/pidgin/main: 2a4179d0177d: Replace GtkTable with GtkGrid in Pre...

Elliott Sales de Andrade <[email protected]>
Newsgroups gmane.comp.gnome.gaim.cvs
Message-ID <[email protected]>
Changeset: 2a4179d0177ddfe999e3f6bf0e77e22e9a940b0e
Author:	 Elliott Sales de Andrade <[email protected]>
Date:	 2014-11-10 23:54 -0500
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/2a4179d0177d

Description:

Replace GtkTable with GtkGrid in Preferences window.

diffstat:

 pidgin/gtk3compat.h |  31 +++++++++++++++++++++++++++++++
 pidgin/gtkprefs.c   |  40 ++++++++++++++++++++++------------------
 2 files changed, 53 insertions(+), 18 deletions(-)

diffs (141 lines):

diff --git a/pidgin/gtk3compat.h b/pidgin/gtk3compat.h
--- a/pidgin/gtk3compat.h
+++ b/pidgin/gtk3compat.h
@@ -123,6 +123,28 @@ gtk_grid_attach_defaults(GtkGrid *grid, 
 	gtk_widget_set_vexpand(child, TRUE);
 }
 
+static inline void
+gtk_grid_attach_full(GtkGrid *grid, GtkWidget *child, guint left, guint top,
+	guint width, guint height, GtkAttachOptions xoptions,
+	GtkAttachOptions yoptions, guint xpadding, guint ypadding)
+{
+	gtk_grid_attach(grid, child, left, top, width, height);
+
+	if (xoptions & GTK_EXPAND)
+		gtk_widget_set_hexpand(child, TRUE);
+	if (!(xoptions & GTK_FILL))
+		gtk_widget_set_halign(child, GTK_ALIGN_CENTER);
+	gtk_widget_set_margin_left(child, xpadding);
+	gtk_widget_set_margin_right(child, xpadding);
+
+	if (yoptions & GTK_EXPAND)
+		gtk_widget_set_vexpand(child, TRUE);
+	if (!(yoptions & GTK_FILL))
+		gtk_widget_set_valign(child, GTK_ALIGN_CENTER);
+	gtk_widget_set_margin_top(child, ypadding);
+	gtk_widget_set_margin_bottom(child, ypadding);
+}
+
 #else /* 3.0.0 and gtk_grid_ */
 
 #define GTK_GRID GTK_TABLE
@@ -154,6 +176,15 @@ gtk_grid_attach_defaults(GtkGrid *grid, 
 		top, top + height);
 }
 
+static inline void
+gtk_grid_attach_full(GtkGrid *grid, GtkWidget *child, guint left, guint top,
+	guint width, guint height, GtkAttachOptions xoptions,
+	GtkAttachOptions yoptions, guint xpadding, guint ypadding)
+{
+	gtk_table_attach(grid, child, left, left + width, top, top + height,
+		xoptions, yoptions, xpadding, ypadding);
+}
+
 #endif /* 3.0.0 and gtk_grid_ */
 
 
diff --git a/pidgin/gtkprefs.c b/pidgin/gtkprefs.c
--- a/pidgin/gtkprefs.c
+++ b/pidgin/gtkprefs.c
@@ -2483,7 +2483,7 @@ static GtkWidget *
 proxy_page(void)
 {
 	GtkWidget *ret = NULL, *vbox = NULL, *hbox = NULL;
-	GtkWidget *table = NULL, *entry = NULL, *proxy_button = NULL;
+	GtkWidget *grid = NULL, *entry = NULL, *proxy_button = NULL;
 	GtkLabel *label = NULL;
 	GtkWidget *prefs_proxy_frame = NULL;
 	PurpleProxyInfo *proxy_info;
@@ -2559,20 +2559,21 @@ proxy_page(void)
 		purple_prefs_connect_callback(prefs, "/purple/proxy/type",
 					    proxy_changed_cb, prefs_proxy_subframe);
 
-		table = gtk_table_new(4, 2, FALSE);
-		gtk_container_set_border_width(GTK_CONTAINER(table), 0);
-		gtk_table_set_col_spacings(GTK_TABLE(table), 5);
-		gtk_table_set_row_spacings(GTK_TABLE(table), 10);
-		gtk_container_add(GTK_CONTAINER(prefs_proxy_subframe), table);
+		grid = gtk_grid_table_new(4, 2);
+		gtk_container_set_border_width(GTK_CONTAINER(grid), 0);
+		gtk_grid_set_column_spacing(GTK_GRID(grid), 5);
+		gtk_grid_set_row_spacing(GTK_GRID(grid), 10);
+		gtk_container_add(GTK_CONTAINER(prefs_proxy_subframe), grid);
 
 		label = GTK_LABEL(gtk_label_new_with_mnemonic(_("_Host:")));
 		gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
-		gtk_table_attach(GTK_TABLE(table), GTK_WIDGET(label),
-			0, 1, 0, 1, GTK_FILL, 0, 0, 0);
+		gtk_grid_attach_full(GTK_GRID(grid), GTK_WIDGET(label), 0, 0, 1, 1,
+			GTK_FILL, 0, 0, 0);
 
 		entry = gtk_entry_new();
 		gtk_label_set_mnemonic_widget(label, entry);
-		gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 0, 1, GTK_FILL, 0, 0, 0);
+		gtk_grid_attach_full(GTK_GRID(grid), entry, 1, 0, 1, 1,
+			GTK_FILL, 0, 0, 0);
 		g_signal_connect(G_OBJECT(entry), "changed",
 				 G_CALLBACK(proxy_print_option), (void *)PROXYHOST);
 
