Commit ac30af51 authored by Pierre Wieser's avatar Pierre Wieser

Revert three last BaseWindow commits

This is due to the new virtual method handling paradigm.
parent 2fef42ce
2011-01-22 Pierre Wieser <pwieser@trychlos.org>
* src/nact/base-window.c:
* src/nact/base-window.h:
Revert commits dfb26ec5, 1991b3b7 and 4d0c43bb due to new virtual method
handling paradigm.
Pass the GtkWindow toplevel as a parameter of 'base-window-initialize-gtk'
signal.
initial_load_toplevel() virtual method is renamed as initialize_gtk_toplevel().
* src/nact/nact-main-window.c:
No more connect to the signal, but implement the virtual method.
* src/nact/base-application.c (appli_initialize_manage_options):
* src/nact/base-application.h (manage_options):
* src/nact/nact-application.c (appli_manage_options):
......
......@@ -116,28 +116,30 @@ static void instance_set_property( GObject *object, guint property_i
static void instance_dispose( GObject *application );
static void instance_finalize( GObject *application );
/* initialization process
*/
static gboolean setup_builder( const BaseWindow *window );
static gboolean load_gtk_toplevel( const BaseWindow *window );
static gboolean is_gtk_toplevel_initialized( const BaseWindow *window, GtkWindow *gtk_toplevel );
static void set_gtk_toplevel_initialized( const BaseWindow *window, GtkWindow *gtk_toplevel, gboolean init );
static gboolean on_delete_event( GtkWidget *widget, GdkEvent *event, BaseWindow *window );
static void on_initialize_gtk_toplevel_class_handler( BaseWindow *window, gpointer user_data );
static void do_initialize_gtk_toplevel( BaseWindow *window, gpointer user_data );
static void on_initialize_gtk_toplevel_class_handler( BaseWindow *window, GtkWindow *toplevel );
static void do_initialize_gtk_toplevel( BaseWindow *window, GtkWindow *toplevel );
static void on_initialize_base_window_class_handler( BaseWindow *window, gpointer user_data );
static void do_initialize_base_window( BaseWindow *window, gpointer user_data );
static void on_all_widgets_showed_class_handler( BaseWindow *window, gpointer user_data );
/* run
*/
static gboolean is_main_window( BaseWindow *window );
static gboolean on_delete_event( GtkWidget *widget, GdkEvent *event, BaseWindow *window );
static gboolean v_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window );
static gchar *v_get_toplevel_name( const BaseWindow *window );
static gchar *v_get_iprefs_window_id( const BaseWindow *window );
static gboolean window_do_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window );
static gboolean window_do_delete_event( BaseWindow *window, GtkWindow *toplevel, GdkEvent *event );
static gboolean window_do_is_willing_to_quit( const BaseWindow *window );
static gboolean is_main_window( BaseWindow *window );
static void record_connected_signal( BaseWindow *window, GObject *instance, gulong handler_id );
static gint display_dlg( const BaseWindow *parent, GtkMessageType type_message, GtkButtonsType type_buttons, const gchar *primary, const gchar *secondary );
......@@ -243,7 +245,7 @@ class_init( BaseWindowClass *klass )
klass->private = g_new0( BaseWindowClassPrivate, 1 );
klass->initial_load_toplevel = do_initialize_gtk_toplevel;
klass->initialize_gtk_toplevel = do_initialize_gtk_toplevel;
klass->runtime_init_toplevel = do_initialize_base_window;
klass->all_widgets_showed = NULL;
klass->dialog_response = window_do_dialog_response;
......@@ -251,13 +253,15 @@ class_init( BaseWindowClass *klass )
klass->get_toplevel_name = NULL;
klass->get_iprefs_window_id = NULL;
klass->get_ui_filename = NULL;
klass->is_willing_to_quit = window_do_is_willing_to_quit;
klass->is_willing_to_quit = NULL;
/**
* base-window-initialize-gtk:
*
* The signal is emitted by the #BaseWindow instance when it has
* The signal is emitted by and on the #BaseWindow instance when it has
* loaded for the first time the Gtk toplevel widget from the GtkBuilder.
*
* The toplevel GtkWindow is passed as a parameter to this signal.
*/
st_signals[ INITIALIZE_GTK ] =
g_signal_new_class_handler(
......@@ -549,6 +553,7 @@ gboolean
base_window_init( BaseWindow *window )
{
static const gchar *thisfn = "base_window_init";
gboolean initialized;
g_return_val_if_fail( BASE_IS_WINDOW( window ), FALSE );
......@@ -573,8 +578,12 @@ base_window_init( BaseWindow *window )
if( window->private->gtk_toplevel ){
g_return_val_if_fail( GTK_IS_WINDOW( window->private->gtk_toplevel ), FALSE );
if( !is_gtk_toplevel_initialized( window, window->private->gtk_toplevel )){
g_signal_emit_by_name( window, BASE_SIGNAL_INITIALIZE_GTK, NULL );
initialized = is_gtk_toplevel_initialized( window, window->private->gtk_toplevel );
g_debug( "%s: gtk_toplevel=%p, initialized=%s",
thisfn, ( void * ) window->private->gtk_toplevel, initialized ? "True":"False" );
if( !initialized ){
g_signal_emit_by_name( window, BASE_SIGNAL_INITIALIZE_GTK, window->private->gtk_toplevel );
set_gtk_toplevel_initialized( window, window->private->gtk_toplevel, TRUE );
}
......@@ -685,6 +694,110 @@ set_gtk_toplevel_initialized( const BaseWindow *window, GtkWindow *gtk_toplevel,
g_object_set_data( G_OBJECT( gtk_toplevel ), "base-window-gtk-toplevel-initialized", GUINT_TO_POINTER( initialized ));
}
/*
* default class handler for "base-window-initialize-gtk" signal
*
* successively invokes the method of each derived class, starting from
* the topmost derived up to this BaseWindow
*/
static void
on_initialize_gtk_toplevel_class_handler( BaseWindow *window, GtkWindow *toplevel )
{
static const gchar *thisfn = "base_window_on_initialize_gtk_toplevel_class_handler";
g_return_if_fail( BASE_IS_WINDOW( window ));
g_debug( "%s: window=%p, toplevel=%p", thisfn, ( void * ) window, ( void * ) toplevel );
if( !window->private->dispose_has_run ){
if( BASE_WINDOW_GET_CLASS( window )->initialize_gtk_toplevel ){
BASE_WINDOW_GET_CLASS( window )->initialize_gtk_toplevel( window, toplevel );
}
}
}
static void
do_initialize_gtk_toplevel( BaseWindow *window, GtkWindow *toplevel )
{
static const gchar *thisfn = "base_window_do_initialize_gtk_toplevel";
GtkWindow *parent_gtk_toplevel;
g_return_if_fail( BASE_IS_WINDOW( window ));
g_return_if_fail( GTK_IS_WINDOW( toplevel ));
g_return_if_fail( toplevel == window->private->gtk_toplevel );
g_debug( "%s: window=%p, toplevel=%p", thisfn, ( void * ) window, ( void * ) toplevel );
if( !window->private->dispose_has_run ){
g_debug( "%s: parent=%p (%s)", thisfn,
( void * ) window->private->parent,
window->private->parent ? G_OBJECT_TYPE_NAME( window->private->parent ) : "null" );
if( window->private->parent ){
g_return_if_fail( BASE_IS_WINDOW( window->private->parent ));
parent_gtk_toplevel = base_window_get_gtk_toplevel( BASE_WINDOW( window->private->parent ));
gtk_window_set_transient_for( toplevel, parent_gtk_toplevel );
}
}
}
/*
* default class handler for "nact-signal-base-window-runtime-init" message
* -> does nothing here
*/
static void
on_initialize_base_window_class_handler( BaseWindow *window, gpointer user_data )
{
static const gchar *thisfn = "base_window_on_initialize_base_window_class_handler";
g_return_if_fail( BASE_IS_WINDOW( window ));
g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
if( !window->private->dispose_has_run ){
if( BASE_WINDOW_GET_CLASS( window )->runtime_init_toplevel ){
BASE_WINDOW_GET_CLASS( window )->runtime_init_toplevel( window, user_data );
}
}
}
static void
do_initialize_base_window( BaseWindow *window, gpointer user_data )
{
static const gchar *thisfn = "base_window_do_initialize_base_window";
g_return_if_fail( BASE_IS_WINDOW( window ));
g_debug( "%s: window=%p, user_data=%p, parent_window=%p",
thisfn, ( void * ) window, ( void * ) user_data, ( void * ) window->private->parent );
if( !window->private->dispose_has_run ){
base_iprefs_position_window( window );
}
}
static void
on_all_widgets_showed_class_handler( BaseWindow *window, gpointer user_data )
{
static const gchar *thisfn = "base_window_on_all_widgets_showed_class_handler";
g_return_if_fail( BASE_IS_WINDOW( window ));
g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
if( !window->private->dispose_has_run ){
if( BASE_WINDOW_GET_CLASS( window )->all_widgets_showed ){
BASE_WINDOW_GET_CLASS( window )->all_widgets_showed( window, user_data );
}
}
}
/**
* base_window_run:
* @window: this #BaseWindow object.
......@@ -749,6 +862,21 @@ base_window_run( BaseWindow *window )
return( run_ok ? BASE_EXIT_CODE_OK : BASE_EXIT_CODE_MAIN_WINDOW );
}
static gboolean
is_main_window( BaseWindow *window )
{
gboolean is_main = FALSE;
g_return_val_if_fail( BASE_IS_WINDOW( window ), FALSE );
if( !window->private->dispose_has_run ){
is_main = ( window == st_first_window );
}
return( is_main );
}
/**
* base_window_get_application:
* @window: this #BaseWindow object.
......@@ -935,118 +1063,6 @@ on_delete_event( GtkWidget *toplevel, GdkEvent *event, BaseWindow *window )
return( stop );
}
/*
* default class handler for "base-window-initialize-gtk" signal
*
* successively invokes the method of each derived class, starting from
* the topmost derived up to this BaseWindow
*/
static void
on_initialize_gtk_toplevel_class_handler( BaseWindow *window, gpointer user_data )
{
static const gchar *thisfn = "base_window_on_initialize_gtk_toplevel_class_handler";
GObjectClass *class;
g_return_if_fail( BASE_IS_WINDOW( window ));
g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
if( !window->private->dispose_has_run ){
for( class = G_OBJECT_GET_CLASS( window ) ; BASE_IS_WINDOW_CLASS( class ) ; class = g_type_class_peek_parent( class )){
if( BASE_WINDOW_CLASS( class )->initial_load_toplevel ){
BASE_WINDOW_CLASS( class )->initial_load_toplevel( window, user_data );
}
}
}
}
static void
do_initialize_gtk_toplevel( BaseWindow *window, gpointer user_data )
{
static const gchar *thisfn = "base_window_do_initialize_gtk_toplevel";
GtkWindow *parent_gtk_toplevel;
g_return_if_fail( BASE_IS_WINDOW( window ));
g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
if( !window->private->dispose_has_run ){
g_debug( "%s: parent=%p (%s)", thisfn,
( void * ) window->private->parent,
window->private->parent ? G_OBJECT_TYPE_NAME( window->private->parent ) : "null" );
if( window->private->parent ){
g_return_if_fail( BASE_IS_WINDOW( window->private->parent ));
parent_gtk_toplevel = base_window_get_gtk_toplevel( BASE_WINDOW( window->private->parent ));
g_debug( "%s: toplevel=%p, parent_gtk_toplevel=%p", thisfn, ( void * ) window->private->gtk_toplevel, ( void * ) parent_gtk_toplevel );
gtk_window_set_transient_for( window->private->gtk_toplevel, parent_gtk_toplevel );
}
}
}
/*
* default class handler for "nact-signal-base-window-runtime-init" message
* -> does nothing here
*/
static void
on_initialize_base_window_class_handler( BaseWindow *window, gpointer user_data )
{
static const gchar *thisfn = "base_window_on_initialize_base_window_class_handler";
GObjectClass *class;
g_return_if_fail( BASE_IS_WINDOW( window ));
g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
if( !window->private->dispose_has_run ){
for( class = G_OBJECT_GET_CLASS( window ) ; BASE_IS_WINDOW_CLASS( class ) ; class = g_type_class_peek_parent( class )){
if( BASE_WINDOW_CLASS( class )->runtime_init_toplevel ){
BASE_WINDOW_CLASS( class )->runtime_init_toplevel( window, user_data );
}
}
}
}
static void
do_initialize_base_window( BaseWindow *window, gpointer user_data )
{
static const gchar *thisfn = "base_window_do_initialize_base_window";
g_return_if_fail( BASE_IS_WINDOW( window ));
g_debug( "%s: window=%p, user_data=%p, parent_window=%p",
thisfn, ( void * ) window, ( void * ) user_data, ( void * ) window->private->parent );
if( !window->private->dispose_has_run ){
base_iprefs_position_window( window );
}
}
static void
on_all_widgets_showed_class_handler( BaseWindow *window, gpointer user_data )
{
static const gchar *thisfn = "base_window_on_all_widgets_showed_class_handler";
GObjectClass *class;
g_return_if_fail( BASE_IS_WINDOW( window ));
g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
if( !window->private->dispose_has_run ){
for( class = G_OBJECT_GET_CLASS( window ) ; BASE_IS_WINDOW_CLASS( class ) ; class = g_type_class_peek_parent( class )){
if( BASE_WINDOW_CLASS( class )->all_widgets_showed ){
BASE_WINDOW_CLASS( class )->all_widgets_showed( window, user_data );
}
}
}
}
static gboolean
v_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window )
{
......@@ -1139,31 +1155,6 @@ window_do_delete_event( BaseWindow *window, GtkWindow *toplevel, GdkEvent *event
return( FALSE );
}
static gboolean
window_do_is_willing_to_quit( const BaseWindow *window )
{
static const gchar *thisfn = "base_window_do_is_willing_to_quit";
g_debug( "%s: window=%p", thisfn, ( void * ) window );
return( TRUE );
}
static gboolean
is_main_window( BaseWindow *window )
{
gboolean is_main = FALSE;
g_return_val_if_fail( BASE_IS_WINDOW( window ), FALSE );
if( !window->private->dispose_has_run ){
is_main = ( window == st_first_window );
}
return( is_main );
}
/**
* base_window_display_error_dlg:
* @parent: the #BaseWindow parent, may be %NULL.
......
......@@ -94,9 +94,9 @@ typedef struct _BaseWindowClassPrivate BaseWindowClassPrivate;
/**
* BaseWindowClass:
* @initial_load_toplevel: initialize the toplevel GtkWindow
* @runtime_init_toplevel: initialize the BaseWindow
* @all_widgets_showed: all widgets have been showed
* @initialize_gtk_toplevel: initialize the toplevel GtkWindow
* @runtime_init_toplevel: initialize the BaseWindow
* @all_widgets_showed: all widgets have been showed
* @dialog_response:
* @delete_event:
* @get_toplevel_name:
......@@ -113,22 +113,21 @@ typedef struct {
/*< public >*/
/**
* initial_load_toplevel:
* initialize_gtk_toplevel:
* @window: this #BaseWindow instance.
* @user_data: not used
* @toplevel: the GtkWindow being initialized.
*
* Invoked when the toplevel GtkWindow is allocated for the firt time
* by the GtkBuilder, after all connected handlers have themselves run.
*
* The BaseWindow class takes care of successively invoking the
* initial_load_toplevel() method of each derived class, starting from
* the topmost derived class, up to the BaseWindow itself.
* The derived class should invoke the virtual method of its parent class
* at the end of its processing.
*
* The BaseWindow base class implementation of this method, which is
* so called last, set this GtkWindow toplevel window transient for
* its parent window.
*/
void ( *initial_load_toplevel )( BaseWindow *window, gpointer user_data );
void ( *initialize_gtk_toplevel )( BaseWindow *window, GtkWindow *toplevel );
/**
* runtime_init_toplevel:
......@@ -139,14 +138,13 @@ typedef struct {
* actually dsplaying the widget, and after all connected handlers
* have themselves run.
*
* The BaseWindow class takes care of successively invoking the
* runtime_init_toplevel() method of each derived class, starting from
* the topmost derived class, up to the BaseWindow itself.
* The derived class should invoke the virtual method of its parent class
* at the end of its processing.
*
* The BaseWindow base class implementation of this method, which is
* so called last, reset last size and position of the window.
*/
void ( *runtime_init_toplevel )( BaseWindow *window, gpointer user_data );
void ( *runtime_init_toplevel ) ( BaseWindow *window, gpointer user_data );
/**
* all_widgets_showed:
......@@ -156,9 +154,8 @@ typedef struct {
* Invoked at the end of initialization process, after all connected
* handlers have themselves run.
*
* The BaseWindow class takes care of successively invoking the
* all_widgets_showed() method of each derived class, starting from
* the topmost derived class, up to the BaseWindow itself.
* The derived class should invoke the virtual method of its parent class
* at the end of its processing.
*/
void ( *all_widgets_showed ) ( BaseWindow *window, gpointer user_data );
......
......@@ -168,7 +168,7 @@ static gboolean actually_delete_item( NactMainWindow *window, NAObject *item, NA
static gchar *base_get_toplevel_name( const BaseWindow *window );
static gchar *base_get_iprefs_window_id( const BaseWindow *window );
static gboolean base_is_willing_to_quit( const BaseWindow *window );
static void on_base_initial_load_toplevel( NactMainWindow *window, gpointer user_data );
static void on_base_initialize_gtk_toplevel( BaseWindow *window, GtkWindow *toplevel );
static void on_base_runtime_init_toplevel( NactMainWindow *window, gpointer user_data );
static void on_base_all_widgets_showed( NactMainWindow *window, gpointer user_data );
......@@ -395,6 +395,7 @@ class_init( NactMainWindowClass *klass )
klass->private = g_new0( NactMainWindowClassPrivate, 1 );
base_class = BASE_WINDOW_CLASS( klass );
base_class->initialize_gtk_toplevel = on_base_initialize_gtk_toplevel;
base_class->get_toplevel_name = base_get_toplevel_name;
base_class->get_iprefs_window_id = base_get_iprefs_window_id;
base_class->is_willing_to_quit = base_is_willing_to_quit;
......@@ -646,12 +647,6 @@ instance_init( GTypeInstance *instance, gpointer klass )
self->private = g_new0( NactMainWindowPrivate, 1 );
base_window_signal_connect(
BASE_WINDOW( instance ),
G_OBJECT( instance ),
BASE_SIGNAL_INITIALIZE_GTK,
G_CALLBACK( on_base_initial_load_toplevel ));
base_window_signal_connect(
BASE_WINDOW( instance ),
G_OBJECT( instance ),
......@@ -1135,9 +1130,10 @@ base_is_willing_to_quit( const BaseWindow *window )
* is the same than quitting the application
*/
static void
on_base_initial_load_toplevel( NactMainWindow *window, gpointer user_data )
on_base_initialize_gtk_toplevel( BaseWindow *window, GtkWindow *toplevel )
{
static const gchar *thisfn = "nact_main_window_on_base_initial_load_toplevel";
static const gchar *thisfn = "nact_main_window_on_base_initialize_gtk_toplevel";
NactMainWindow *main_window;
gint pos;
GtkWidget *pane;
NactApplication *application;
......@@ -1146,22 +1142,24 @@ on_base_initial_load_toplevel( NactMainWindow *window, gpointer user_data )
g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
if( !window->private->dispose_has_run ){
g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
main_window = NACT_MAIN_WINDOW( window );
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
if( !main_window->private->dispose_has_run ){
g_debug( "%s: window=%p, toplevel=%p", thisfn, ( void * ) window, ( void * ) toplevel );
application = NACT_APPLICATION( base_window_get_application( window ));
updater = nact_application_get_updater( application );
settings = na_pivot_get_settings( NA_PIVOT( updater ));
pos = na_settings_get_uint( settings, NA_IPREFS_MAIN_PANED, NULL, NULL );
if( pos ){
pane = base_window_get_widget( BASE_WINDOW( window ), "MainPaned" );
pane = base_window_get_widget( window, "MainPaned" );
gtk_paned_set_position( GTK_PANED( pane ), pos );
}
nact_iactions_list_set_management_mode( NACT_IACTIONS_LIST( window ), IACTIONS_LIST_MANAGEMENT_MODE_EDITION );
nact_iactions_list_initial_load_toplevel( NACT_IACTIONS_LIST( window ));
nact_sort_buttons_initial_load( window );
nact_sort_buttons_initial_load( main_window );
nact_iaction_tab_initial_load_toplevel( NACT_IACTION_TAB( window ));
nact_icommand_tab_initial_load_toplevel( NACT_ICOMMAND_TAB( window ));
......@@ -1174,7 +1172,7 @@ on_base_initial_load_toplevel( NactMainWindow *window, gpointer user_data )
nact_iexecution_tab_initial_load_toplevel( NACT_IEXECUTION_TAB( window ));
nact_iproperties_tab_initial_load_toplevel( NACT_IPROPERTIES_TAB( window ));
nact_main_statusbar_initial_load_toplevel( window );
nact_main_statusbar_initial_load_toplevel( main_window );
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment