/soc/2013/ankitkv/gobjectification: e5530c2b896e: Merged default...

Ankit Vani a at nevitus.org
Thu Sep 12 10:26:02 EDT 2013


Changeset: e5530c2b896e32ae85a3a701ce8a02ebce2bf603
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-12 19:50 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/e5530c2b896e

Description:

Merged default branch

diffstat:

 libpurple/request.c |  17 +++++++++++++
 libpurple/request.h |  26 ++++++++++++++++++++
 pidgin/gtkrequest.c |  67 ++++++++++++++++++++++++++++++++++++----------------
 3 files changed, 89 insertions(+), 21 deletions(-)

diffs (223 lines):

diff --git a/libpurple/request.c b/libpurple/request.c
--- a/libpurple/request.c
+++ b/libpurple/request.c
@@ -166,6 +166,7 @@ struct _PurpleRequestCommonParameters
 	gconstpointer icon_data;
 	gsize icon_size;
 	gboolean html;
+	gboolean compact;
 };
 
 PurpleRequestCommonParameters *
@@ -331,6 +332,22 @@ purple_request_cpar_is_html(PurpleReques
 	return cpar->html;
 }
 
+void
+purple_request_cpar_set_compact(PurpleRequestCommonParameters *cpar,
+	gboolean compact)
+{
+	cpar->compact = compact;
+}
+
+gboolean
+purple_request_cpar_is_compact(PurpleRequestCommonParameters *cpar)
+{
+	if (cpar == NULL)
+		return FALSE;
+
+	return cpar->compact;
+}
+
 PurpleRequestFields *
 purple_request_fields_new(void)
 {
diff --git a/libpurple/request.h b/libpurple/request.h
--- a/libpurple/request.h
+++ b/libpurple/request.h
@@ -336,6 +336,26 @@ purple_request_cpar_set_html(PurpleReque
 gboolean
 purple_request_cpar_is_html(PurpleRequestCommonParameters *cpar);
 
+/**
+ * Sets dialog display mode to compact or default.
+ *
+ * @param cpar    The parameters set.
+ * @param compact TRUE for compact, FALSE otherwise.
+ */
+void
+purple_request_cpar_set_compact(PurpleRequestCommonParameters *cpar,
+	gboolean compact);
+
+/**
+ * Gets dialog display mode.
+ *
+ * @param cpar The parameters set (may be @c NULL).
+ *
+ * @return TRUE for compact, FALSE for default.
+ */
+gboolean
+purple_request_cpar_is_compact(PurpleRequestCommonParameters *cpar);
+
 /*@}*/
 
 /**************************************************************************/
@@ -1133,6 +1153,12 @@ purple_request_field_choice_get_value(co
 GList *
 purple_request_field_choice_get_elements(const PurpleRequestField *field);
 
+/**
+ * Sets the destructor for field values.
+ *
+ * @param field   The field.
+ * @param destroy The destroy function.
+ */
 void
 purple_request_field_choice_set_data_destructor(PurpleRequestField *field,
 	GDestroyNotify destroy);
diff --git a/pidgin/gtkrequest.c b/pidgin/gtkrequest.c
--- a/pidgin/gtkrequest.c
+++ b/pidgin/gtkrequest.c
@@ -303,27 +303,35 @@ destroy_multifield_cb(GtkWidget *dialog,
 
 
 #define STOCK_ITEMIZE(r, l) \
-	if (!strcmp((r), text)) \
+	if (!strcmp((r), text) || !strcmp(_(r), text)) \
 		return (l);
 
 static const char *
 text_to_stock(const char *text)
 {
-	STOCK_ITEMIZE(_("Yes"),     GTK_STOCK_YES);
-	STOCK_ITEMIZE(_("No"),      GTK_STOCK_NO);
-	STOCK_ITEMIZE(_("OK"),      GTK_STOCK_OK);
-	STOCK_ITEMIZE(_("Cancel"),  GTK_STOCK_CANCEL);
-	STOCK_ITEMIZE(_("Apply"),   GTK_STOCK_APPLY);
-	STOCK_ITEMIZE(_("Close"),   GTK_STOCK_CLOSE);
-	STOCK_ITEMIZE(_("Delete"),  GTK_STOCK_DELETE);
-	STOCK_ITEMIZE(_("Add"),     GTK_STOCK_ADD);
-	STOCK_ITEMIZE(_("Remove"),  GTK_STOCK_REMOVE);
-	STOCK_ITEMIZE(_("Save"),    GTK_STOCK_SAVE);
-	STOCK_ITEMIZE(_("Alias"),   PIDGIN_STOCK_ALIAS);
+	STOCK_ITEMIZE(N_("Yes"),     GTK_STOCK_YES);
+	STOCK_ITEMIZE(N_("_Yes"),    GTK_STOCK_YES);
+	STOCK_ITEMIZE(N_("No"),      GTK_STOCK_NO);
+	STOCK_ITEMIZE(N_("_No"),     GTK_STOCK_NO);
+	STOCK_ITEMIZE(N_("OK"),      GTK_STOCK_OK);
+	STOCK_ITEMIZE(N_("_OK"),     GTK_STOCK_OK);
+	STOCK_ITEMIZE(N_("Cancel"),  GTK_STOCK_CANCEL);
+	STOCK_ITEMIZE(N_("_Cancel"), GTK_STOCK_CANCEL);
+	STOCK_ITEMIZE(N_("Apply"),   GTK_STOCK_APPLY);
+	STOCK_ITEMIZE(N_("Close"),   GTK_STOCK_CLOSE);
+	STOCK_ITEMIZE(N_("Delete"),  GTK_STOCK_DELETE);
+	STOCK_ITEMIZE(N_("Add"),     GTK_STOCK_ADD);
+	STOCK_ITEMIZE(N_("Remove"),  GTK_STOCK_REMOVE);
+	STOCK_ITEMIZE(N_("Save"),    GTK_STOCK_SAVE);
+	STOCK_ITEMIZE(N_("Next"),    GTK_STOCK_GO_FORWARD);
+	STOCK_ITEMIZE(N_("Back"),    GTK_STOCK_GO_BACK);
+	STOCK_ITEMIZE(N_("Alias"),   PIDGIN_STOCK_ALIAS);
 
 	return text;
 }
 
+#undef STOCK_ITEMIZE
+
 static gchar *
 pidgin_request_escape(PurpleRequestCommonParameters *cpar, const gchar *text)
 {
@@ -1019,7 +1027,8 @@ create_bool_field(PurpleRequestField *fi
 }
 
 static GtkWidget *
-create_choice_field(PurpleRequestField *field)
+create_choice_field(PurpleRequestField *field,
+	PurpleRequestCommonParameters *cpar)
 {
 	GtkWidget *widget;
 	GList *elements = purple_request_field_choice_get_elements(field);
@@ -1027,11 +1036,12 @@ create_choice_field(PurpleRequestField *
 	GList *l;
 	gpointer *values = g_new(gpointer, num_labels);
 	gpointer default_value;
-	int i, default_index = -1;
+	int i;
 
 	default_value = purple_request_field_choice_get_default_value(field);
-	if (num_labels > 5)
+	if (num_labels > 5 || purple_request_cpar_is_compact(cpar))
 	{
+		int default_index = 0;
 		widget = gtk_combo_box_text_new();
 
 		i = 0;
@@ -1335,6 +1345,7 @@ pidgin_request_fields(const char *title,
 	char *label_text;
 	char *primary_esc, *secondary_esc;
 	int total_fields = 0;
+	const gboolean compact = purple_request_cpar_is_compact(cpar);
 
 	data            = g_new0(PidginRequestData, 1);
 	data->type      = PURPLE_REQUEST_FIELDS;
@@ -1501,7 +1512,8 @@ pidgin_request_fields(const char *title,
 					rows++;
 
 				rows += 2;
-			}
+			} else if (compact && type != PURPLE_REQUEST_FIELD_BOOLEAN)
+				rows++;
 
 			col_num++;
 
@@ -1509,7 +1521,10 @@ pidgin_request_fields(const char *title,
 				col_num = 0;
 		}
 
-		table = gtk_table_new(rows, 2 * cols, FALSE);
+		if (compact)
+			table = gtk_table_new(rows, cols, FALSE);
+		else
+			table = gtk_table_new(rows, 2 * cols, 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);
 
@@ -1544,8 +1559,11 @@ pidgin_request_fields(const char *title,
 				{
 					char *text = NULL;
 
-					if (field_label[strlen(field_label) - 1] != ':')
+					if (field_label[strlen(field_label) - 1] != ':' &&
+						field_label[strlen(field_label) - 1] != '?')
+					{
 						text = g_strdup_printf("%s:", field_label);
+					}
 
 					label = gtk_label_new(NULL);
 					gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), text ? text : field_label);
@@ -1590,7 +1608,7 @@ pidgin_request_fields(const char *title,
 					else if (type == PURPLE_REQUEST_FIELD_BOOLEAN)
 						widget = create_bool_field(field);
 					else if (type == PURPLE_REQUEST_FIELD_CHOICE)
-						widget = create_choice_field(field);
+						widget = create_choice_field(field, cpar);
 					else if (type == PURPLE_REQUEST_FIELD_LIST)
 						widget = create_list_field(field);
 					else if (type == PURPLE_REQUEST_FIELD_IMAGE)
@@ -1634,8 +1652,15 @@ pidgin_request_fields(const char *title,
 									 GTK_FILL | GTK_EXPAND,
 									 5, 0);
 				}
-				else
-				{
+				else if (compact) {
+					row_num++;
+					gtk_table_attach(GTK_TABLE(table), widget,
+									 0, 2 * cols,
+									 row_num, row_num + 1,
+									 GTK_FILL | GTK_EXPAND,
+									 GTK_FILL | GTK_EXPAND,
+									 5, 0);
+				} else {
 					gtk_table_attach(GTK_TABLE(table), widget,
 							 		 1, 2 * cols,
 									 row_num, row_num + 1,



More information about the Commits mailing list