[Xfce4-commits] [apps/xfce4-dict] 02/02: Reverting to deprecated GtkImageMenuItem

noreply at xfce.org noreply at xfce.org
Sat May 26 21:49:22 CEST 2018


This is an automated email from the git hooks/post-receive script.

a   n   d   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfce4-dict.

commit 08b46c5396e8a3a40d0368702a2a737995d53555
Author: Andre Miranda <andreldm at xfce.org>
Date:   Sat May 26 16:47:18 2018 -0300

    Reverting to deprecated GtkImageMenuItem
    
    The workaround proposed by gtk authors is not only
    complicated, it also add a very ugly left padding that's
    impossible to remove AFAICT.
    So let's keep the deprecated widget while it's around.
---
 lib/gui.c | 86 +++++++++++++++++++++------------------------------------------
 1 file changed, 29 insertions(+), 57 deletions(-)

diff --git a/lib/gui.c b/lib/gui.c
index 15046b9..3094415 100644
--- a/lib/gui.c
+++ b/lib/gui.c
@@ -347,37 +347,6 @@ static gboolean textview_is_hyperlink_at_cursor(DictData *dd)
 
 
 
-static GtkWidget*
-create_menu_item(GtkWidget* label, GtkWidget* image)
-{
-    GtkWidget *mi;
-    GtkWidget *box;
-
-    /* create item */
-    mi = gtk_menu_item_new ();
-
-    gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
-    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
-
-    box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-    gtk_widget_set_halign (label, GTK_ALIGN_START);
-
-    /* Add the image and label to the box, add the box to the menu item */
-    if (image && GTK_IS_WIDGET(image)) {
-        /* only add the widget if it exists */
-        gtk_widget_show (image);
-        gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
-    }
-
-    gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 6);
-    gtk_widget_show_all (box);
-    gtk_container_add (GTK_CONTAINER (mi), box);
-
-    return mi;
-}
-
-
-
 static void textview_populate_popup_cb(GtkTextView *textview, GtkMenu *menu, DictData *dd)
 {
 	GtkWidget *box, *icon, *label;
@@ -389,17 +358,21 @@ static void textview_populate_popup_cb(GtkTextView *textview, GtkMenu *menu, Dic
 	gtk_widget_show(sep);
 	gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), sep);
 
-	label = gtk_label_new (_("Copy Link"));
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+	copy_link = gtk_image_menu_item_new_with_mnemonic (_("Copy Link"));
 	icon = gtk_image_new_from_icon_name ("gtk-copy", GTK_ICON_SIZE_MENU);
-	copy_link = create_menu_item(label, icon);
+	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (copy_link), icon);
+G_GNUC_END_IGNORE_DEPRECATIONS
 
 	gtk_widget_show_all(copy_link);
 	gtk_widget_set_sensitive(GTK_WIDGET(copy_link), textview_is_hyperlink_at_cursor(dd));
 	gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), copy_link);
 
-	label = gtk_label_new (_("Search"));
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+	search = gtk_image_menu_item_new_with_mnemonic (_("Search"));
 	icon = gtk_image_new_from_icon_name ("gtk-find", GTK_ICON_SIZE_MENU);
-	search = create_menu_item(label, icon);
+	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (search), icon);
+G_GNUC_END_IGNORE_DEPRECATIONS
 
 	gtk_widget_show_all(search);
 	gtk_widget_set_sensitive(GTK_WIDGET(search), textview_is_text_at_cursor(dd));
@@ -707,7 +680,7 @@ static void speedreader_clicked_cb(GtkButton *button, DictData *dd)
 
 static GtkWidget *create_file_menu(DictData *dd)
 {
-	GtkWidget *icon, *label;
+	GtkWidget *icon;
 	GtkWidget *menubar, *file, *file_menu, *help, *help_menu, *menu_item;
 
 	GtkAccelGroup *accel_group = gtk_accel_group_new();
@@ -722,16 +695,14 @@ static GtkWidget *create_file_menu(DictData *dd)
 	gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), file_menu);
 
 	/* Speed Reader */
