Index: app/interface.c =================================================================== --- app/interface.c (revision 4086) +++ app/interface.c (working copy) @@ -253,6 +253,7 @@ GtkToolbar * toolbar; GtkNotebook * diagram_notebook; GtkStatusbar * statusbar; + GtkWidget * layer_view; } ui; /*static*/ GtkTooltips *tool_tips; @@ -1616,6 +1617,8 @@ GtkAccelGroup *accel_group; GdkPixbuf *pixbuf; + GtkWidget *layer_view; + #ifdef GNOME window = gnome_app_new ("Dia", _("Diagram Editor")); #else @@ -1657,6 +1660,10 @@ gtk_box_pack_end (GTK_BOX (main_vbox), hbox, TRUE, TRUE, 0); gtk_widget_show (hbox); + /* Layer View */ + layer_view = create_layer_view_widget (); + gtk_box_pack_end (GTK_BOX (hbox), layer_view, FALSE, FALSE, 0); + /* Diagram Notebook */ notebook = gtk_notebook_new (); gtk_box_pack_end (GTK_BOX (hbox), notebook, TRUE, TRUE, 0); @@ -1715,6 +1722,7 @@ ui.toolbar = GTK_TOOLBAR (toolbar); ui.diagram_notebook = GTK_NOTEBOOK (notebook); ui.statusbar = GTK_STATUSBAR (statusbar); + ui.layer_view = layer_view; /* NOTE: These functions use ui.xxx assignments above and so must come after * the user interface components are set. */ @@ -1889,6 +1897,46 @@ } } +/* Indicate if the integrated UI Layer View is showing. + * @return TRUE if showing, FALSE if not showing or doesn't exist + */ +gboolean integrated_ui_layer_view_is_showing (void) +{ + if (ui.layer_view) + { + return GTK_WIDGET_VISIBLE (ui.layer_view)? TRUE : FALSE; + } + return FALSE; +} + +void integrated_ui_layer_view_show (void) +{ + if (ui.layer_view) + { + GtkAction *action = NULL; + gtk_widget_show (ui.layer_view); + action = menus_get_action (VIEW_LAYERS_ACTION); + if (action) + { + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); + } + } +} + +void integrated_ui_layer_view_hide (void) +{ + if (ui.layer_view) + { + GtkAction *action = NULL; + gtk_widget_hide (ui.layer_view); + action = menus_get_action (VIEW_LAYERS_ACTION); + if (action) + { + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), FALSE); + } + } +} + /* Indicate if the integrated UI statusbar is showing. * @return TRUE if showing, FALSE if not showing or doesn't exist */ Index: app/commands.c =================================================================== --- app/commands.c (revision 4086) +++ app/commands.c (working copy) @@ -1047,7 +1047,20 @@ } } +void +view_layers_callback (GtkAction *action) +{ + if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION(action)) == TRUE) + { + integrated_ui_layer_view_show (); + } + else + { + integrated_ui_layer_view_hide (); + } +} + void objects_place_over_callback (GtkAction *action) { Index: app/interface.h =================================================================== --- app/interface.h (revision 4086) +++ app/interface.h (working copy) @@ -53,6 +53,10 @@ void integrated_ui_main_statusbar_show (void); void integrated_ui_main_statusbar_hide (void); +gboolean integrated_ui_layer_view_is_showing (void); +void integrated_ui_layer_view_show (void); +void integrated_ui_layer_view_hide (void); + int is_integrated_ui (void); void create_display_shell(DDisplay *ddisp, Index: app/commands.h =================================================================== --- app/commands.h (revision 4086) +++ app/commands.h (working copy) @@ -63,8 +63,10 @@ void view_redraw_callback (GtkAction *action); void view_diagram_properties_callback (GtkAction *action); +/* Integrated UI callbacks */ void view_main_toolbar_callback (GtkAction *action); void view_main_statusbar_callback (GtkAction *action); +void view_layers_callback (GtkAction *action); void objects_place_over_callback (GtkAction *action); void objects_place_under_callback (GtkAction *action); Index: app/app_procs.c =================================================================== --- app/app_procs.c (revision 4086) +++ app/app_procs.c (working copy) @@ -802,11 +802,14 @@ if( prefs.use_integrated_ui ) create_integrated_ui(); else + { create_toolbox(); persistence_register_window_create("layer_window", (NullaryFunc*)&create_layer_dialog); + } + /*fill recent file menu */ recent_file_history_init(); Index: app/layer_dialog.c =================================================================== --- app/layer_dialog.c (revision 4086) +++ app/layer_dialog.c (working copy) @@ -40,6 +40,15 @@ #include "dia-app-icons.h" +struct LayerDialog { + GtkWidget *dialog; + GtkWidget *diagram_omenu; + + GtkWidget *layer_list; + + Diagram *diagram; +}; + static struct LayerDialog *layer_dialog = NULL; typedef struct _ButtonData ButtonData; @@ -121,7 +130,7 @@ #define INSENSITIVE 2 static GtkWidget * -create_button_box(GtkWidget *parent) +create_button_box(GtkWidget *parent, gboolean show_labels) { GtkWidget *button; GtkWidget *button_box; @@ -130,7 +139,22 @@ button_box = gtk_hbox_new (TRUE, 1); for (i=0;ibuttons[i] = button; - gtk_widget_show (button); } @@ -202,6 +224,95 @@ return TRUE; } +void layer_view_hide_button_clicked (void * not_used) +{ + integrated_ui_layer_view_hide (); +} + +GtkWidget * create_layer_view_widget (void) +{ + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *label; + GtkWidget *hide_button; + GtkRcStyle *rcstyle; /* For hide_button */ + GtkWidget *image; /* For hide_button */ + GtkWidget *list; + GtkWidget *separator; + GtkWidget *scrolled_win; + GtkWidget *button_box; + + /* if layer_dialog were renamed to layer_view_data this would make + * more sense. + */ + layer_dialog = g_new (struct LayerDialog, 1); + + layer_dialog->diagram = NULL; + + layer_dialog->dialog = vbox = gtk_vbox_new (FALSE, 1); + + hbox = gtk_hbox_new (FALSE, 1); + + label = gtk_label_new (_ ("Layers:")); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 2); + gtk_widget_show (label); + + layer_dialog->diagram_omenu = NULL; + + /* Hide Button */ + hide_button = gtk_button_new (); + gtk_button_set_relief (GTK_BUTTON (hide_button), GTK_RELIEF_NONE); + gtk_button_set_focus_on_click (GTK_BUTTON (hide_button), FALSE); + + /* make it as small as possible */ + rcstyle = gtk_rc_style_new (); + rcstyle->xthickness = rcstyle->ythickness = 0; + gtk_widget_modify_style (hide_button, rcstyle); + gtk_rc_style_unref (rcstyle); + + image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, + GTK_ICON_SIZE_MENU); + + gtk_container_add (GTK_CONTAINER(hide_button), image); + gtk_signal_connect (GTK_OBJECT (hide_button), "clicked", + GTK_SIGNAL_FUNC (layer_view_hide_button_clicked), NULL); + + gtk_box_pack_start (GTK_BOX (hbox), hide_button, FALSE, FALSE, 2); + + gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 2); + gtk_widget_show_all (hbox); + + button_box = create_button_box(vbox, FALSE); + + gtk_box_pack_start (GTK_BOX (vbox), button_box, FALSE, FALSE, 2); + gtk_widget_show (button_box); + + separator = gtk_hseparator_new(); + gtk_box_pack_start(GTK_BOX(vbox), separator, FALSE, FALSE, 2); + gtk_widget_show (separator); + + scrolled_win = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + gtk_box_pack_start (GTK_BOX (vbox), scrolled_win, TRUE, TRUE, 2); + + layer_dialog->layer_list = list = gtk_list_new(); + + gtk_list_set_selection_mode (GTK_LIST (list), GTK_SELECTION_BROWSE); + gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_win), list); + gtk_container_set_focus_vadjustment (GTK_CONTAINER (list), + gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolled_win))); + gtk_widget_show (scrolled_win); + gtk_widget_show (list); + + g_signal_connect (GTK_OBJECT (list), "event", + (GtkSignalFunc) layer_list_events, + NULL); + + return vbox; +} + void create_layer_dialog(void) { @@ -273,7 +384,7 @@ (GtkSignalFunc) layer_list_events, NULL); - button_box = create_button_box(dialog); + button_box = create_button_box(dialog, TRUE); gtk_box_pack_start (GTK_BOX (vbox), button_box, FALSE, FALSE, 2); gtk_widget_show (button_box); @@ -521,6 +632,11 @@ int i; int current_nr; + if (layer_dialog->diagram_omenu == NULL) + { + return; + } + if (layer_dialog == NULL || layer_dialog->dialog == NULL) { if (!dia_open_diagrams()) return; /* shortcut; maybe session end w/o this dialog */ @@ -591,9 +707,12 @@ void layer_dialog_show() { + if (is_integrated_ui () == FALSE) + { if (layer_dialog == NULL || layer_dialog->dialog == NULL) create_layer_dialog(); gtk_window_present(GTK_WINDOW(layer_dialog->dialog)); + } } /* @@ -631,7 +750,7 @@ layer_dialog->diagram = dia; if (dia != NULL) { i = g_list_index(dia_open_diagrams(), dia); - if (i >= 0) + if (i >= 0 && layer_dialog->diagram_omenu != NULL) gtk_option_menu_set_history(GTK_OPTION_MENU(layer_dialog->diagram_omenu), i); } Index: app/layer_dialog.h =================================================================== --- app/layer_dialog.h (revision 4086) +++ app/layer_dialog.h (working copy) @@ -21,22 +21,14 @@ #include #include "diagram.h" -struct LayerDialog { - GtkWidget *dialog; - GtkWidget *diagram_omenu; - GtkWidget *layer_list; - - Diagram *diagram; - - GtkWidget *buttons[4]; -}; - void create_layer_dialog(void); void layer_dialog_update_diagram_list(void); void layer_dialog_show(void); void layer_dialog_set_diagram(Diagram *dia); +/* Integrated UI component */ +GtkWidget * create_layer_view_widget (void); /* DiaLayerWidget: */ #define DIA_LAYER_WIDGET(obj) \ Index: app/menus.c =================================================================== --- app/menus.c (revision 4086) +++ app/menus.c (working copy) @@ -99,7 +99,8 @@ static const GtkToggleActionEntry integrated_ui_view_toggle_entries[] = { { VIEW_MAIN_TOOLBAR_ACTION, NULL, N_("Show Toolbar"), NULL, NULL, G_CALLBACK (view_main_toolbar_callback) }, - { VIEW_MAIN_STATUSBAR_ACTION, NULL, N_("Show Statusbar"), NULL, NULL, G_CALLBACK (view_main_statusbar_callback) } + { VIEW_MAIN_STATUSBAR_ACTION, NULL, N_("Show Statusbar"), NULL, NULL, G_CALLBACK (view_main_statusbar_callback) }, + { VIEW_LAYERS_ACTION, NULL, N_("Show Layers"), NULL, NULL, G_CALLBACK (view_layers_callback) } }; /* Actions for diagram window */ Index: app/menus.h =================================================================== --- app/menus.h (revision 4086) +++ app/menus.h (working copy) @@ -112,6 +112,7 @@ #define VIEW_MAIN_TOOLBAR_ACTION "ViewMainToolbar" #define VIEW_MAIN_STATUSBAR_ACTION "ViewMainStatusbar" +#define VIEW_LAYERS_ACTION "ViewLayers" #endif /* MENUS_H */ Index: data/integrated-ui.xml =================================================================== --- data/integrated-ui.xml (revision 4086) +++ data/integrated-ui.xml (working copy) @@ -49,7 +49,6 @@ - @@ -72,6 +71,7 @@ +