Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Fri, 07 Mar 2014 21:12:04 UTC Commit: 9ae07905620e78da3550945f47d01f2c7ea14edb https://github.com/geany/geany/commit/9ae07905620e78da3550945f47d01f2c7ea14e...
Log Message: ----------- Merge branch 'bestel74/add_apply_button_color_chooser'
Closes PR #223.
Modified Paths: -------------- src/tools.c src/ui_utils.c src/ui_utils.h
Modified: src/tools.c 7 files changed, 6 insertions(+), 1 deletions(-) =================================================================== @@ -952,13 +952,15 @@ static void on_color_dialog_response(GtkDialog *dialog, gint response, gpointer switch (response) { case GTK_RESPONSE_OK: + gtk_widget_hide(ui_widgets.open_colorsel); + /* fall through */ + case GTK_RESPONSE_APPLY: { GdkColor color; GeanyDocument *doc = document_get_current(); gchar *hex; GtkWidget *colorsel;
- gtk_widget_hide(ui_widgets.open_colorsel); g_return_if_fail(doc != NULL);
colorsel = gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(ui_widgets.open_colorsel)); @@ -989,6 +991,9 @@ void tools_color_chooser(const gchar *color) if (ui_widgets.open_colorsel == NULL) { 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).