-	label = gtk_accel_label_new (_("Speed _Reader"));
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+	menu_item = gtk_image_menu_item_new_with_mnemonic (_("Speed _Reader"));
 	icon = gtk_image_new_from_icon_name ("gtk-justify-center", GTK_ICON_SIZE_MENU);
-	menu_item = create_menu_item (label, icon);
+	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), icon);
+G_GNUC_END_IGNORE_DEPRECATIONS
 
-	gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
-	gtk_label_set_xalign (GTK_LABEL (label), 0.0);
 	gtk_widget_add_accelerator (menu_item, "activate", accel_group,
                                 GDK_KEY_r, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
-	gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), menu_item);
-
 	g_signal_connect(menu_item, "activate", G_CALLBACK(speedreader_clicked_cb), dd);
 	gtk_container_add(GTK_CONTAINER(file_menu), menu_item);
 
@@ -739,30 +710,29 @@ static GtkWidget *create_file_menu(DictData *dd)
 	gtk_container_add(GTK_CONTAINER(file_menu), gtk_separator_menu_item_new());
 
 	/* Preferences */
-	label = gtk_accel_label_new (_("_Preferences"));
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+	dd->pref_menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Preferences"));
 	icon = gtk_image_new_from_icon_name ("gtk-preferences", GTK_ICON_SIZE_MENU);
-	dd->pref_menu_item = create_menu_item (label, icon);
+	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (dd->pref_menu_item), icon);
+G_GNUC_END_IGNORE_DEPRECATIONS
 
-	gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
-	gtk_label_set_xalign (GTK_LABEL (label), 0.0);
 	gtk_widget_add_accelerator (dd->pref_menu_item, "activate", accel_group,
-                                GDK_KEY_p, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
-	gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), dd->pref_menu_item);
+								GDK_KEY_p, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
 	gtk_container_add(GTK_CONTAINER(file_menu), dd->pref_menu_item);
 
 	/* Separator */
 	gtk_container_add(GTK_CONTAINER(file_menu), gtk_separator_menu_item_new());
 
 	/* Close */
-	label = gtk_accel_label_new (_("_Quit"));
-	icon = gtk_image_new_from_icon_name ((dd->is_plugin) ? "gtk-close" : "gtk-quit", GTK_ICON_SIZE_MENU);
-	dd->close_menu_item = create_menu_item (label, icon);
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+	dd->close_menu_item = gtk_image_menu_item_new_with_mnemonic (dd->is_plugin ? _("_Close") : _("_Quit"));
+	icon = gtk_image_new_from_icon_name (dd->is_plugin ? "gtk-close" : "gtk-quit", GTK_ICON_SIZE_MENU);
+	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (dd->close_menu_item), icon);
+G_GNUC_END_IGNORE_DEPRECATIONS
 
-	gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
-	gtk_label_set_xalign (GTK_LABEL (label), 0.0);
 	gtk_widget_add_accelerator (dd->close_menu_item, "activate", accel_group,
-                                GDK_KEY_q, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
-	gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), dd->close_menu_item);
+								dd->is_plugin ? GDK_KEY_c : GDK_KEY_q,
+								GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
 	gtk_container_add(GTK_CONTAINER(file_menu), dd->close_menu_item);
 
 	/* Help Menu*/
@@ -772,9 +742,11 @@ static GtkWidget *create_file_menu(DictData *dd)
 	gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), help_menu);
 
 	/* About */
-	label = gtk_label_new (_("About"));
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+	menu_item = gtk_image_menu_item_new_with_mnemonic (_("About"));
 	icon = gtk_image_new_from_icon_name ("gtk-about", GTK_ICON_SIZE_MENU);
-	menu_item = create_menu_item (label, icon);
+	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), icon);
+G_GNUC_END_IGNORE_DEPRECATIONS
 
 	gtk_container_add(GTK_CONTAINER(help_menu), menu_item);
 	g_signal_connect(menu_item, "activate", G_CALLBACK(dict_gui_about_dialog), dd);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list