From: Jim Evins Date: Wed, 21 Oct 2009 02:42:15 +0000 (-0400) Subject: Minor cleanup of glFieldButton widgets X-Git-Tag: glabels-2_3_0~155 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f83b6537a0fdf8f6f25483ab691a76923c10508a;p=glabels Minor cleanup of glFieldButton widgets Free proper data in gl_field_button_menu_finalize(). Minor formatting cleanup. --- diff --git a/src/field-button-menu.c b/src/field-button-menu.c index a59bb3b2..38f23481 100644 --- a/src/field-button-menu.c +++ b/src/field-button-menu.c @@ -93,11 +93,11 @@ gl_field_button_menu_class_init (glFieldButtonMenuClass *class) static void -gl_field_button_menu_init (glFieldButtonMenu *merge_menu) +gl_field_button_menu_init (glFieldButtonMenu *this) { gl_debug (DEBUG_FIELD_BUTTON, "START"); - merge_menu->priv = g_new0 (glFieldButtonMenuPrivate, 1); + this->priv = g_new0 (glFieldButtonMenuPrivate, 1); gl_debug (DEBUG_FIELD_BUTTON, "END"); } @@ -106,24 +106,24 @@ gl_field_button_menu_init (glFieldButtonMenu *merge_menu) static void gl_field_button_menu_finalize (GObject *object) { - glFieldButtonMenu *merge_menu = GL_FIELD_BUTTON_MENU (object); + glFieldButtonMenu *this = GL_FIELD_BUTTON_MENU (object); GList *p; GtkWidget *menu_item; - gchar *field; + gchar *key; gl_debug (DEBUG_FIELD_BUTTON, "START"); g_return_if_fail (object != NULL); g_return_if_fail (GL_IS_FIELD_BUTTON_MENU (object)); - for ( p = merge_menu->priv->menu_items; p != NULL; p = p->next ) + for ( p = this->priv->menu_items; p != NULL; p = p->next ) { menu_item = GTK_WIDGET (p->data); - field = g_object_get_data (G_OBJECT (menu_item), "field"); - g_free (field); + key = g_object_get_data (G_OBJECT (menu_item), "key"); + g_free (key); } - g_list_free (merge_menu->priv->menu_items); - g_free (merge_menu->priv); + g_list_free (this->priv->menu_items); + g_free (this->priv); G_OBJECT_CLASS (gl_field_button_menu_parent_class)->finalize (object); @@ -134,15 +134,15 @@ gl_field_button_menu_finalize (GObject *object) GtkWidget * gl_field_button_menu_new (void) { - glFieldButtonMenu *merge_menu; + glFieldButtonMenu *this; gl_debug (DEBUG_FIELD_BUTTON, "START"); - merge_menu = g_object_new (gl_field_button_menu_get_type (), NULL); + this = g_object_new (gl_field_button_menu_get_type (), NULL); gl_debug (DEBUG_FIELD_BUTTON, "END"); - return GTK_WIDGET (merge_menu); + return GTK_WIDGET (this); } @@ -151,7 +151,7 @@ gl_field_button_menu_new (void) /*--------------------------------------------------------------------------*/ static void activate_cb (GtkMenuItem *menu_item, - glFieldButtonMenu *merge_menu) + glFieldButtonMenu *this) { gchar *key; @@ -160,7 +160,7 @@ activate_cb (GtkMenuItem *menu_item, key = g_object_get_data (G_OBJECT (menu_item), "key"); gl_debug (DEBUG_FIELD_BUTTON, "Key activated: \"%s\"\n", key ); - g_signal_emit (G_OBJECT (merge_menu), signals[KEY_SELECTED], 0, key); + g_signal_emit (G_OBJECT (this), signals[KEY_SELECTED], 0, key); gl_debug (DEBUG_FIELD_BUTTON, "END"); } @@ -170,7 +170,7 @@ activate_cb (GtkMenuItem *menu_item, /* set key names. */ /****************************************************************************/ void -gl_field_button_menu_set_keys (glFieldButtonMenu *merge_menu, +gl_field_button_menu_set_keys (glFieldButtonMenu *this, GList *key_list) { GList *p; @@ -182,15 +182,15 @@ gl_field_button_menu_set_keys (glFieldButtonMenu *merge_menu, /* * Remove all old menu items. */ - for ( p = merge_menu->priv->menu_items; p != NULL; p = p->next ) + for ( p = this->priv->menu_items; p != NULL; p = p->next ) { menu_item = GTK_WIDGET (p->data); key = g_object_get_data (G_OBJECT (menu_item), "key"); g_free (key); gtk_widget_destroy (menu_item); } - g_list_free (merge_menu->priv->menu_items); - merge_menu->priv->menu_items = NULL; + g_list_free (this->priv->menu_items); + this->priv->menu_items = NULL; /* * Add new menu items. @@ -201,10 +201,10 @@ gl_field_button_menu_set_keys (glFieldButtonMenu *merge_menu, menu_item = gtk_menu_item_new_with_label (p->data); g_object_set_data (G_OBJECT (menu_item), "key", g_strdup (p->data)); g_signal_connect (G_OBJECT (menu_item), "activate", - G_CALLBACK (activate_cb), merge_menu); - gtk_menu_shell_append (GTK_MENU_SHELL (merge_menu), menu_item); - merge_menu->priv->menu_items = - g_list_append (merge_menu->priv->menu_items, menu_item); + G_CALLBACK (activate_cb), this); + gtk_menu_shell_append (GTK_MENU_SHELL (this), menu_item); + this->priv->menu_items = + g_list_append (this->priv->menu_items, menu_item); } gl_debug (DEBUG_FIELD_BUTTON, "END"); diff --git a/src/field-button-menu.h b/src/field-button-menu.h index cdb2a261..83e6bd63 100644 --- a/src/field-button-menu.h +++ b/src/field-button-menu.h @@ -62,7 +62,7 @@ GType gl_field_button_menu_get_type (void) G_GNUC_CONST; GtkWidget *gl_field_button_menu_new (void); -void gl_field_button_menu_set_keys (glFieldButtonMenu *merge_menu, +void gl_field_button_menu_set_keys (glFieldButtonMenu *this, GList *key_list); diff --git a/src/field-button.c b/src/field-button.c index e307bfb5..a2892728 100644 --- a/src/field-button.c +++ b/src/field-button.c @@ -199,9 +199,9 @@ menu_position_function (GtkMenu *menu, gpointer user_data) { glFieldButton *this = GL_FIELD_BUTTON (user_data); - GdkWindow *window; - gint x1, y1; - gint menu_h, menu_w; + GdkWindow *window; + gint x1, y1; + gint menu_h, menu_w; window = gtk_widget_get_window (GTK_WIDGET (this)); @@ -237,7 +237,7 @@ menu_position_function (GtkMenu *menu, static gboolean button_press_event_cb (GtkWidget *widget, GdkEventButton *event, - glFieldButton *this) + glFieldButton *this) { switch (event->button) { @@ -277,7 +277,7 @@ menu_key_selected_cb (glFieldButtonMenu *menu, /*****************************************************************************/ static void menu_selection_done_cb (GtkMenuShell *object, - glFieldButton *this) + glFieldButton *this) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (this), FALSE); }