[nautilus-actions] Rename TREE_SIGNAL_CONTEXT_MENU to MAIN_SIGNAL_CONTEXT_MENU
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Rename TREE_SIGNAL_CONTEXT_MENU to MAIN_SIGNAL_CONTEXT_MENU
- Date: Thu, 2 Feb 2012 21:43:08 +0000 (UTC)
commit 4de2da595a6d0046f9084b6ffef54bd1ccdfd128
Author: Pierre Wieser <pwieser trychlos org>
Date: Wed Feb 1 23:22:37 2012 +0100
Rename TREE_SIGNAL_CONTEXT_MENU to MAIN_SIGNAL_CONTEXT_MENU
ChangeLog | 11 +++
src/nact/nact-main-tab.c | 38 ++++++++----
src/nact/nact-main-window.c | 27 ++++++++
src/nact/nact-main-window.h | 5 +-
src/nact/nact-marshal.def | 3 +
src/nact/nact-menubar.c | 85 +++++++++++++++++--------
src/nact/nact-tree-view.c | 28 +--------
src/nact/nact-tree-view.h | 1 -
src/nact/nautilus-actions-config-tool.actions | 2 +-
9 files changed, 131 insertions(+), 69 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8369e9a..b8abe12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2012-02-01 Pierre Wieser <pwieser trychlos org>
+ * src/nact/nact-main-window.c:
+ * src/nact/nact-main-window.h: New MAIN_SIGNAL_CONTEXT_MENU signal.
+
+ * src/nact/nact-marshal.def: New closure definition.
+
+ * src/nact/nact-tree-view.c:
+ * src/nact/nact-tree-view.h: Removed TREE_SIGNAL_CONTEXT_MENU signal.
+
+ * src/nact/nautilus-actions-config-tool.actions:
+ * src/nact/nact-menubar.c: Updated accordingly.
+
* src/nact/nact-main-tab.c:
* src/nact/nact-main-tab.h (nact_main_tab_init): New function.
diff --git a/src/nact/nact-main-tab.c b/src/nact/nact-main-tab.c
index a147ff3..665ccce 100644
--- a/src/nact/nact-main-tab.c
+++ b/src/nact/nact-main-tab.c
@@ -36,6 +36,7 @@
#include "nact-main-tab.h"
+static void on_tab_initialize_window( NactMainWindow *window, gpointer p_page );
static gboolean on_button_press_event( GtkWidget *widget, GdkEventButton *event, NactMainWindow *window );
static void open_popup( NactMainWindow *window, GdkEventButton *event );
@@ -49,18 +50,12 @@ static void open_popup( NactMainWindow *window, GdkEventButton *event );
void
nact_main_tab_init( NactMainWindow *window, gint num_page )
{
- GtkNotebook *notebook;
- GtkWidget *page, *label;
-
- notebook = GTK_NOTEBOOK( base_window_get_widget( BASE_WINDOW( window ), "MainNotebook" ));
- page = gtk_notebook_get_nth_page( notebook, num_page );
- label = gtk_notebook_get_tab_label( notebook, page );
-
- base_window_signal_connect(
+ base_window_signal_connect_with_data(
BASE_WINDOW( window ),
- G_OBJECT( label ),
- "button-press-event",
- G_CALLBACK( on_button_press_event ));
+ G_OBJECT( window ),
+ BASE_SIGNAL_INITIALIZE_WINDOW,
+ G_CALLBACK( on_tab_initialize_window ),
+ GUINT_TO_POINTER( num_page ));
}
/**
@@ -109,6 +104,25 @@ nact_main_tab_is_page_enabled( NactMainWindow *window, gint num_page )
return( is_sensitive );
}
+static void
+on_tab_initialize_window( NactMainWindow *window, gpointer p_page )
+{
+ GtkNotebook *notebook;
+ GtkWidget *page, *label;
+ guint num_page;
+
+ notebook = GTK_NOTEBOOK( base_window_get_widget( BASE_WINDOW( window ), "MainNotebook" ));
+ num_page = GPOINTER_TO_UINT( p_page );
+ page = gtk_notebook_get_nth_page( notebook, num_page );
+ label = gtk_notebook_get_tab_label( notebook, page );
+
+ base_window_signal_connect(
+ BASE_WINDOW( window ),
+ G_OBJECT( label ),
+ "button-press-event",
+ G_CALLBACK( on_button_press_event ));
+}
+
static gboolean
on_button_press_event( GtkWidget *widget, GdkEventButton *event, NactMainWindow *window )
{
@@ -137,6 +151,6 @@ open_popup( NactMainWindow *window, GdkEventButton *event )
gtk_tree_path_free( path );
}
- g_signal_emit_by_name( window, TREE_SIGNAL_CONTEXT_MENU, event );
+ g_signal_emit_by_name( window, MAIN_SIGNAL_CONTEXT_MENU, event, "popup" );
#endif
}
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index 4b29ff5..2f00b33 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -149,6 +149,7 @@ enum {
MAIN_ITEM_UPDATED,
TAB_ITEM_UPDATED,
SELECTION_CHANGED,
+ CONTEXT_MENU,
LAST_SIGNAL
};
@@ -454,6 +455,32 @@ class_init( NactMainWindowClass *klass )
G_TYPE_NONE,
1,
G_TYPE_POINTER );
+
+ /**
+ * NactMainWindow::main-signal-open-popup
+ *
+ * This signal is emitted on the BaseWindow parent when the user right
+ * clicks somewhere (on an active zone).
+ *
+ * Signal args:
+ * - the GdkEvent
+ * - the popup name to be opened.
+ *
+ * Handler prototype:
+ * void ( *handler )( BaseWindow *window, GdkEvent *event, const gchar *popup_name, gpointer user_data );
+ */
+ st_signals[ CONTEXT_MENU ] = g_signal_new(
+ MAIN_SIGNAL_CONTEXT_MENU,
+ G_TYPE_OBJECT,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ nact_cclosure_marshal_VOID__POINTER_STRING,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_POINTER,
+ G_TYPE_STRING);
}
static void
diff --git a/src/nact/nact-main-window.h b/src/nact/nact-main-window.h
index 9e7c116..66eb436 100644
--- a/src/nact/nact-main-window.h
+++ b/src/nact/nact-main-window.h
@@ -232,9 +232,11 @@
* - IActionTab and ICommandTab should update their label widgets
* - IPropertiesTab updates its provider label
*
+ * MAIN_SIGNAL_CONTEXT_MENU
+ * Opens the specified context menu.
+ *
* TREE_SIGNAL_FOCUS_IN
* TREE_SIGNAL_FOCUS_OUT
- * TREE_SIGNAL_CONTEXT_MENU
* TREE_SIGNAL_COUNT_CHANGED
* TREE_SIGNAL_LEVEL_ZERO_CHANGED
* TREE_SIGNAL_MODIFIED_STATUS_CHANGED
@@ -280,6 +282,7 @@ typedef struct {
*/
#define MAIN_SIGNAL_ITEM_UPDATED "main-item-updated"
#define MAIN_SIGNAL_SELECTION_CHANGED "main-selection-changed"
+#define MAIN_SIGNAL_CONTEXT_MENU "main-signal-open-popup"
/**
* The data which, when modified, should be redisplayed asap.
diff --git a/src/nact/nact-marshal.def b/src/nact/nact-marshal.def
index 4623a90..a5cbe01 100644
--- a/src/nact/nact-marshal.def
+++ b/src/nact/nact-marshal.def
@@ -4,3 +4,6 @@ VOID:BOOLEAN,INT,INT,INT
# NactMainWindow::TAB_UPDATABLE_SIGNAL_ITEM_UPDATED
# NactMainWindow::MAIN_SIGNAL_ITEM_UPDATED
VOID:POINTER,UINT
+#
+# NactMainWindow::MAIN_SIGNAL_CONTEXT_MENU
+VOID:POINTER,STRING
diff --git a/src/nact/nact-menubar.c b/src/nact/nact-menubar.c
index c6ea610..733fd88 100644
--- a/src/nact/nact-menubar.c
+++ b/src/nact/nact-menubar.c
@@ -211,7 +211,7 @@ static void on_ui_manager_proxy_connect( GtkUIManager *ui_manager, GtkAction
static void on_menu_item_selected( GtkMenuItem *proxy, BaseWindow *window );
static void on_menu_item_deselected( GtkMenuItem *proxy, BaseWindow *window );
-static void on_tree_view_open_context_menu( BaseWindow *window, GdkEventButton *event, gpointer user_data );
+static void on_open_context_menu( BaseWindow *window, GdkEventButton *event, const gchar *popup, gpointer user_data );
static void on_popup_selection_done( GtkMenuShell *menushell, BaseWindow *window );
static void on_tree_view_count_changed( BaseWindow *window, gboolean reset, gint menus, gint actions, gint profiles );
static void on_tree_view_focus_in( BaseWindow *window, gpointer user_data );
@@ -428,9 +428,11 @@ on_base_initialize_window( BaseWindow *window, gpointer user_data )
bar->private->ui_manager = gtk_ui_manager_new();
g_debug( "%s: ui_manager=%p", thisfn, ( void * ) bar->private->ui_manager );
- base_window_signal_connect( window,
+ base_window_signal_connect(
+ window,
G_OBJECT( bar->private->ui_manager ),
- "connect-proxy", G_CALLBACK( on_ui_manager_proxy_connect ));
+ "connect-proxy",
+ G_CALLBACK( on_ui_manager_proxy_connect ));
bar->private->action_group = gtk_action_group_new( "MenubarActions" );
g_debug( "%s: action_group=%p", thisfn, ( void * ) bar->private->action_group );
@@ -482,26 +484,47 @@ on_base_initialize_window( BaseWindow *window, gpointer user_data )
/* connect to all signal which may have an influence on the menu
* items sensitivity
*/
- base_window_signal_connect( window,
- G_OBJECT( window ), TREE_SIGNAL_CONTEXT_MENU, G_CALLBACK( on_tree_view_open_context_menu ));
-
- base_window_signal_connect( window,
- G_OBJECT( window ), TREE_SIGNAL_COUNT_CHANGED, G_CALLBACK( on_tree_view_count_changed ));
-
- base_window_signal_connect( window,
- G_OBJECT( window ), TREE_SIGNAL_FOCUS_IN, G_CALLBACK( on_tree_view_focus_in ));
-
- base_window_signal_connect( window,
- G_OBJECT( window ), TREE_SIGNAL_FOCUS_OUT, G_CALLBACK( on_tree_view_focus_out ));
-
- base_window_signal_connect( window,
- G_OBJECT( window ), TREE_SIGNAL_MODIFIED_STATUS_CHANGED, G_CALLBACK( on_tree_view_modified_status_changed ));
-
- base_window_signal_connect( window,
- G_OBJECT( window ), TREE_SIGNAL_SELECTION_CHANGED, G_CALLBACK( on_tree_view_selection_changed ));
-
- base_window_signal_connect( window,
- G_OBJECT( bar ), MENUBAR_SIGNAL_UPDATE_SENSITIVITIES, G_CALLBACK( on_update_sensitivities ));
+ base_window_signal_connect(
+ window,
+ G_OBJECT( window ),
+ MAIN_SIGNAL_CONTEXT_MENU,
+ G_CALLBACK( on_open_context_menu ));
+
+ base_window_signal_connect(
+ window,
+ G_OBJECT( window ),
+ TREE_SIGNAL_COUNT_CHANGED,
+ G_CALLBACK( on_tree_view_count_changed ));
+
+ base_window_signal_connect(
+ window,
+ G_OBJECT( window ),
+ TREE_SIGNAL_FOCUS_IN,
+ G_CALLBACK( on_tree_view_focus_in ));
+
+ base_window_signal_connect(
+ window,
+ G_OBJECT( window ),
+ TREE_SIGNAL_FOCUS_OUT,
+ G_CALLBACK( on_tree_view_focus_out ));
+
+ base_window_signal_connect(
+ window,
+ G_OBJECT( window ),
+ TREE_SIGNAL_MODIFIED_STATUS_CHANGED,
+ G_CALLBACK( on_tree_view_modified_status_changed ));
+
+ base_window_signal_connect(
+ window,
+ G_OBJECT( window ),
+ TREE_SIGNAL_SELECTION_CHANGED,
+ G_CALLBACK( on_tree_view_selection_changed ));
+
+ base_window_signal_connect(
+ window,
+ G_OBJECT( bar ),
+ MENUBAR_SIGNAL_UPDATE_SENSITIVITIES,
+ G_CALLBACK( on_update_sensitivities ));
nact_menubar_file_initialize( bar );
nact_main_toolbar_init( window, bar->private->action_group );
@@ -569,17 +592,23 @@ on_menu_item_deselected( GtkMenuItem *proxy, BaseWindow *window )
* Opens a popup menu.
*/
static void
-on_tree_view_open_context_menu( BaseWindow *window, GdkEventButton *event, gpointer user_data )
+on_open_context_menu( BaseWindow *window, GdkEventButton *event, const gchar *popup, gpointer user_data )
{
GtkWidget *menu;
BAR_WINDOW_VOID( window );
- menu = gtk_ui_manager_get_widget( bar->private->ui_manager, "/ui/Popup" );
- bar->private->popup_handler =
- g_signal_connect( menu, "selection-done", G_CALLBACK( on_popup_selection_done ), window );
+ menu = gtk_ui_manager_get_widget( bar->private->ui_manager, popup );
+ if( menu ){
+ bar->private->popup_handler =
+ g_signal_connect(
+ menu,
+ "selection-done",
+ G_CALLBACK( on_popup_selection_done ),
+ window );
- gtk_menu_popup( GTK_MENU( menu ), NULL, NULL, NULL, NULL, event->button, event->time );
+ gtk_menu_popup( GTK_MENU( menu ), NULL, NULL, NULL, NULL, event->button, event->time );
+ }
}
static void
diff --git a/src/nact/nact-tree-view.c b/src/nact/nact-tree-view.c
index 6ff8ea7..8145e24 100644
--- a/src/nact/nact-tree-view.c
+++ b/src/nact/nact-tree-view.c
@@ -40,6 +40,7 @@
#include "base-keysyms.h"
#include "nact-application.h"
+#include "nact-main-window.h"
#include "nact-marshal.h"
#include "nact-tree-view.h"
#include "nact-tree-model.h"
@@ -86,7 +87,6 @@ enum {
/* signals
*/
enum {
- CONTEXT_MENU,
COUNT_CHANGED,
FOCUS_IN,
FOCUS_OUT,
@@ -260,30 +260,6 @@ class_init( NactTreeViewClass *klass )
G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE ));
/**
- * NactTreeView::tree-signal-open-popup
- *
- * This signal is emitted on the BaseWindow parent when the user right
- * clicks on the tree view.
- *
- * Signal args:
- * - the GdkEvent.
- *
- * Handler prototype:
- * void ( *handler )( BaseWindow *window, GdkEvent *event, gpointer user_data );
- */
- st_signals[ CONTEXT_MENU ] = g_signal_new(
- TREE_SIGNAL_CONTEXT_MENU,
- G_TYPE_OBJECT,
- G_SIGNAL_RUN_LAST,
- 0,
- NULL,
- NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE,
- 1,
- G_TYPE_POINTER );
-
- /**
* NactTreeView::tree-signal-count-changed:
*
* This signal is emitted on BaseWindow parent when the count of items
@@ -1435,7 +1411,7 @@ open_popup( BaseWindow *window, GdkEventButton *event )
gtk_tree_path_free( path );
}
- g_signal_emit_by_name( window, TREE_SIGNAL_CONTEXT_MENU, event );
+ g_signal_emit_by_name( window, MAIN_SIGNAL_CONTEXT_MENU, event, "/ui/TreeContext" );
}
/*
diff --git a/src/nact/nact-tree-view.h b/src/nact/nact-tree-view.h
index 100b218..20b330c 100644
--- a/src/nact/nact-tree-view.h
+++ b/src/nact/nact-tree-view.h
@@ -98,7 +98,6 @@ typedef struct {
/**
* Signals emitted by the NactTreeView instance.
*/
-#define TREE_SIGNAL_CONTEXT_MENU "tree-signal-open-popup"
#define TREE_SIGNAL_COUNT_CHANGED "tree-signal-count-changed"
#define TREE_SIGNAL_FOCUS_IN "tree-signal-focus-in"
#define TREE_SIGNAL_FOCUS_OUT "tree-signal-focus-out"
diff --git a/src/nact/nautilus-actions-config-tool.actions b/src/nact/nautilus-actions-config-tool.actions
index 3a47564..abdbd16 100644
--- a/src/nact/nautilus-actions-config-tool.actions
+++ b/src/nact/nautilus-actions-config-tool.actions
@@ -44,7 +44,7 @@
</menu>
</menubar>
- <popup name="Popup">
+ <popup name="TreeContext">
<menuitem action="NewMenuItem" />
<menuitem action="NewActionItem" />
<menuitem action="NewProfileItem" />
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]