Patch: Error messages
- From: Devin Heitmueller <dheitmueller netilla com>
- To: memprof-list gnome org
- Subject: Patch: Error messages
- Date: 22 Sep 2002 16:20:57 -0400
In response to concerns by Owen Taylor that the previous patch should
disable the buttons instead of showing an error message, attached is a
patch that does the following:
* Changes the id tags in memprof.glade to give the buttons meaningful
names
* Add the buttons to the pwin structure, the same way the status bar
works
* Add a function called update_toolbar(), which will show the proper
sensitivity for the buttons given the state of the process.
* Add calls to update_toolbar() on initialization, loading of a process,
killing of a process, generating the profile, etc.
Please let me know if this is the correct approach. If it is, I will
create a patch to address the menu items as well. If not, a brief
description of what is wrong will help greatly in creating the
appropriate fix.
Thanks,
--
Devin Heitmueller
Senior Software Engineer
Netilla Networks Inc
? main.diff2
Index: main.c
===================================================================
RCS file: /cvs/gnome/memprof/main.c,v
retrieving revision 1.25
diff --unified -r1.25 main.c
--- main.c 5 Sep 2002 19:16:38 -0000 1.25
+++ main.c 22 Sep 2002 20:12:04 -0000
@@ -66,6 +66,12 @@
GtkWidget *usage_max_label;
GtkWidget *usage_canvas;
+ GtkWidget *toolbar_run_button;
+ GtkWidget *toolbar_kill_button;
+ GtkWidget *toolbar_profile_button;
+ GtkWidget *toolbar_leaks_button;
+ GtkWidget *toolbar_save_button;
+
guint usage_max;
guint usage_high;
guint usage_leaked;
@@ -167,11 +173,33 @@
pwin->usage_high = MAX (pwin->process->bytes_used, pwin->usage_high);
update_bars (pwin);
-
+
return TRUE;
}
static void
+update_toolbar (ProcessWindow *pwin)
+{
+ if (pwin->process) {
+ gtk_widget_set_sensitive (pwin->toolbar_kill_button, TRUE);
+ gtk_widget_set_sensitive (pwin->toolbar_profile_button, TRUE);
+ gtk_widget_set_sensitive (pwin->toolbar_leaks_button, TRUE);
+ }
+ else {
+ gtk_widget_set_sensitive (pwin->toolbar_kill_button, FALSE);
+ gtk_widget_set_sensitive (pwin->toolbar_profile_button, FALSE);
+ gtk_widget_set_sensitive (pwin->toolbar_leaks_button, FALSE);
+
+ }
+ if (pwin->profile) {
+ gtk_widget_set_sensitive (pwin->toolbar_save_button, TRUE);
+ }
+ else {
+ gtk_widget_set_sensitive (pwin->toolbar_save_button, FALSE);
+ }
+}
+
+static void
usage_canvas_size_allocate (GtkWidget *widget,
GtkAllocation *allocation,
ProcessWindow *pwin)
@@ -742,6 +770,7 @@
gtk_window_set_title (GTK_WINDOW (pwin->main_window), "MemProf");
update_bars (pwin);
+ update_toolbar(pwin);
}
static void
@@ -797,8 +826,9 @@
init_process (pwin, process);
- gtk_widget_show (pwin->main_window);
+ update_toolbar (pwin);
+ gtk_widget_show (pwin->main_window);
result = TRUE;
} else {
@@ -985,6 +1015,8 @@
gtk_notebook_set_page (GTK_NOTEBOOK (pwin->main_notebook), 0);
}
+
+ update_toolbar (pwin);
}
static void
@@ -1520,6 +1552,12 @@
menuitem = glade_xml_get_widget (xml, "follow-exec");
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem), pwin->follow_exec);
+ pwin->toolbar_run_button = glade_xml_get_widget (xml, "toolbar-run-button");
+ pwin->toolbar_kill_button = glade_xml_get_widget (xml, "toolbar-kill-button");
+ pwin->toolbar_profile_button = glade_xml_get_widget (xml, "toolbar-profile-button");
+ pwin->toolbar_leaks_button = glade_xml_get_widget (xml, "toolbar-leaks-button");
+ pwin->toolbar_save_button = glade_xml_get_widget (xml,"toolbar-save-button");
+
pwin->n_allocations_label = glade_xml_get_widget (xml, "n-allocations-label");
pwin->bytes_per_label = glade_xml_get_widget (xml, "bytes-per-label");
pwin->total_bytes_label = glade_xml_get_widget (xml, "total-bytes-label");
@@ -1689,8 +1727,10 @@
response = gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
- if (response == GTK_RESPONSE_YES)
+ if (response == GTK_RESPONSE_YES) {
process_detach (pwin->process);
+ update_toolbar (pwin);
+ }
}
@@ -1714,8 +1754,10 @@
response = gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
- if (response == GTK_RESPONSE_YES)
+ if (response == GTK_RESPONSE_YES) {
process_kill (pwin->process);
+ update_toolbar (pwin);
+ }
}
}
@@ -1878,6 +1920,9 @@
NULL, NULL, NULL);
gtk_widget_show (initial_window->main_window);
+
+ /* Set the initial state of the buttons to disabled */
+ update_toolbar (initial_window);
startup_args = poptGetArgs (ctx);
if (startup_args)
Index: memprof.glade
===================================================================
RCS file: /cvs/gnome/memprof/memprof.glade,v
retrieving revision 1.17
diff --unified -r1.17 memprof.glade
--- memprof.glade 5 Sep 2002 19:16:38 -0000 1.17
+++ memprof.glade 22 Sep 2002 20:12:05 -0000
@@ -335,7 +335,7 @@
<property name="visible">yes</property>
<child>
- <widget class="button" id="button2">
+ <widget class="button" id="toolbar-run-button">
<property name="tooltip" translatable="yes">Run Program</property>
<property name="label" translatable="yes">Run</property>
<property name="stock_pixmap">gtk-execute</property>
@@ -346,7 +346,7 @@
</child>
<child>
- <widget class="button" id="button26">
+ <widget class="button" id="toolbar-kill-button">
<property name="tooltip" translatable="yes">Kill Program</property>
<property name="label" translatable="yes">Kill</property>
<property name="stock_pixmap">gtk-close</property>
@@ -357,7 +357,7 @@
</child>
<child>
- <widget class="button" id="button4">
+ <widget class="button" id="toolbar-profile-button">
<property name="tooltip" translatable="yes">Create Profile</property>
<property name="label" translatable="yes">Profile</property>
<property name="stock_pixmap">gtk-justify-left</property>
@@ -379,7 +379,7 @@
</child>
<child>
- <widget class="button" id="button3">
+ <widget class="button" id="toolbar-save-button">
<property name="tooltip" translatable="yes">Save Report</property>
<property name="label" translatable="yes">Save</property>
<property name="stock_pixmap">gtk-save</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]