/soc/2015/mmcc/main: 9415ac64b6fa: add a helper function so that...

Michael McConville mmcconville at mykolab.com
Tue Jul 7 21:45:44 EDT 2015


Changeset: 9415ac64b6fa9a84c96a0a8ada728454e0948187
Author:	 Michael McConville <mmcconville at mykolab.com>
Date:	 2015-07-07 21:45 -0400
Branch:	 default
URL: https://hg.pidgin.im/soc/2015/mmcc/main/rev/9415ac64b6fa

Description:

add a helper function so that we don't need tons of GTK boilerplate for every label alignment

diffstat:

 pidgin/gtk3compat.h                           |   13 ++
 pidgin/gtkaccount.c                           |    7 +-
 pidgin/gtkblist.c                             |   41 +------
 pidgin/gtkconv.c                              |   53 +---------
 pidgin/gtkdialogs.c                           |    9 +-
 pidgin/gtklog.c                               |   18 +---
 pidgin/gtkmedia.c                             |   18 +---
 pidgin/gtknotify.c                            |   36 +------
 pidgin/gtkplugin.c                            |   72 +------------
 pidgin/gtkpluginpref.c                        |   36 +------
 pidgin/gtkpounce.c                            |   18 +---
 pidgin/gtkprefs.c                             |  135 ++-----------------------
 pidgin/gtkprivacy.c                           |    9 +-
 pidgin/gtkrequest.c                           |   81 +-------------
 pidgin/gtksavedstatuses.c                     |   18 +---
 pidgin/gtkutils.c                             |   27 +----
 pidgin/gtkxfer.c                              |   18 +---
 pidgin/minidialog.c                           |   27 +----
 pidgin/plugins/cap/cap.c                      |   54 +---------
 pidgin/plugins/contact_priority.c             |    9 +-
 pidgin/plugins/gevolution/add_buddy_dialog.c  |    9 +-
 pidgin/plugins/gevolution/assoc-buddy.c       |    9 +-
 pidgin/plugins/gevolution/gevolution.c        |    9 +-
 pidgin/plugins/gevolution/new_person_dialog.c |   27 +----
 pidgin/plugins/themeedit-icon.c               |    9 +-
 pidgin/plugins/themeedit.c                    |   18 +---
 pidgin/plugins/xmppconsole.c                  |  117 ++--------------------
 27 files changed, 112 insertions(+), 785 deletions(-)

diffs (truncated from 1630 to 300 lines):

diff --git a/pidgin/gtk3compat.h b/pidgin/gtk3compat.h
--- a/pidgin/gtk3compat.h
+++ b/pidgin/gtk3compat.h
@@ -89,4 +89,17 @@ gtk_grid_attach_full(GtkGrid *grid, GtkW
 	gtk_widget_set_margin_bottom(child, ypadding);
 }
 
+static inline void
+gtk_label_set_alignment(GtkLabel *label, gfloat xalign, gfloat yalign)
+{
+#if GTK_CHECK_VERSION (3,16,0)
+	gtk_label_set_xalign(label, xalign);
+	gtk_label_set_yalign(label, yalign);
+#else
+	G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+	gtk_misc_set_alignment(GTK_MISC(label), xalign, yalign);
+	G_GNUC_END_IGNORE_DEPRECATIONS;
+#endif
+}
+
 #endif /* _PIDGINGTK3COMPAT_H_ */
