/pidgin/main: 2a390d401448: Replace GtkTable with GtkGrid in con...

Elliott Sales de Andrade qulogic at pidgin.im
Tue Nov 11 01:10:00 EST 2014


Changeset: 2a390d40144865841bfed50c26348c1314d5741b
Author:	 Elliott Sales de Andrade <qulogic at pidgin.im>
Date:	 2014-11-11 00:54 -0500
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/2a390d401448

Description:

Replace GtkTable with GtkGrid in conversation window.

diffstat:

 pidgin/gtk3compat.h |  53 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 pidgin/gtkconv.c    |  24 ++++++++++++------------
 2 files changed, 64 insertions(+), 13 deletions(-)

diffs (136 lines):

diff --git a/pidgin/gtk3compat.h b/pidgin/gtk3compat.h
--- a/pidgin/gtk3compat.h
+++ b/pidgin/gtk3compat.h
@@ -77,7 +77,7 @@ pidgin_color_chooser_get_rgb(GtkWidget *
 		gtk_color_button_get_color(GTK_COLOR_BUTTON(widget), color);
 }
 
-#else
+#else /* 3.4.0 */
 
 static inline void
 pidgin_color_chooser_set_rgb(GtkColorChooser *chooser, const GdkColor *rgb)
@@ -106,6 +106,57 @@ pidgin_color_chooser_get_rgb(GtkColorCho
 #endif /* 3.4.0 and gtk_color_chooser_ */
 
 
+#if GTK_CHECK_VERSION(3,0,0)
+
+static inline GtkWidget *
+gtk_grid_table_new(guint rows, guint columns)
+{
+	return gtk_grid_new();
+}
+
+static inline void
+gtk_grid_attach_defaults(GtkGrid *grid, GtkWidget *child, gint left, gint top,
+	gint width, gint height)
+{
+	gtk_grid_attach(grid, child, left, top, width, height);
+	gtk_widget_set_hexpand(child, TRUE);
+	gtk_widget_set_vexpand(child, TRUE);
+}
+
+#else /* 3.0.0 and gtk_grid_ */
+
+#define GTK_GRID GTK_TABLE
+#define GtkGrid GtkTable
+
+static inline GtkWidget *
+gtk_grid_table_new(guint rows, guint columns)
+{
+	return gtk_table_new(rows, columns, FALSE);
+}
+
+static inline void
+gtk_grid_set_row_spacing(GtkGrid *grid, guint spacing)
+{
+	gtk_table_set_row_spacings(grid, spacing);
+}
+
+static inline void
+gtk_grid_set_column_spacing(GtkGrid *grid, guint spacing)
+{
+	gtk_table_set_col_spacings(grid, spacing);
+}
+
+static inline void
+gtk_grid_attach_defaults(GtkGrid *grid, GtkWidget *child, gint left, gint top,
+	gint width, gint height)
+{
+	gtk_table_attach_defaults(grid, child, left, left + width,
+		top, top + height);
+}
+
+#endif /* 3.0.0 and gtk_grid_ */
+
+
 #if !GTK_CHECK_VERSION(3,2,0)
 
 #define GTK_FONT_CHOOSER GTK_FONT_SELECTION_DIALOG
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -919,7 +919,7 @@ invite_cb(GtkWidget *widget, PidginConve
 		PidginConvWindow *gtkwin;
 		GtkWidget *label;
 		GtkWidget *vbox, *hbox;
-		GtkWidget *table;
+		GtkWidget *grid;
 		GtkWidget *img;
 
 		img = gtk_image_new_from_stock(PIDGIN_STOCK_DIALOG_QUESTION,
@@ -969,42 +969,42 @@ invite_cb(GtkWidget *widget, PidginConve
 		gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
 		gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
 
-		/* hbox for the table, and to give it some spacing on the left. */
+		/* hbox for the grid, and to give it some spacing on the left. */
 		hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, PIDGIN_HIG_BOX_SPACE);
 		gtk_container_add(GTK_CONTAINER(vbox), hbox);
 
-		/* Setup the table we're going to use to lay stuff out. */
-		table = gtk_table_new(2, 2, FALSE);
-		gtk_table_set_row_spacings(GTK_TABLE(table), PIDGIN_HIG_BOX_SPACE);
-		gtk_table_set_col_spacings(GTK_TABLE(table), PIDGIN_HIG_BOX_SPACE);
-		gtk_container_set_border_width(GTK_CONTAINER(table), PIDGIN_HIG_BORDER);
-		gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
+		/* Setup the grid we're going to use to lay stuff out. */
+		grid = gtk_grid_table_new(2, 2);
+		gtk_grid_set_row_spacing(GTK_GRID(grid), PIDGIN_HIG_BOX_SPACE);
+		gtk_grid_set_column_spacing(GTK_GRID(grid), PIDGIN_HIG_BOX_SPACE);
+		gtk_container_set_border_width(GTK_CONTAINER(grid), PIDGIN_HIG_BORDER);
+		gtk_box_pack_start(GTK_BOX(vbox), grid, FALSE, FALSE, 0);
 
 		/* Now the Buddy label */
 		label = gtk_label_new(NULL);
 		gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:"));
 		gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
-		gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
+		gtk_grid_attach_defaults(GTK_GRID(grid), label, 0, 0, 1, 1);
 
 		/* Now the Buddy drop-down entry field. */
 		info->entry = gtk_entry_new();
 		pidgin_setup_screenname_autocomplete(info->entry, NULL, chat_invite_filter,
 				purple_conversation_get_account(PURPLE_CONVERSATION(chat)));
-		gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1);
+		gtk_grid_attach_defaults(GTK_GRID(grid), info->entry, 1, 0, 1, 1);
 		gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry);
 
 		/* Now the label for "Message" */
 		label = gtk_label_new(NULL);
 		gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:"));
 		gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
-		gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
+		gtk_grid_attach_defaults(GTK_GRID(grid), label, 0, 1, 1, 1);
 
 
 		/* And finally, the Message entry field. */
 		info->message = gtk_entry_new();
 		gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE);
 
-		gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2);
+		gtk_grid_attach_defaults(GTK_GRID(grid), info->message, 1, 1, 1, 1);
 		gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message);
 
 		/* Connect the signals. */



More information about the Commits mailing list