aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-06-09 17:00:12 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-06-09 17:00:12 -0400
commit84db8a11ec76e2e01fe299514e18b0558cb6416d (patch)
tree50ae86839e9f13607a9e341b9a81082651926b5e
parentbfcfe4834608b06ffecab2dc185e44669e48f50d (diff)
kernelshark: Clean up CPU dialog code
Use gtk_dialog_run() and examine the results instead of having to create a helper structure that is allocated and passed back to signals. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-filter.c83
1 files changed, 27 insertions, 56 deletions
diff --git a/trace-filter.c b/trace-filter.c
index b7ca5c3..2cc0629 100644
--- a/trace-filter.c
+++ b/trace-filter.c
@@ -58,11 +58,6 @@ int id_cmp(const void *a, const void *b)
58 return 0; 58 return 0;
59} 59}
60 60
61struct dialog_helper {
62 GtkWidget *dialog;
63 gpointer data;
64};
65
66/** 61/**
67 * trace_array_add - allocate and add an int to an array. 62 * trace_array_add - allocate and add an int to an array.
68 * @array: address of array to allocate 63 * @array: address of array to allocate
@@ -1675,8 +1670,6 @@ struct cpu_filter_helper {
1675 guint64 *cpu_mask; 1670 guint64 *cpu_mask;
1676 GtkWidget **buttons; 1671 GtkWidget **buttons;
1677 int cpus; 1672 int cpus;
1678 trace_filter_cpu_cb_func func;
1679 gpointer data;
1680}; 1673};
1681 1674
1682static void destroy_cpu_helper(struct cpu_filter_helper *cpu_helper) 1675static void destroy_cpu_helper(struct cpu_filter_helper *cpu_helper)
@@ -1686,40 +1679,6 @@ static void destroy_cpu_helper(struct cpu_filter_helper *cpu_helper)
1686 g_free(cpu_helper); 1679 g_free(cpu_helper);
1687} 1680}
1688 1681
1689/* Callback for the clicked signal of the CPUS filter button */
1690static void
1691cpu_dialog_response (gpointer data, gint response_id)
1692{
1693 struct dialog_helper *helper = data;
1694 struct cpu_filter_helper *cpu_helper = helper->data;
1695 guint64 *cpu_mask = NULL;
1696
1697 switch (response_id) {
1698 case GTK_RESPONSE_ACCEPT:
1699
1700 if (!cpu_helper->allcpus) {
1701 cpu_mask = cpu_helper->cpu_mask;
1702 cpu_helper->cpu_mask = NULL;
1703 }
1704
1705 cpu_helper->func(TRUE, cpu_helper->allcpus, cpu_mask, cpu_helper->data);
1706 break;
1707
1708 case GTK_RESPONSE_REJECT:
1709 cpu_helper->func(FALSE, FALSE, NULL, cpu_helper->data);
1710 break;
1711 default:
1712 break;
1713 };
1714
1715 g_free(cpu_mask);
1716
1717 gtk_widget_destroy(GTK_WIDGET(helper->dialog));
1718
1719 destroy_cpu_helper(helper->data);
1720 g_free(helper);
1721}
1722
1723#define CPU_ALL_CPUS_STR "All CPUs" 1682#define CPU_ALL_CPUS_STR "All CPUs"
1724 1683
1725void cpu_toggle(gpointer data, GtkWidget *widget) 1684void cpu_toggle(gpointer data, GtkWidget *widget)
@@ -1771,8 +1730,8 @@ void cpu_toggle(gpointer data, GtkWidget *widget)
1771void trace_filter_cpu_dialog(gboolean all_cpus, guint64 *cpus_selected, gint cpus, 1730void trace_filter_cpu_dialog(gboolean all_cpus, guint64 *cpus_selected, gint cpus,
1772 trace_filter_cpu_cb_func func, gpointer data) 1731 trace_filter_cpu_cb_func func, gpointer data)
1773{ 1732{
1774 struct dialog_helper *helper;
1775 struct cpu_filter_helper *cpu_helper; 1733 struct cpu_filter_helper *cpu_helper;
1734 guint64 *cpu_mask = NULL;
1776 GtkWidget *dialog; 1735 GtkWidget *dialog;
1777 GtkWidget *scrollwin; 1736 GtkWidget *scrollwin;
1778 GtkWidget *viewport; 1737 GtkWidget *viewport;
@@ -1784,15 +1743,11 @@ void trace_filter_cpu_dialog(gboolean all_cpus, guint64 *cpus_selected, gint cpu
1784 gint width, height; 1743 gint width, height;
1785 gint allset; 1744 gint allset;
1786 gint cpu; 1745 gint cpu;
1787 1746 int result;
1788 helper = g_malloc(sizeof(*helper));
1789 g_assert(helper != NULL);
1790 1747
1791 cpu_helper = g_new0(typeof(*cpu_helper), 1); 1748 cpu_helper = g_new0(typeof(*cpu_helper), 1);
1792 g_assert(cpu_helper != NULL); 1749 g_assert(cpu_helper != NULL);
1793 1750
1794 helper->data = cpu_helper;
1795
1796 /* --- Make dialog window --- */ 1751 /* --- Make dialog window --- */
1797 1752
1798 dialog = gtk_dialog_new_with_buttons("Filter CPUS", 1753 dialog = gtk_dialog_new_with_buttons("Filter CPUS",
@@ -1804,19 +1759,10 @@ void trace_filter_cpu_dialog(gboolean all_cpus, guint64 *cpus_selected, gint cpu
1804 GTK_RESPONSE_REJECT, 1759 GTK_RESPONSE_REJECT,
1805 NULL); 1760 NULL);
1806 1761
1807 helper->dialog = dialog;
1808
1809 cpu_helper->cpus = cpus; 1762 cpu_helper->cpus = cpus;
1810 cpu_helper->buttons = g_new0(GtkWidget *, cpus + 1); 1763 cpu_helper->buttons = g_new0(GtkWidget *, cpus + 1);
1811 g_assert(cpu_helper->buttons); 1764 g_assert(cpu_helper->buttons);
1812 1765
1813 cpu_helper->func = func;
1814 cpu_helper->data = data;
1815
1816 g_signal_connect_swapped (dialog, "response",
1817 G_CALLBACK (cpu_dialog_response),
1818 (gpointer) helper);
1819
1820 scrollwin = gtk_scrolled_window_new(NULL, NULL); 1766 scrollwin = gtk_scrolled_window_new(NULL, NULL);
1821 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), 1767 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin),
1822 GTK_POLICY_AUTOMATIC, 1768 GTK_POLICY_AUTOMATIC,
@@ -1908,6 +1854,31 @@ void trace_filter_cpu_dialog(gboolean all_cpus, guint64 *cpus_selected, gint cpu
1908 width, height); 1854 width, height);
1909 1855
1910 gtk_widget_show_all(dialog); 1856 gtk_widget_show_all(dialog);
1857
1858 result = gtk_dialog_run(GTK_DIALOG(dialog));
1859 switch (result) {
1860 case GTK_RESPONSE_ACCEPT:
1861
1862 if (!cpu_helper->allcpus) {
1863 cpu_mask = cpu_helper->cpu_mask;
1864 cpu_helper->cpu_mask = NULL;
1865 }
1866
1867 func(TRUE, cpu_helper->allcpus, cpu_mask, data);
1868 break;
1869
1870 case GTK_RESPONSE_REJECT:
1871 func(FALSE, FALSE, NULL, data);
1872 break;
1873 default:
1874 break;
1875 };
1876
1877 g_free(cpu_mask);
1878
1879 gtk_widget_destroy(dialog);
1880
1881 destroy_cpu_helper(cpu_helper);
1911} 1882}
1912 1883
1913static void add_system_str(gchar ***systems, char *system, int count) 1884static void add_system_str(gchar ***systems, char *system, int count)