@@ -2587,12 +2588,13 @@ proxy_page(void)
 
 		label = GTK_LABEL(gtk_label_new_with_mnemonic(_("P_ort:")));
 		gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
-		gtk_table_attach(GTK_TABLE(table), GTK_WIDGET(label),
-			2, 3, 0, 1, GTK_FILL, 0, 0, 0);
+		gtk_grid_attach_full(GTK_GRID(grid), GTK_WIDGET(label), 2, 0, 1, 1,
+			GTK_FILL, 0, 0, 0);
 
 		entry = gtk_spin_button_new_with_range(0, 65535, 1);
 		gtk_label_set_mnemonic_widget(label, entry);
-		gtk_table_attach(GTK_TABLE(table), entry, 3, 4, 0, 1, GTK_FILL, 0, 0, 0);
+		gtk_grid_attach_full(GTK_GRID(grid), entry, 3, 0, 1, 1,
+			GTK_FILL, 0, 0, 0);
 		g_signal_connect(G_OBJECT(entry), "changed",
 				 G_CALLBACK(proxy_print_option), (void *)PROXYPORT);
 
@@ -2604,12 +2606,13 @@ proxy_page(void)
 
 		label = GTK_LABEL(gtk_label_new_with_mnemonic(_("User_name:")));
 		gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
-		gtk_table_attach(GTK_TABLE(table), GTK_WIDGET(label),
-			0, 1, 1, 2, GTK_FILL, 0, 0, 0);
+		gtk_grid_attach_full(GTK_GRID(grid), GTK_WIDGET(label), 0, 1, 1, 1,
+			GTK_FILL, 0, 0, 0);
 
 		entry = gtk_entry_new();
 		gtk_label_set_mnemonic_widget(label, entry);
-		gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
+		gtk_grid_attach_full(GTK_GRID(grid), entry, 1, 1, 1, 1,
+			GTK_FILL, 0, 0, 0);
 		g_signal_connect(G_OBJECT(entry), "changed",
 				 G_CALLBACK(proxy_print_option), (void *)PROXYUSER);
 
@@ -2624,12 +2627,13 @@ proxy_page(void)
 
 		label = GTK_LABEL(gtk_label_new_with_mnemonic(_("Pa_ssword:")));
 		gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
-		gtk_table_attach(GTK_TABLE(table), GTK_WIDGET(label),
-			2, 3, 1, 2, GTK_FILL, 0, 0, 0);
+		gtk_grid_attach_full(GTK_GRID(grid), GTK_WIDGET(label), 2, 1, 1, 1,
+			GTK_FILL, 0, 0, 0);
 
 		entry = gtk_entry_new();
 		gtk_label_set_mnemonic_widget(label, entry);
-		gtk_table_attach(GTK_TABLE(table), entry, 3, 4, 1, 2, GTK_FILL , 0, 0, 0);
+		gtk_grid_attach_full(GTK_GRID(grid), entry, 3, 1, 1, 1,
+			GTK_FILL, 0, 0, 0);
 		gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
 		g_signal_connect(G_OBJECT(entry), "changed",
 				 G_CALLBACK(proxy_print_option), (void *)PROXYPASS);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.