diff --git a/pidgin/gtkaccount.c b/pidgin/gtkaccount.c
--- a/pidgin/gtkaccount.c
+++ b/pidgin/gtkaccount.c
@@ -2299,12 +2299,7 @@ create_accounts_list(AccountsWindow *dia
 	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
 	gtk_widget_show(label);
 
-#if GTK_CHECK_VERSION (3,16,0)
-#else
-	G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-	gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
-	G_GNUC_END_IGNORE_DEPRECATIONS;
-#endif
+	gtk_label_set_alignment(GTK_LABEL(label), 0.5, 0.5);
 	gtk_notebook_append_page(GTK_NOTEBOOK(accounts_window->notebook), label, NULL);
 
 	/* Create the list model. */
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -1010,14 +1010,7 @@ make_blist_request_dialog(PidginBlistReq
 
 	gtk_widget_set_size_request(label, 400, -1);
 	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
-#if GTK_CHECK_VERSION (3,16,0)
-	gtk_label_set_xalign(GTK_LABEL(label), GTK_ALIGN_START);
-	gtk_label_set_yalign(GTK_LABEL(label), GTK_ALIGN_START);
-#else
-	G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-	gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
-	G_GNUC_END_IGNORE_DEPRECATIONS;
-#endif
+	gtk_label_set_alignment(GTK_LABEL(label), 0, 0);
 	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
 
 	data->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
@@ -5382,14 +5375,7 @@ create_account_label(PurpleAccount *acco
 	markup = g_strdup_printf("<span size=\"smaller\">%s</span>", username);
 	gtk_label_set_markup(GTK_LABEL(label), markup);
 	g_free(markup);
-#if GTK_CHECK_VERSION (3,16,0)
-	gtk_label_set_xalign(GTK_LABEL(label), GTK_ALIGN_START);
-	gtk_label_set_yalign(GTK_LABEL(label), GTK_ALIGN_START);
-#else
-	G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-	gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
-	G_GNUC_END_IGNORE_DEPRECATIONS;
-#endif
+	gtk_label_set_alignment(GTK_LABEL(label), 0, 0);
 	g_object_set(G_OBJECT(label), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
 	description = purple_account_get_current_error(account)->description;
 	if (description != NULL && *description != '\0')
@@ -5569,26 +5555,14 @@ kiosk_page()
 
 	label = gtk_label_new(NULL);
 	gtk_label_set_markup(GTK_LABEL(label), _("<b>Username:</b>"));
-#if GTK_CHECK_VERSION (3,16,0)
-	gtk_label_set_xalign(GTK_LABEL(label), GTK_ALIGN_START);
-#else
-	G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
-	G_GNUC_END_IGNORE_DEPRECATIONS;
-#endif
+	gtk_label_set_alignment(GTK_LABEL(label), 0.0, 0.5);
 	gtk_box_pack_start(GTK_BOX(ret), label, FALSE, FALSE, 0);
 	entry = gtk_entry_new();
 	gtk_box_pack_start(GTK_BOX(ret), entry, FALSE, FALSE, 0);
 
 	label = gtk_label_new(NULL);
 	gtk_label_set_markup(GTK_LABEL(label), _("<b>Password:</b>"));
-#if GTK_CHECK_VERSION (3,16,0)
-	gtk_label_set_xalign(GTK_LABEL(label), GTK_ALIGN_START);
-#else
-	G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
-	G_GNUC_END_IGNORE_DEPRECATIONS;
-#endif
+	gtk_label_set_alignment(GTK_LABEL(label), 0.0, 0.5);
 	gtk_box_pack_start(GTK_BOX(ret), label, FALSE, FALSE, 0);
 	entry = gtk_entry_new();
 	gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
@@ -5898,12 +5872,7 @@ static void pidgin_blist_show(PurpleBudd
 	g_free(tmp);
 	label = gtk_label_new(NULL);
 	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
-#if GTK_CHECK_VERSION (3,16,0)
-#else
-	G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-	gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.2);
-	G_GNUC_END_IGNORE_DEPRECATIONS;
-#endif
+	gtk_label_set_alignment(GTK_LABEL(label), 0.5, 0.2);
 	gtk_label_set_markup(GTK_LABEL(label), pretty);
 	g_free(pretty);
 	gtk_notebook_append_page(GTK_NOTEBOOK(gtkblist->notebook),label, NULL);
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -970,14 +970,7 @@ invite_cb(GtkWidget *widget, PidginConve
 								"message."));
 		gtk_widget_set_size_request(label, 350, -1);
 		gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
-#if GTK_CHECK_VERSION (3,16,0)
-		gtk_label_set_xalign(GTK_LABEL(label), GTK_ALIGN_START);
-		gtk_label_set_yalign(GTK_LABEL(label), GTK_ALIGN_START);
-#else
-		G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-		gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
-		G_GNUC_END_IGNORE_DEPRECATIONS;
-#endif
+		gtk_label_set_alignment(GTK_LABEL(label), 0, 0);
 		gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
 
 		/* hbox for the grid, and to give it some spacing on the left. */
@@ -994,14 +987,7 @@ invite_cb(GtkWidget *widget, PidginConve
 		/* Now the Buddy label */
 		label = gtk_label_new(NULL);
 		gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:"));
-#if GTK_CHECK_VERSION (3,16,0)
-		gtk_label_set_xalign(GTK_LABEL(label), GTK_ALIGN_START);
-		gtk_label_set_yalign(GTK_LABEL(label), GTK_ALIGN_START);
-#else
-		G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-		gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
-		G_GNUC_END_IGNORE_DEPRECATIONS;
-#endif
+		gtk_label_set_alignment(GTK_LABEL(label), 0, 0);
 		gtk_grid_attach_defaults(GTK_GRID(grid), label, 0, 0, 1, 1);
 
 		/* Now the Buddy drop-down entry field. */
@@ -1014,14 +1000,7 @@ invite_cb(GtkWidget *widget, PidginConve
 		/* Now the label for "Message" */
 		label = gtk_label_new(NULL);
 		gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:"));
-#if GTK_CHECK_VERSION (3,16,0)
-		gtk_label_set_xalign(GTK_LABEL(label), GTK_ALIGN_START);
-		gtk_label_set_yalign(GTK_LABEL(label), GTK_ALIGN_START);
-#else
-		G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-		gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
-		G_GNUC_END_IGNORE_DEPRECATIONS;
-#endif
+		gtk_label_set_alignment(GTK_LABEL(label), 0, 0);
 		gtk_grid_attach_defaults(GTK_GRID(grid), label, 0, 1, 1, 1);
 
 
@@ -9063,14 +9042,7 @@ build_warn_close_dialog(PidginConvWindow
 	label = gtk_label_new(_("You have unread messages. Are you sure you want to close the window?"));
 	gtk_widget_set_size_request(label, 350, -1);
 	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
-#if GTK_CHECK_VERSION (3,16,0)
-	gtk_label_set_xalign(GTK_LABEL(label), GTK_ALIGN_START);
-	gtk_label_set_yalign(GTK_LABEL(label), GTK_ALIGN_START);
-#else
-	G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-	gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
-	G_GNUC_END_IGNORE_DEPRECATIONS;
-#endif
+	gtk_label_set_alignment(GTK_LABEL(label), 0, 0);
 	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
 
 	/* Connect the signals. */
@@ -10372,14 +10344,7 @@ pidgin_conv_window_add_gtkconv(PidginCon
 
 	gtk_box_pack_start(GTK_BOX(gtkconv->menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0);
 	gtk_widget_show(gtkconv->menu_label);
-#if GTK_CHECK_VERSION (3,16,0)
-	gtk_label_set_xalign(GTK_LABEL(gtkconv->menu_label), GTK_ALIGN_START);
-	gtk_label_set_yalign(GTK_LABEL(gtkconv->menu_label), GTK_ALIGN_START);
-#else
-	G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-	gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0);
-	G_GNUC_END_IGNORE_DEPRECATIONS;
-#endif
+	gtk_label_set_alignment(GTK_LABEL(gtkconv->menu_label), 0, 0);
 
 	gtk_widget_show(gtkconv->menu_tabby);
 
@@ -10441,13 +10406,7 @@ pidgin_conv_tab_pack(PidginConvWindow *w
 	gtk_label_set_angle(GTK_LABEL(gtkconv->tab_label), angle);
 
 #if 0
-#if GTK_CHECK_VERSION (3,16,0)
-	gtk_label_set_xalign(GTK_LABEL(gtkconv->tab_label), GTK_ALIGN_START);
-#else
-	G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-	gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0, 0.5);
-	G_GNUC_END_IGNORE_DEPRECATIONS;
-#endif
+	gtk_label_set_alignment(GTK_LABEL(gtkconv->tab_label), 0, 0.5);
 	gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0);
 #endif
 
diff --git a/pidgin/gtkdialogs.c b/pidgin/gtkdialogs.c
--- a/pidgin/gtkdialogs.c
+++ b/pidgin/gtkdialogs.c
@@ -1071,14 +1071,7 @@ pidgin_dialogs_ee(const char *ee)
 	gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
 
 	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
-#if GTK_CHECK_VERSION (3,16,0)
-	gtk_label_set_xalign(GTK_LABEL(label), GTK_ALIGN_START);
-	gtk_label_set_yalign(GTK_LABEL(label), GTK_ALIGN_START);
-#else
-	G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-	gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
-	G_GNUC_END_IGNORE_DEPRECATIONS;
-#endif
+	gtk_label_set_alignment(GTK_LABEL(label), 0, 0);
 	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
 
 	gtk_widget_show_all(window);
diff --git a/pidgin/gtklog.c b/pidgin/gtklog.c
--- a/pidgin/gtklog.c
+++ b/pidgin/gtklog.c
@@ -602,14 +602,7 @@ static PidginLogViewer *display_log_view
 	text = g_strdup_printf("<span size='larger' weight='bold'>%s</span>", title);
 
 	gtk_label_set_markup(lv->label, text);
-#if GTK_CHECK_VERSION (3,16,0)
-	gtk_label_set_xalign(lv->label, GTK_ALIGN_START);
-	gtk_label_set_yalign(lv->label, GTK_ALIGN_START);
-#else
-	G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-	gtk_misc_set_alignment(GTK_MISC(lv->label), 0, 0);
-	G_GNUC_END_IGNORE_DEPRECATIONS;
-#endif
+	gtk_label_set_alignment(GTK_LABEL(lv->label), 0, 0);
 	gtk_box_pack_start(GTK_BOX(title_box), GTK_WIDGET(lv->label), FALSE, FALSE, 0);
 	g_free(text);
 
@@ -651,14 +644,7 @@ static PidginLogViewer *display_log_view
 		size_label = gtk_label_new(NULL);
 		gtk_label_set_markup(GTK_LABEL(size_label), text);
 		/*		gtk_paned_add1(GTK_PANED(pane), size_label); */
-#if GTK_CHECK_VERSION (3,16,0)
-		gtk_label_set_xalign(GTK_LABEL(size_label), GTK_ALIGN_START);
-		gtk_label_set_yalign(GTK_LABEL(size_label), GTK_ALIGN_START);
-#else
-		G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-		gtk_misc_set_alignment(GTK_MISC(size_label), 0, 0);
-		G_GNUC_END_IGNORE_DEPRECATIONS;
-#endif
+		gtk_label_set_alignment(GTK_LABEL(size_label), 0, 0);
 		gtk_box_pack_end(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(lv->window))),
 		                 size_label, FALSE, FALSE, 0);
 		g_free(sz_txt);
diff --git a/pidgin/gtkmedia.c b/pidgin/gtkmedia.c
--- a/pidgin/gtkmedia.c
+++ b/pidgin/gtkmedia.c
@@ -768,24 +768,10 @@ phone_create_button(const gchar *text_hi
 
 	button = gtk_button_new();
 	label_hi = gtk_label_new(text_hi_local);
-#if GTK_CHECK_VERSION (3,16,0)
-	gtk_label_set_xalign(GTK_LABEL(label_hi), GTK_ALIGN_CENTER);
-	gtk_label_set_yalign(GTK_LABEL(label_hi), GTK_ALIGN_CENTER);
-#else
-	G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-	gtk_misc_set_alignment(GTK_MISC(label_hi), 0.5, 0.5);
-	G_GNUC_END_IGNORE_DEPRECATIONS;
-#endif
+	gtk_label_set_alignment(GTK_LABEL(label_hi), 0.5, 0.5);
 	gtk_box_pack_end(GTK_BOX(grid), label_hi, FALSE, TRUE, 0);
 	label_lo = gtk_label_new(text_lo);
-#if GTK_CHECK_VERSION (3,16,0)
-	gtk_label_set_xalign(GTK_LABEL(label_lo), GTK_ALIGN_CENTER);
-	gtk_label_set_yalign(GTK_LABEL(label_lo), GTK_ALIGN_CENTER);
-#else
-	G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-	gtk_misc_set_alignment(GTK_MISC(label_lo), 0.5, 0.5);
-	G_GNUC_END_IGNORE_DEPRECATIONS;
-#endif
+	gtk_label_set_alignment(GTK_LABEL(label_lo), 0.5, 0.5);
 	gtk_label_set_use_markup(GTK_LABEL(label_lo), TRUE);
 	gtk_box_pack_end(GTK_BOX(grid), label_lo, FALSE, TRUE, 0);
 	gtk_container_add(GTK_CONTAINER(button), grid);
diff --git a/pidgin/gtknotify.c b/pidgin/gtknotify.c
--- a/pidgin/gtknotify.c



More information about the Commits mailing list