[nautilus-actions] nact_main_tab_init(): new function



commit 83f86f85aab14964200b65413146238d97f8b21f
Author: Pierre Wieser <pwieser trychlos org>
Date:   Wed Feb 1 22:55:51 2012 +0100

    nact_main_tab_init(): new function

 ChangeLog                         |   14 +++++++++
 src/nact/nact-iaction-tab.c       |    2 +
 src/nact/nact-ibasenames-tab.c    |    2 +
 src/nact/nact-icapabilities-tab.c |    2 +
 src/nact/nact-icommand-tab.c      |    2 +
 src/nact/nact-ienvironment-tab.c  |    2 +
 src/nact/nact-iexecution-tab.c    |    2 +
 src/nact/nact-ifolders-tab.c      |    2 +
 src/nact/nact-imimetypes-tab.c    |    2 +
 src/nact/nact-iproperties-tab.c   |    2 +
 src/nact/nact-ischemes-tab.c      |    2 +
 src/nact/nact-main-tab.c          |   59 +++++++++++++++++++++++++++++++++++++
 src/nact/nact-main-tab.h          |    1 +
 13 files changed, 94 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9664f4a..8369e9a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2012-02-01 Pierre Wieser <pwieser trychlos org>
 
+	* src/nact/nact-main-tab.c:
+	* src/nact/nact-main-tab.h (nact_main_tab_init): New function.
+
+	* src/nact/nact-iaction-tab.c (nact_iaction_tab_init):
+	* src/nact/nact-ibasenames-tab.c (nact_ibasenames_tab_init):
+	* src/nact/nact-icapabilities-tab.c (nact_icapabilities_tab_init):
+	* src/nact/nact-icommand-tab.c (nact_icommand_tab_init):
+	* src/nact/nact-ienvironment-tab.c (nact_ienvironment_tab_init):
+	* src/nact/nact-iexecution-tab.c (nact_iexecution_tab_init):
+	* src/nact/nact-ifolders-tab.c (nact_ifolders_tab_init):
+	* src/nact/nact-imimetypes-tab.c (nact_imimetypes_tab_init):
+	* src/nact/nact-iproperties-tab.c (nact_iproperties_tab_init):
+	* src/nact/nact-ischemes-tab.c (nact_ischemes_tab_init): Updated accordingly.
+
 	* src/nact/nact-main-window.c
 	(instance_dispose): Saves the current tabs position.
 	(on_base_initialize_gtk): Restaures and set the tabs position.
diff --git a/src/nact/nact-iaction-tab.c b/src/nact/nact-iaction-tab.c
index 678b42d..0efeac7 100644
--- a/src/nact/nact-iaction-tab.c
+++ b/src/nact/nact-iaction-tab.c
@@ -197,6 +197,8 @@ nact_iaction_tab_init( NactIActionTab *instance )
 			BASE_SIGNAL_INITIALIZE_WINDOW,
 			G_CALLBACK( on_base_initialize_window ));
 
+	nact_main_tab_init( NACT_MAIN_WINDOW( instance ), TAB_ACTION );
+
 	data = get_iaction_data( instance );
 	data->on_selection_change = FALSE;
 
diff --git a/src/nact/nact-ibasenames-tab.c b/src/nact/nact-ibasenames-tab.c
index 65d1b1d..ad74de0 100644
--- a/src/nact/nact-ibasenames-tab.c
+++ b/src/nact/nact-ibasenames-tab.c
@@ -178,6 +178,8 @@ nact_ibasenames_tab_init( NactIBasenamesTab *instance )
 			BASE_SIGNAL_INITIALIZE_WINDOW,
 			G_CALLBACK( on_base_initialize_window ));
 
+	nact_main_tab_init( NACT_MAIN_WINDOW( instance ), TAB_BASENAMES );
+
 	data = get_ibasenames_data( instance );
 	data->on_selection_change = FALSE;
 
diff --git a/src/nact/nact-icapabilities-tab.c b/src/nact/nact-icapabilities-tab.c
index 7c6a6c1..79412e3 100644
--- a/src/nact/nact-icapabilities-tab.c
+++ b/src/nact/nact-icapabilities-tab.c
@@ -166,6 +166,8 @@ nact_icapabilities_tab_init( NactICapabilitiesTab *instance )
 			BASE_SIGNAL_INITIALIZE_WINDOW,
 			G_CALLBACK( on_base_initialize_window ));
 
