aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/menu.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2004-01-06 22:38:07 +0000
committerGuy Harris <guy@alum.mit.edu>2004-01-06 22:38:07 +0000
commit73d47925ebf2806453f5dee513c0313595fbb432 (patch)
treea05294092f4d1a9f871523b4f26963affac18056 /gtk/menu.c
parent5f4ed6f6f83d71ba27a0f150870e56d6a85eb9a9 (diff)
Widgets get freed when the reference count goes to zero; we don't need
to explicitly destroy menu items when we remove them from the "recent files" list. Clean up indentation. svn path=/trunk/; revision=9578
Diffstat (limited to 'gtk/menu.c')
-rw-r--r--gtk/menu.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/gtk/menu.c b/gtk/menu.c
index 718386504b..4294868b6a 100644
--- a/gtk/menu.c
+++ b/gtk/menu.c
@@ -1,7 +1,7 @@
/* menu.c
* Menu routines
*
- * $Id: menu.c,v 1.134 2004/01/04 06:16:57 sharpe Exp $
+ * $Id: menu.c,v 1.135 2004/01/06 22:38:07 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -679,21 +679,21 @@ set_menu_object_data (gchar *path, gchar *key, gpointer data) {
void
update_menu_recent_capture_file1(GtkWidget *widget, gpointer cnt) {
- gchar *widget_cf_name;
+ gchar *widget_cf_name;
widget_cf_name = OBJECT_GET_DATA(widget, MENU_RECENT_FILES_KEY);
- /* if this menu item is a file, count it */
- if (widget_cf_name) {
+ /* if this menu item is a file, count it */
+ if (widget_cf_name) {
(*(guint *)cnt)++;
- }
+ }
}
/* update the menu */
void
update_menu_recent_capture_file(GtkWidget *submenu_recent_files) {
- guint cnt = 0;
+ guint cnt = 0;
gtk_container_foreach(GTK_CONTAINER(submenu_recent_files),
update_menu_recent_capture_file1, &cnt);
@@ -716,9 +716,10 @@ remove_menu_recent_capture_file(GtkWidget *widget, gpointer unused _U_) {
/* get the submenu container item */
submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
- /* XXX: is this all we need to do, to destroy the menu item and its label? */
+ /* XXX: is this all we need to do, to free the menu item and its label?
+ The reference count of widget will go to 0, so it'll be freed;
+ will that free the label? */
gtk_container_remove(GTK_CONTAINER(submenu_recent_files), widget);
- gtk_widget_destroy(widget);
}
@@ -762,7 +763,7 @@ menu_open_recent_file_cmd_cb(GtkWidget *w, gpointer unused _U_)
remove_menu_recent_capture_file(w, NULL);
}
- update_menu_recent_capture_file(submenu_recent_files);
+ update_menu_recent_capture_file(submenu_recent_files);
}
@@ -785,18 +786,18 @@ add_menu_recent_capture_file_absolute(gchar *cf_name) {
/* iterate through list items of menu_item_list,
* removing special items, a maybe duplicate entry and every item above count_max */
- cnt = 1;
+ cnt = 1;
for (li = g_list_first(menu_item_list); li; li = li->next, cnt++) {
/* get capture filename */
- menu_item = (GtkWidget *) li->data;
- widget_cf_name = OBJECT_GET_DATA(menu_item, MENU_RECENT_FILES_KEY);
+ menu_item = GTK_WIDGET(li->data);
+ widget_cf_name = OBJECT_GET_DATA(menu_item, MENU_RECENT_FILES_KEY);
/* if this element string is one of our special items or
- * already in the list or
+ * already in the list or
* this element is above maximum count (too old), remove it */
if (!widget_cf_name ||
- strncmp(widget_cf_name, cf_name, 1000) == 0 ||
- cnt >= prefs.gui_recent_files_count_max) {
+ strncmp(widget_cf_name, cf_name, 1000) == 0 ||
+ cnt >= prefs.gui_recent_files_count_max) {
remove_menu_recent_capture_file(li->data, NULL);
cnt--;
}
@@ -806,8 +807,8 @@ add_menu_recent_capture_file_absolute(gchar *cf_name) {
/* add new item at latest position */
menu_item = gtk_menu_item_new_with_label(cf_name);
- widget_cf_name = g_strdup(cf_name);
- OBJECT_SET_DATA(menu_item, MENU_RECENT_FILES_KEY, widget_cf_name);
+ widget_cf_name = g_strdup(cf_name);
+ OBJECT_SET_DATA(menu_item, MENU_RECENT_FILES_KEY, widget_cf_name);
gtk_menu_prepend (GTK_MENU(submenu_recent_files), menu_item);
SIGNAL_CONNECT_OBJECT(GTK_OBJECT(menu_item), "activate",
menu_open_recent_file_cmd_cb, (GtkObject *) menu_item);
@@ -818,14 +819,14 @@ add_menu_recent_capture_file_absolute(gchar *cf_name) {
gtk_menu_append (GTK_MENU(submenu_recent_files), menu_item);
gtk_widget_show (menu_item);
- /* add new "clear list" item at last position */
+ /* add new "clear list" item at last position */
menu_item = gtk_menu_item_new_with_label("<clear file list>");
gtk_menu_append (GTK_MENU(submenu_recent_files), menu_item);
SIGNAL_CONNECT_OBJECT(GTK_OBJECT(menu_item), "activate",
clear_menu_recent_capture_file_cmd_cb, (GtkObject *) menu_item);
gtk_widget_show (menu_item);
- update_menu_recent_capture_file(submenu_recent_files);
+ update_menu_recent_capture_file(submenu_recent_files);
}
@@ -861,11 +862,11 @@ void menu_recent_file_write(GtkWidget *widget, gpointer data) {
/* get capture filename from the menu item label */
- cf_name = OBJECT_GET_DATA(widget, MENU_RECENT_FILES_KEY);
+ cf_name = OBJECT_GET_DATA(widget, MENU_RECENT_FILES_KEY);
- if (cf_name) {
+ if (cf_name) {
fprintf (rf, RECENT_KEY_CAPTURE_FILE ": %s\n", cf_name);
- }
+ }
}