diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/gtkext/gtkdockstation.c | 25 | ||||
| -rw-r--r-- | src/gtkext/gtkdockstation.h | 3 | ||||
| -rw-r--r-- | src/gui/panels/panel.c | 62 | 
3 files changed, 87 insertions, 3 deletions
diff --git a/src/gtkext/gtkdockstation.c b/src/gtkext/gtkdockstation.c index 68c8e1d..e087377 100644 --- a/src/gtkext/gtkdockstation.c +++ b/src/gtkext/gtkdockstation.c @@ -64,6 +64,22 @@ G_DEFINE_TYPE(GtkDockStation, gtk_dock_station, GTK_TYPE_VBOX)  static void gtk_dock_station_class_init(GtkDockStationClass *class)  { +    g_signal_new("dock-widget", +                 GTK_TYPE_DOCK_STATION, +                 G_SIGNAL_RUN_LAST, +                 G_STRUCT_OFFSET(GtkDockStationClass, dock_widget), +                 NULL, NULL, +                 g_cclosure_user_marshal_VOID__OBJECT, +                 G_TYPE_NONE, 1, GTK_TYPE_WIDGET); + +    g_signal_new("undock-widget", +                 GTK_TYPE_DOCK_STATION, +                 G_SIGNAL_RUN_LAST, +                 G_STRUCT_OFFSET(GtkDockStationClass, undock_widget), +                 NULL, NULL, +                 g_cclosure_user_marshal_VOID__OBJECT, +                 G_TYPE_NONE, 1, GTK_TYPE_WIDGET); +      g_signal_new("switch-widget",                   GTK_TYPE_DOCK_STATION,                   G_SIGNAL_RUN_LAST, @@ -238,6 +254,8 @@ void gtk_dock_panel_add_widget(GtkDockStation *station, GtkWidget *widget, const      gtk_notebook_set_current_page(station->notebook, -1); +    g_signal_emit_by_name(station, "dock-widget", widget); +  } @@ -303,12 +321,17 @@ void gtk_dock_panel_change_active_widget(GtkDockStation *station, GtkWidget *wid  void gtk_dock_panel_remove_widget(GtkDockStation *station, GtkWidget *widget)  {      gint index;                             /* Indice de l'onglet visé     */ +    gint count;                             /* Nombre d'onglets en place   */      index = gtk_notebook_page_num(station->notebook, widget);      gtk_notebook_remove_page(station->notebook, index); -    if (gtk_notebook_get_n_pages(station->notebook) == 0) +    count = gtk_notebook_get_n_pages(station->notebook); + +    gtk_notebook_set_show_tabs(station->notebook, count > 1); + +    if (count == 0)          gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(GTK_WIDGET(station))),                               GTK_WIDGET(station)); diff --git a/src/gtkext/gtkdockstation.h b/src/gtkext/gtkdockstation.h index c285dc7..192fdf2 100644 --- a/src/gtkext/gtkdockstation.h +++ b/src/gtkext/gtkdockstation.h @@ -61,6 +61,9 @@ struct _GtkDockStationClass      /* Signaux */ +    void (* dock_widget) (GtkDockStation *, GtkWidget *); +    void (* undock_widget) (GtkDockStation *, GtkWidget *); +      void (* switch_widget) (GtkDockStation *, GtkWidget *);  }; diff --git a/src/gui/panels/panel.c b/src/gui/panels/panel.c index 2749545..6ccf14a 100644 --- a/src/gui/panels/panel.c +++ b/src/gui/panels/panel.c @@ -50,6 +50,7 @@ static GCallback _handler;  static gpointer _data;  /* Liste des panneaux en place. */ +static GPanelItem *_welcome = NULL;  static GPanelItem *_panels_list = NULL; @@ -111,6 +112,15 @@ static void set_panel_node_size_request(const panel_node *, const GtkRequisition + +/* Surveille les ajouts dans la partie principale. */ +static void on_docking_to_main_panel(GtkDockStation *, GtkWidget *, gpointer); + + + + + +  /* Indique le type défini pour un élément destiné à un panneau. */  G_DEFINE_TYPE(GPanelItem, g_panel_item, G_TYPE_EDITOR_ITEM); @@ -352,8 +362,11 @@ void load_main_panels(GObject *ref)  {      GPanelItem *item;                       /* Panneau de base à charger   */ -    item = create_welcome_panel(ref); -    g_panel_item_dock(item); +    _welcome = create_welcome_panel(ref); +    g_panel_item_dock(_welcome); + +    g_signal_connect(_nodes->station, "dock-widget", +                     G_CALLBACK(on_docking_to_main_panel), NULL);      item = create_log_panel(ref);      g_panel_item_dock(item); @@ -370,6 +383,7 @@ void load_main_panels(GObject *ref)  } +  /* ---------------------------------------------------------------------------------- */  /*                        MECANISMES DE PLACEMENT DES PANNEAUX                        */  /* ---------------------------------------------------------------------------------- */ @@ -1033,3 +1047,47 @@ static void set_panel_node_size_request(const panel_node *node, const GtkRequisi      set_panel_node_size_request(node->second, ALLOC_2_REQ(&allocation));  } + + + + + +/* ---------------------------------------------------------------------------------- */ +/*                        MECANISMES DE PLACEMENT DES PANNEAUX                        */ +/* ---------------------------------------------------------------------------------- */ + + + + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : station = base d'accueil pour composants divers.             * +*                widget  = composant rajouté à l'ensemble.                    * +*                data    = adresse non utilisée ici.                          * +*                                                                             * +*  Description : Surveille les ajouts dans la partie principale.              * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void on_docking_to_main_panel(GtkDockStation *station, GtkWidget *widget, gpointer data) +{ + + +    printf("docking.... %p\n", widget); + + +    g_panel_item_undock(_welcome); + + + +    g_signal_handlers_disconnect_by_func(station, +                                         G_CALLBACK(on_docking_to_main_panel), NULL); + + +} +  | 