+	nact_main_tab_init( NACT_MAIN_WINDOW( instance ), TAB_CAPABILITIES );
+
 	g_object_weak_ref( G_OBJECT( instance ), ( GWeakNotify ) on_instance_finalized, NULL );
 }
 
diff --git a/src/nact/nact-icommand-tab.c b/src/nact/nact-icommand-tab.c
index 2c51b5c..d6cd419 100644
--- a/src/nact/nact-icommand-tab.c
+++ b/src/nact/nact-icommand-tab.c
@@ -196,6 +196,8 @@ nact_icommand_tab_init( NactICommandTab *instance )
 			BASE_SIGNAL_INITIALIZE_WINDOW,
 			G_CALLBACK( on_base_initialize_window ));
 
+	nact_main_tab_init( NACT_MAIN_WINDOW( instance ), TAB_COMMAND );
+
 	data = get_icommand_data( instance );
 	data->on_selection_change = FALSE;
 	data->tokens = NULL;
diff --git a/src/nact/nact-ienvironment-tab.c b/src/nact/nact-ienvironment-tab.c
index 7ca2649..526caf8 100644
--- a/src/nact/nact-ienvironment-tab.c
+++ b/src/nact/nact-ienvironment-tab.c
@@ -231,6 +231,8 @@ nact_ienvironment_tab_init( NactIEnvironmentTab *instance )
 			BASE_SIGNAL_INITIALIZE_WINDOW,
 			G_CALLBACK( on_base_initialize_window ));
 
+	nact_main_tab_init( NACT_MAIN_WINDOW( instance ), TAB_ENVIRONMENT );
+
 	data = get_ienviron_data( instance );
 	data->on_selection_change = FALSE;
 
diff --git a/src/nact/nact-iexecution-tab.c b/src/nact/nact-iexecution-tab.c
index e44defd..a212fd9 100644
--- a/src/nact/nact-iexecution-tab.c
+++ b/src/nact/nact-iexecution-tab.c
@@ -171,6 +171,8 @@ nact_iexecution_tab_init( NactIExecutionTab *instance )
 			BASE_SIGNAL_INITIALIZE_WINDOW,
 			G_CALLBACK( on_base_initialize_window ));
 
+	nact_main_tab_init( NACT_MAIN_WINDOW( instance ), TAB_EXECUTION );
+
 	data = get_iexecution_data( instance );
 	data->on_selection_change = FALSE;
 
diff --git a/src/nact/nact-ifolders-tab.c b/src/nact/nact-ifolders-tab.c
index 070f0cd..783b75b 100644
--- a/src/nact/nact-ifolders-tab.c
+++ b/src/nact/nact-ifolders-tab.c
@@ -171,6 +171,8 @@ nact_ifolders_tab_init( NactIFoldersTab *instance )
 			BASE_SIGNAL_INITIALIZE_WINDOW,
 			G_CALLBACK( on_base_initialize_window ));
 
+	nact_main_tab_init( NACT_MAIN_WINDOW( instance ), TAB_FOLDERS );
+
 	g_object_weak_ref( G_OBJECT( instance ), ( GWeakNotify ) on_instance_finalized, NULL );
 }
 
diff --git a/src/nact/nact-imimetypes-tab.c b/src/nact/nact-imimetypes-tab.c
index 5e56228..3b95c19 100644
--- a/src/nact/nact-imimetypes-tab.c
+++ b/src/nact/nact-imimetypes-tab.c
@@ -165,6 +165,8 @@ nact_imimetypes_tab_init( NactIMimetypesTab *instance )
 			BASE_SIGNAL_INITIALIZE_WINDOW,
 			G_CALLBACK( on_base_initialize_window ));
 
+	nact_main_tab_init( NACT_MAIN_WINDOW( instance ), TAB_MIMETYPES );
+
 	g_object_weak_ref( G_OBJECT( instance ), ( GWeakNotify ) on_instance_finalized, NULL );
 }
 
diff --git a/src/nact/nact-iproperties-tab.c b/src/nact/nact-iproperties-tab.c
index c6ea614..b8ea77b 100644
--- a/src/nact/nact-iproperties-tab.c
+++ b/src/nact/nact-iproperties-tab.c
@@ -178,6 +178,8 @@ nact_iproperties_tab_init( NactIPropertiesTab *instance )
 			BASE_SIGNAL_INITIALIZE_WINDOW,
 			G_CALLBACK( on_base_initialize_window ));
 
+	nact_main_tab_init( NACT_MAIN_WINDOW( instance ), TAB_PROPERTIES );
+
 	data = get_iproperties_data( instance );
 	data->on_selection_change = FALSE;
 
diff --git a/src/nact/nact-ischemes-tab.c b/src/nact/nact-ischemes-tab.c
index 91bb4bb..491dd31 100644
--- a/src/nact/nact-ischemes-tab.c
+++ b/src/nact/nact-ischemes-tab.c
@@ -169,6 +169,8 @@ nact_ischemes_tab_init( NactISchemesTab *instance )
 			BASE_SIGNAL_INITIALIZE_WINDOW,
 			G_CALLBACK( on_base_initialize_window ));
 
+	nact_main_tab_init( NACT_MAIN_WINDOW( instance ), TAB_SCHEMES );
+
 	g_object_weak_ref( G_OBJECT( instance ), ( GWeakNotify ) on_instance_finalized, NULL );
 }
 
diff --git a/src/nact/nact-main-tab.c b/src/nact/nact-main-tab.c
index 35473f1..a147ff3 100644
--- a/src/nact/nact-main-tab.c
+++ b/src/nact/nact-main-tab.c
@@ -36,6 +36,33 @@
 
 #include "nact-main-tab.h"
 
+static gboolean on_button_press_event( GtkWidget *widget, GdkEventButton *event, NactMainWindow *window );
+static void     open_popup( NactMainWindow *window, GdkEventButton *event );
+
+/**
+ * nact_main_tab_init:
+ * @window: the #NactMainWindow.
+ * @num_page: the page number, starting from zero.
+ *
+ * Common initialization of each page of the notebook.
+ */
+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( window ),
+			G_OBJECT( label ),
+			"button-press-event",
+			G_CALLBACK( on_button_press_event ));
+}
+
 /**
  * nact_main_tab_enable_page:
  * @window: the #NactMainWindow.
@@ -81,3 +108,35 @@ nact_main_tab_is_page_enabled( NactMainWindow *window, gint num_page )
 
 	return( is_sensitive );
 }
+
+static gboolean
+on_button_press_event( GtkWidget *widget, GdkEventButton *event, NactMainWindow *window )
+{
+	gboolean stop = FALSE;
+
+	/* single click on right button */
+	if( event->type == GDK_BUTTON_PRESS && event->button == 3 ){
+		open_popup( window, event );
+		stop = TRUE;
+	}
+
+	return( stop );
+}
+
+static void
+open_popup( NactMainWindow *window, GdkEventButton *event )
+{
+#if 0
+	NactTreeView *items_view;
+	GtkTreePath *path;
+
+	items_view = NACT_TREE_VIEW( g_object_get_data( G_OBJECT( window ), WINDOW_DATA_TREE_VIEW ));
+
+	if( gtk_tree_view_get_path_at_pos( items_view->private->tree_view, event->x, event->y, &path, NULL, NULL, NULL )){
+		nact_tree_view_select_row_at_path( items_view, path );
+		gtk_tree_path_free( path );
+	}
+
+	g_signal_emit_by_name( window, TREE_SIGNAL_CONTEXT_MENU, event );
+#endif
+}
diff --git a/src/nact/nact-main-tab.h b/src/nact/nact-main-tab.h
index 69cf740..cffe7c0 100644
--- a/src/nact/nact-main-tab.h
+++ b/src/nact/nact-main-tab.h
@@ -64,6 +64,7 @@ enum {
 	TAB_PROPERTIES
 };
 
+void     nact_main_tab_init           ( NactMainWindow *window, gint page );
 void     nact_main_tab_enable_page    ( NactMainWindow *window, gint page, gboolean enabled );
 gboolean nact_main_tab_is_page_enabled( NactMainWindow *window, gint page );
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]