[geany/geany] 77b828: Fix color chooser button order

Colomban Wendling git-noreply at xxxxx
Fri Mar 7 21:09:40 UTC 2014


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Fri, 07 Mar 2014 21:09:40 UTC
Commit:      77b82845edcc796380cddc26cc4064329f0817cd
             https://github.com/geany/geany/commit/77b82845edcc796380cddc26cc4064329f0817cd

Log Message:
-----------
Fix color chooser button order


Modified Paths:
--------------
    src/tools.c
    src/ui_utils.c
    src/ui_utils.h

Modified: src/tools.c
2 files changed, 2 insertions(+), 0 deletions(-)
===================================================================
@@ -992,6 +992,8 @@ void tools_color_chooser(const gchar *color)
 	{
 		ui_widgets.open_colorsel = gtk_color_selection_dialog_new(_("Color Chooser"));
 		gtk_dialog_add_button(GTK_DIALOG(ui_widgets.open_colorsel), GTK_STOCK_APPLY, GTK_RESPONSE_APPLY);
+		ui_dialog_set_primary_button_order(GTK_DIALOG(ui_widgets.open_colorsel),
+				GTK_RESPONSE_APPLY, GTK_RESPONSE_CANCEL, GTK_RESPONSE_OK, -1);
 		gtk_widget_set_name(ui_widgets.open_colorsel, "GeanyDialog");
 		gtk_window_set_transient_for(GTK_WINDOW(ui_widgets.open_colorsel), GTK_WINDOW(main_widgets.window));
 		colorsel = gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(ui_widgets.open_colorsel));


Modified: src/ui_utils.c
35 files changed, 35 insertions(+), 0 deletions(-)
===================================================================
@@ -1346,6 +1346,41 @@ GtkWidget *ui_dialog_vbox_new(GtkDialog *dialog)
 }
 
 
+/* Reorders a dialog's buttons
+ * @param dialog A dialog
+ * @param response First response ID to reorder
+ * @param ... more response IDs, terminated by -1
+ *
+ * Like gtk_dialog_set_alternative_button_order(), but reorders the default
+ * buttons layout, not the alternative one.  This is useful if you e.g. added a
+ * button to a dialog which already had some and need yours not to be on the
+ * end.
+ */
+/* Heavily based on gtk_dialog_set_alternative_button_order().
+ * This relies on the action area to be a GtkBox, but although not documented
+ * the API expose it to be a GtkHButtonBox though GtkBuilder, so it should be
+ * fine */
+void ui_dialog_set_primary_button_order(GtkDialog *dialog, gint response, ...)
+{
+	va_list ap;
+	GtkWidget *action_area = gtk_dialog_get_action_area(dialog);
+	gint position;
+
+	va_start(ap, response);
+	for (position = 0; response != -1; position++)
+	{
+		GtkWidget *child = gtk_dialog_get_widget_for_response(dialog, response);
+		if (child)
+			gtk_box_reorder_child(GTK_BOX(action_area), child, position);
+		else
+			g_warning("%s: no child button with response id %d.", G_STRFUNC, response);
+
+		response = va_arg(ap, gint);
+	}
+	va_end(ap);
+}
+
+
 /** Creates a @c GtkButton with custom text and a stock image similar to
  * @c gtk_button_new_from_stock().
  * @param stock_id A @c GTK_STOCK_NAME string.


Modified: src/ui_utils.h
3 files changed, 3 insertions(+), 0 deletions(-)
===================================================================
@@ -22,6 +22,7 @@
 #ifndef GEANY_UI_UTILS_H
 #define GEANY_UI_UTILS_H 1
 
+#include <stdarg.h>
 #include "gtkcompat.h"
 
 G_BEGIN_DECLS
@@ -185,6 +186,8 @@
 
 GtkWidget *ui_dialog_vbox_new(GtkDialog *dialog);
 
+void ui_dialog_set_primary_button_order(GtkDialog *dialog, gint response, ...);
+
 GtkWidget *ui_button_new_with_image(const gchar *stock_id, const gchar *text);
 
 GtkWidget *ui_image_menu_item_new(const gchar *stock_id, const gchar *label);



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list