[Xfce4-commits] [apps/mousepad] 03/03: Add Enter and Shift+Enter support to search bar entry

noreply at xfce.org noreply at xfce.org
Sat Jul 12 04:26:04 CEST 2014


This is an automated email from the git hooks/post-receive script.

mbrush pushed a commit to branch master
in repository apps/mousepad.

commit 6715fa8f91a38e51fa59202ec072b3ab9058f268
Author: Matthew Brush <mbrush at codebrainz.ca>
Date:   Fri Jul 11 19:13:50 2014 -0700

    Add Enter and Shift+Enter support to search bar entry
    
    Closes #10438 (https://bugzilla.xfce.org/show_bug.cgi?id=10438)
    To search forwards and backwards using those shortcuts.
---
 mousepad/mousepad-search-bar.c |   41 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/mousepad/mousepad-search-bar.c b/mousepad/mousepad-search-bar.c
index 75d8851..1f86fc2 100644
--- a/mousepad/mousepad-search-bar.c
+++ b/mousepad/mousepad-search-bar.c
@@ -40,6 +40,10 @@ static void      mousepad_search_bar_finalize                   (GObject
 static void      mousepad_search_bar_find_string                (MousepadSearchBar       *bar,
                                                                  MousepadSearchFlags   flags);
 static void      mousepad_search_bar_hide_clicked               (MousepadSearchBar       *bar);
+static void      mousepad_search_bar_entry_activate             (GtkWidget               *entry,
+                                                                 MousepadSearchBar       *bar);
+static void      mousepad_search_bar_entry_activate_backward    (GtkWidget               *entry,
+                                                                 MousepadSearchBar       *bar);
 static void      mousepad_search_bar_entry_changed              (GtkWidget               *entry,
                                                                  MousepadSearchBar       *bar);
 static void      mousepad_search_bar_highlight_toggled          (GtkWidget               *button,
@@ -107,6 +111,7 @@ static void
 mousepad_search_bar_class_init (MousepadSearchBarClass *klass)
 {
   GObjectClass  *gobject_class;
+  GObjectClass  *entry_class;
   GtkBindingSet *binding_set;
 
   gobject_class = G_OBJECT_CLASS (klass);
@@ -148,6 +153,22 @@ mousepad_search_bar_class_init (MousepadSearchBarClass *klass)
                            "GtkToolButton::icon-spacing = 2\n"
                          "}\n"
                        "widget \"MousepadWindow.*.Gtk*ToolButton\" style \"mousepad-button-style\"\n");
+
+  /* add an activate-backwards signal to GtkEntry */
+  entry_class = g_type_class_ref (GTK_TYPE_ENTRY);
+  if (G_LIKELY (g_signal_lookup("activate-backward", GTK_TYPE_ENTRY) == 0))
+    {
+      /* install the signal */
+      g_signal_new("activate-backward",
+                   GTK_TYPE_ENTRY,
+                   G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                   0, NULL, NULL,
+                   g_cclosure_marshal_VOID__VOID,
+                   G_TYPE_NONE, 0);
+      binding_set = gtk_binding_set_by_class(entry_class);
+      gtk_binding_entry_add_signal(binding_set, GDK_Return, GDK_SHIFT_MASK, "activate-backward", 0);
+    }
+  g_type_class_unref (entry_class);
 }
 
 
@@ -191,6 +212,8 @@ mousepad_search_bar_init (MousepadSearchBar *bar)
   gtk_container_add (GTK_CONTAINER (item), bar->entry);
   gtk_label_set_mnemonic_widget (GTK_LABEL (label), bar->entry);
   g_signal_connect (G_OBJECT (bar->entry), "changed", G_CALLBACK (mousepad_search_bar_entry_changed), bar);
+  g_signal_connect (G_OBJECT (bar->entry), "activate", G_CALLBACK (mousepad_search_bar_entry_activate), bar);
+  g_signal_connect (G_OBJECT (bar->entry), "activate-backward", G_CALLBACK (mousepad_search_bar_entry_activate_backward), bar);
   gtk_widget_show (bar->entry);
 
   /* next button */
@@ -318,6 +341,24 @@ mousepad_search_bar_hide_clicked (MousepadSearchBar *bar)
 
 
 static void
+mousepad_search_bar_entry_activate (GtkWidget         *entry,
+                                    MousepadSearchBar *bar)
+{
+  mousepad_search_bar_find_next (bar);
+}
+
+
+
+static void
+mousepad_search_bar_entry_activate_backward (GtkWidget         *entry,
+                                             MousepadSearchBar *bar)
+{
+  mousepad_search_bar_find_previous (bar);
+}
+
+
+
+static void
 mousepad_search_bar_entry_changed (GtkWidget         *entry,
                                    MousepadSearchBar *bar)
 {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list