[gnome-calendar] window: simplified key handler code
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] window: simplified key handler code
- Date: Thu, 4 Dec 2014 22:44:31 +0000 (UTC)
commit c0a16ac06aca4f25092dda306cb23a2c0d4f4216
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Mon Nov 24 15:46:15 2014 -0200
window: simplified key handler code
Instead of treating every case, use the builtin gtk_search_bar_handle_event function.
src/gcal-window.c | 46 +++++++---------------------------------------
1 files changed, 7 insertions(+), 39 deletions(-)
---
diff --git a/src/gcal-window.c b/src/gcal-window.c
index 8848a49..989f2eb 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -105,7 +105,7 @@ enum
#define SAVE_GEOMETRY_ID_TIMEOUT 100 /* ms */
static gboolean key_pressed (GtkWidget *widget,
- GdkEventKey *event,
+ GdkEvent *event,
gpointer user_data);
static void date_updated (GtkButton *buttton,
@@ -206,52 +206,20 @@ static void gcal_window_undo_remove_event (GtkButton *b
G_DEFINE_TYPE_WITH_PRIVATE (GcalWindow, gcal_window, GTK_TYPE_APPLICATION_WINDOW)
static gboolean
-key_pressed (GtkWidget *widget,
- GdkEventKey *event,
- gpointer user_data)
+key_pressed (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
{
GcalWindowPrivate *priv;
- GdkModifierType modifiers;
priv = gcal_window_get_instance_private (GCAL_WINDOW (user_data));
- modifiers = gtk_accelerator_get_default_mod_mask ();
- /* case 1:close leave new event mode */
- if (priv->new_event_mode &&
- event->keyval == GDK_KEY_Escape)
- {
- set_new_event_mode (GCAL_WINDOW (user_data), FALSE);
- return TRUE;
- }
-
- /* case 2: write in new-event-widget entry */
+ /* special case: write in new-event-widget entry */
if (priv->new_event_mode)
return FALSE;
- /* case 3: leave search-mode*/
- if (priv->search_mode && event->keyval == GDK_KEY_Escape)
- {
- gcal_window_set_search_mode (GCAL_WINDOW (widget), FALSE);
- return TRUE;
- }
-
- /* case 4: write into search-mode entry */
- if (priv->search_mode)
- return FALSE;
-
- /* case 5: open search-mode */
- if (!priv->search_mode &&
- gdk_keyval_to_unicode (event->keyval) != 0 &&
- ((event->state & modifiers & GDK_META_MASK) == 0) &&
- ((event->state & modifiers & GDK_SUPER_MASK) == 0) &&
- ((event->state & modifiers & GDK_HYPER_MASK) == 0) &&
- ((event->state & modifiers & GDK_CONTROL_MASK) == 0))
- {
- gcal_window_set_search_mode (GCAL_WINDOW (widget), TRUE);
- return FALSE;
- }
-
- return FALSE;
+ return gtk_search_bar_handle_event (GTK_SEARCH_BAR (priv->search_bar),
+ event);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]