Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Mon, 16 Feb 2015 14:35:09 UTC Commit: 147c188c1c03ef38ca62c181e981935bd9650930 https://github.com/geany/geany-plugins/commit/147c188c1c03ef38ca62c181e98193...
Log Message: ----------- git-ui: Add a preference dialog
Modified Paths: -------------- build/git-ui.m4 git-ui/Makefile.am git-ui/data/Makefile.am git-ui/data/prefs.ui git-ui/src/ggu-plugin.c po/POTFILES.in
Modified: build/git-ui.m4 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -11,6 +11,7 @@ AC_DEFUN([GP_CHECK_GITUI],
AC_CONFIG_FILES([ git-ui/Makefile + git-ui/data/Makefile git-ui/src/Makefile ]) ])
Modified: git-ui/Makefile.am 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -1,4 +1,4 @@ include $(top_srcdir)/build/vars.auxfiles.mk plugin = git-ui
-SUBDIRS = src +SUBDIRS = data src
Modified: git-ui/data/Makefile.am 4 lines changed, 4 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,4 @@ +include $(top_srcdir)/build/vars.docs.mk +plugin = git-ui + +dist_plugindata_DATA = prefs.ui
Modified: git-ui/data/prefs.ui 162 lines changed, 162 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,162 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <requires lib="gtk+" version="2.16"/> + <!-- interface-naming-policy toplevel-contextual --> + <object class="GtkVBox" id="base"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkFrame" id="frame1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> + <child> + <object class="GtkAlignment" id="alignment1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="left_padding">12</property> + <child> + <object class="GtkVBox" id="box2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkHBox" id="box3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">6</property> + <child> + <object class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Added lines:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">added-color-button</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkColorButton" id="added-color-button"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkHBox" id="box4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">6</property> + <child> + <object class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Changed lines:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">changed-color-button</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkColorButton" id="changed-color-button"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkHBox" id="box5"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">6</property> + <child> + <object class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Removed lines:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">removed-color-button</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkColorButton" id="removed-color-button"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Colors</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> +</interface>
Modified: git-ui/src/ggu-plugin.c 119 lines changed, 119 insertions(+), 0 deletions(-) =================================================================== @@ -1039,3 +1039,122 @@ plugin_cleanup (void)
git_threads_shutdown (); } + +/* --- configuration dialog --- */ + +typedef struct ConfigureWidgets ConfigureWidgets; +struct ConfigureWidgets { + GtkWidget *base; + GtkWidget *added_color_button; + GtkWidget *changed_color_button; + GtkWidget *removed_color_button; +}; + +static void configure_widgets_free (ConfigureWidgets *cw) +{ + g_object_unref (cw->base); + g_free (cw); +} + +static void +color_from_int (GdkColor *color, + guint32 val) +{ + color->red = ((val & 0xff0000) >> 16) * 0x101; + color->green = ((val & 0x00ff00) >> 8) * 0x101; + color->blue = ((val & 0x0000ff) >> 0) * 0x101; +} + +static guint32 +color_to_int (const GdkColor *color) +{ + return (((color->red / 0x101) << 16) | + ((color->green / 0x101) << 8) | + ((color->blue / 0x101) << 0)); +} + +static void +on_plugin_configure_response (GtkDialog *dialog, + gint response, + ConfigureWidgets *cw) +{ + switch (response) { + case GTK_RESPONSE_APPLY: + case GTK_RESPONSE_OK: { + guint i; + GdkColor color; + GeanyDocument *doc = document_get_current (); + + gtk_color_button_get_color (GTK_COLOR_BUTTON (cw->added_color_button), + &color); + G_markers[MARKER_LINE_ADDED].color = color_to_int (&color); + gtk_color_button_get_color (GTK_COLOR_BUTTON (cw->changed_color_button), + &color); + G_markers[MARKER_LINE_CHANGED].color = color_to_int (&color); + gtk_color_button_get_color (GTK_COLOR_BUTTON (cw->removed_color_button), + &color); + G_markers[MARKER_LINE_REMOVED].color = color_to_int (&color); + + /* update everything */ + foreach_document (i) { + release_resources (documents[i]->editor->sci); + } + if (doc) { + update_diff_push (doc, FALSE); + } + } + } +} + +GtkWidget * +plugin_configure (GtkDialog *dialog) +{ + GError *error = NULL; + GtkWidget *base = NULL; + GtkBuilder *builder = gtk_builder_new (); + + gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE); + if (! gtk_builder_add_from_file (builder, PKGDATADIR"/"PLUGIN"/prefs.ui", + &error)) { + g_critical (_("Failed to load UI definition, please check your " + "installation. The error was: %s"), error->message); + g_error_free (error); + } else { + GdkColor color; + ConfigureWidgets *cw = g_malloc (sizeof *cw); + struct { + const gchar *name; + GtkWidget **ptr; + } map[] = { + { "base", &cw->base }, + { "added-color-button", &cw->added_color_button }, + { "changed-color-button", &cw->changed_color_button }, + { "removed-color-button", &cw->removed_color_button }, + }; + guint i; + + for (i = 0; i < G_N_ELEMENTS (map); i++) { + *map[i].ptr = GTK_WIDGET (gtk_builder_get_object (builder, map[i].name)); + } + + color_from_int (&color, G_markers[MARKER_LINE_ADDED].color); + gtk_color_button_set_color (GTK_COLOR_BUTTON (cw->added_color_button), + &color); + color_from_int (&color, G_markers[MARKER_LINE_CHANGED].color); + gtk_color_button_set_color (GTK_COLOR_BUTTON (cw->changed_color_button), + &color); + color_from_int (&color, G_markers[MARKER_LINE_REMOVED].color); + gtk_color_button_set_color (GTK_COLOR_BUTTON (cw->removed_color_button), + &color); + + base = g_object_ref_sink (cw->base); + + g_signal_connect_data (dialog, "response", + G_CALLBACK (on_plugin_configure_response), + cw, (GClosureNotify) configure_widgets_free, 0); + } + + g_object_unref (builder); + + return base; +}
Modified: po/POTFILES.in 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -217,6 +217,7 @@ geanyvc/src/utils.c geniuspaste/src/geniuspaste.c
# GitUI +[type: gettext/glade]git-ui/data/prefs.ui git-ui/src/ggu-plugin.c
# Markdown
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).