[Xfce4-commits] <xfce4-panel:master> Adding a possibility to close the calendar popup with "Esc"

Andrzej noreply at xfce.org
Fri Jan 25 22:40:03 CET 2013


Updating branch refs/heads/master
         to a672491a6d2d12264c7e2f823cdf271b7e3acf82 (commit)
       from eb7f419731ce953836def8d36650c967cc223298 (commit)

commit a672491a6d2d12264c7e2f823cdf271b7e3acf82
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Mon Jan 21 00:12:07 2013 +0000

    Adding a possibility to close the calendar popup with "Esc"
    
    Calendar popup can be closed with an Escape key, provided it
    has a keyboard focus.

 plugins/clock/clock.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/plugins/clock/clock.c b/plugins/clock/clock.c
index aae6951..46169bf 100644
--- a/plugins/clock/clock.c
+++ b/plugins/clock/clock.c
@@ -28,6 +28,7 @@
 #include <math.h>
 #endif
 
+#include <gdk/gdkkeysyms.h>
 #include <gtk/gtk.h>
 #include <exo/exo.h>
 #include <libxfce4ui/libxfce4ui.h>
@@ -76,7 +77,10 @@ static void     clock_plugin_screen_position_changed   (XfcePanelPlugin       *p
                                                         XfceScreenPosition     position);
 static void     clock_plugin_configure_plugin          (XfcePanelPlugin       *panel_plugin);
 static void     clock_plugin_set_mode                  (ClockPlugin           *plugin);
-static void     clock_plugin_reposition_calendar       (ClockPlugin          *plugin);
+static void     clock_plugin_reposition_calendar       (ClockPlugin           *plugin);
+static gboolean clock_plugin_calendar_key_press_event  (GtkWidget             *calendar_window,
+                                                        GdkEventKey           *event,
+                                                        ClockPlugin           *plugin);
 static void     clock_plugin_popup_calendar            (ClockPlugin           *plugin);
 static void     clock_plugin_hide_calendar             (ClockPlugin           *plugin);
 static gboolean clock_plugin_tooltip                   (gpointer               user_data);
@@ -975,6 +979,22 @@ clock_plugin_calendar_show_event (GtkWidget   *calendar_window,
 
 
 
+static gboolean
+clock_plugin_calendar_key_press_event (GtkWidget      *calendar_window,
+                                       GdkEventKey    *event,
+                                       ClockPlugin    *plugin)
+{
+  if (event->type == GDK_KEY_PRESS && event->keyval == GDK_KEY_Escape)
+    {
+      clock_plugin_hide_calendar (plugin);
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
+
+
 static void
 clock_plugin_popup_calendar (ClockPlugin *plugin)
 {
@@ -1004,6 +1024,8 @@ clock_plugin_popup_calendar (ClockPlugin *plugin)
                                         | GTK_CALENDAR_SHOW_WEEK_NUMBERS);
       g_signal_connect (G_OBJECT (plugin->calendar_window), "show",
                         G_CALLBACK (clock_plugin_calendar_show_event), plugin);
+      g_signal_connect (G_OBJECT (plugin->calendar_window), "key-press-event",
+                        G_CALLBACK (clock_plugin_calendar_key_press_event), plugin);
       gtk_container_add (GTK_CONTAINER (calendar_frame), plugin->calendar);
       gtk_widget_show (plugin->calendar);
     }


More information about the Xfce4-commits mailing list