[nautilus-actions] Edit action when Enter key pressed
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Subject: [nautilus-actions] Edit action when Enter key pressed
- Date: Tue, 14 Jul 2009 18:49:26 +0000 (UTC)
commit ca54e1d6ec7bf5d10f5108162869936d252aab37
Author: Pierre Wieser <pwieser trychlos org>
Date: Thu Jul 2 21:29:30 2009 +0200
Edit action when Enter key pressed
ChangeLog | 4 ++-
src/nact/nact-iactions-list.c | 36 +++++++++++++++++++++++++++++++++++
src/nact/nact-iactions-list.h | 2 +
src/nact/nact-main-window.c | 9 ++++++++
src/nact/nautilus-actions-config.ui | 2 +-
5 files changed, 51 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9bf62b4..d4cea74 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,7 +16,8 @@
* src/nact/nact-iactions-list.h
(nact_iactions_list_set_selection,
nact_iactions_list_set_send_selection_changed_on_fill_list,
- nact_iactions_list_set_is_filling_list)): New functions.
+ nact_iactions_list_set_is_filling_list,
+ on_key_press_event, on_enter_key_pressed): New functions.
* src/nact/nact-imenu-item.c:
* src/nact/nact-imenu-item.h (nact_imenu_item_size_labels,
@@ -35,6 +36,7 @@
* src/nact/nact-main-window.c:
Do not trigger on_selection_changed when filling the Actions list.
+ Edit action when Enter key pressed.
* src/nact/nact-window.c:
* src/nact/nact-window.h (set_current_action):
diff --git a/src/nact/nact-iactions-list.c b/src/nact/nact-iactions-list.c
index 06bd22f..f89ba22 100644
--- a/src/nact/nact-iactions-list.c
+++ b/src/nact/nact-iactions-list.c
@@ -32,6 +32,8 @@
#include <config.h>
#endif
+#include <gdk/gdkkeysyms.h>
+
#include <common/na-action.h>
#include <common/na-pivot.h>
@@ -63,6 +65,7 @@ static void interface_base_finalize( NactIActionsListInterface *klass );
static void v_on_selection_changed( GtkTreeSelection *selection, gpointer user_data );
static gboolean v_on_button_press_event( GtkWidget *widget, GdkEventButton *event, gpointer data );
+static gboolean v_on_key_press_event( GtkWidget *widget, GdkEventKey *event, gpointer data );
static void do_initial_load_widget( NactWindow *window );
static void do_runtime_init_widget( NactWindow *window );
@@ -343,6 +346,32 @@ v_on_button_press_event( GtkWidget *widget, GdkEventButton *event, gpointer user
return( stop );
}
+static gboolean
+v_on_key_press_event( GtkWidget *widget, GdkEventKey *event, gpointer user_data )
+{
+ static const gchar *thisfn = "nact_iactions_list_v_on_key_pres_event";
+ g_debug( "%s: widget=%p, event=%p, user_data=%p", thisfn, widget, event, user_data );
+
+ g_assert( NACT_IS_IACTIONS_LIST( user_data ));
+ g_assert( NACT_IS_WINDOW( user_data ));
+
+ gboolean stop = FALSE;
+ NactIActionsList *instance = NACT_IACTIONS_LIST( user_data );
+
+ if( NACT_IACTIONS_LIST_GET_INTERFACE( instance )->on_key_press_event ){
+ stop = NACT_IACTIONS_LIST_GET_INTERFACE( instance )->on_key_press_event( widget, event, user_data );
+ }
+
+ if( !stop ){
+ if( event->keyval == GDK_Return || event->keyval == GDK_KP_Enter ){
+ if( NACT_IACTIONS_LIST_GET_INTERFACE( instance )->on_enter_key_pressed ){
+ stop = NACT_IACTIONS_LIST_GET_INTERFACE( instance )->on_enter_key_pressed( widget, event, user_data );
+ }
+ }
+ }
+ return( stop );
+}
+
void
do_initial_load_widget( NactWindow *window )
{
@@ -389,6 +418,13 @@ do_runtime_init_widget( NactWindow *window )
G_CALLBACK( v_on_selection_changed ),
window );
+ /* catch press 'Enter' */
+ g_signal_connect(
+ G_OBJECT( widget ),
+ "key-press-event",
+ G_CALLBACK( v_on_key_press_event ),
+ window );
+
/* catch double-click */
g_signal_connect(
G_OBJECT( widget ),
diff --git a/src/nact/nact-iactions-list.h b/src/nact/nact-iactions-list.h
index 2d5af2c..3f53ff6 100644
--- a/src/nact/nact-iactions-list.h
+++ b/src/nact/nact-iactions-list.h
@@ -64,7 +64,9 @@ typedef struct {
void ( *fill_actions_list ) ( NactWindow *window );
void ( *on_selection_changed ) ( GtkTreeSelection *selection, gpointer user_data );
gboolean ( *on_button_press_event )( GtkWidget *widget, GdkEventButton *event, gpointer data );
+ gboolean ( *on_key_press_event ) ( GtkWidget *widget, GdkEventKey *event, gpointer data );
gboolean ( *on_double_click ) ( GtkWidget *widget, GdkEventButton *event, gpointer data );
+ gboolean ( *on_enter_key_pressed ) ( GtkWidget *widget, GdkEventKey *event, gpointer data );
}
NactIActionsListInterface;
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index 0f23f46..dcf6b80 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -80,6 +80,7 @@ static void on_runtime_init_toplevel( BaseWindow *window );
static void on_actions_list_selection_changed( GtkTreeSelection *selection, gpointer user_data );
static gboolean on_actions_list_double_click( GtkWidget *widget, GdkEventButton *event, gpointer data );
+static gboolean on_actions_list_enter_key_pressed( GtkWidget *widget, GdkEventKey *event, gpointer data );
static void on_about_button_clicked( GtkButton *button, gpointer user_data );
static void on_add_button_clicked( GtkButton *button, gpointer user_data );
@@ -186,6 +187,7 @@ iactions_list_iface_init( NactIActionsListInterface *iface )
iface->runtime_init_widget = NULL;
iface->on_selection_changed = on_actions_list_selection_changed;
iface->on_double_click = on_actions_list_double_click;
+ iface->on_enter_key_pressed = on_actions_list_enter_key_pressed;
}
static void
@@ -346,6 +348,13 @@ on_actions_list_double_click( GtkWidget *widget, GdkEventButton *event, gpointer
return( TRUE );
}
+static gboolean
+on_actions_list_enter_key_pressed( GtkWidget *widget, GdkEventKey *event, gpointer user_data )
+{
+ on_edit_button_clicked( NULL, user_data );
+ return( TRUE );
+}
+
/* TODO: make the website url and the mail addresses clickables
*/
static void
diff --git a/src/nact/nautilus-actions-config.ui b/src/nact/nautilus-actions-config.ui
index ebff366..bf306c5 100644
--- a/src/nact/nautilus-actions-config.ui
+++ b/src/nact/nautilus-actions-config.ui
@@ -27,7 +27,7 @@
<object class="GtkTreeView" id="ActionsList">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="events">GDK_BUTTON_PRESS_MASK</property>
+ <property name="events">GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK</property>
<property name="headers_visible">False</property>
<property name="rules_hint">True</property>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]