]> git.sur5r.net Git - glabels/commitdiff
Moved all ui_component manipulation from mdi module to ui module.
authorJim Evins <evins@snaught.com>
Fri, 13 Sep 2002 03:28:10 +0000 (03:28 +0000)
committerJim Evins <evins@snaught.com>
Fri, 13 Sep 2002 03:28:10 +0000 (03:28 +0000)
gl_label_get_short_name() now removes ".glabels" extension.

git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@115 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/src/label.c
glabels2/src/mdi.c
glabels2/src/ui.c
glabels2/src/ui.h
glabels2/src/util.c
glabels2/src/util.h

index 00054d7c675d94eb8bc152c64789c7e8f4b777f6..e6dd71344667bea1e9b2b72e25350ce10de7fdc4 100644 (file)
@@ -532,13 +532,17 @@ gl_label_get_short_name (glLabel * label)
                        label->private->untitled_instance = ++untitled;
                }
 
-               return g_strdup_printf ( _("%s %d"), _("Untitled"),
+               return g_strdup_printf ( "%s %d", _("Untitled"),
                                         label->private->untitled_instance );
 
        } else {
+               gchar *temp_name, *short_name;
 
-               return g_path_get_basename ( label->private->filename );
+               temp_name = g_path_get_basename ( label->private->filename );
+               short_name = gl_util_remove_extension (temp_name);
+               g_free (temp_name);
 
+               return short_name;
        }
 }
 
index fcaac8eccc81fc9147c7f9dd745862112dbf9f55..a5ed4299bacf0378eef09939794837262068d257 100644 (file)
 #include "glabels.h"
 #include "ui.h"
 #include "prefs.h"
-#include "recent.h" 
 #include "file.h"
 #include "view.h"
 #include "debug.h"
-#include "gnome-recent-view.h"
 #include "alert.h"
 
 #include <bonobo/bonobo-ui-util.h>
 #include <bonobo/bonobo-control.h>
 
-#include <gconf/gconf-client.h>
-
 /*========================================================*/
 /* Private macros and constants.                          */
 /*========================================================*/
@@ -86,9 +82,6 @@ static void gl_mdi_init               (glMDI  *mdi);
 static void gl_mdi_finalize            (GObject        *object);
 
 static void gl_mdi_app_created_cb      (BonoboMDI *mdi, BonoboWindow *win);
-static void gl_mdi_set_app_main_toolbar_style   (BonoboWindow *win);
-static void gl_mdi_set_app_drawing_toolbar_style (BonoboWindow *win);
-static void gl_mdi_set_app_statusbar_style      (BonoboWindow *win);
 
 static gint gl_mdi_add_child_cb (BonoboMDI *mdi, BonoboMDIChild *child);
 static gint gl_mdi_add_view_cb (BonoboMDI *mdi, GtkWidget *view);
@@ -102,12 +95,6 @@ static void gl_mdi_child_state_changed_cb (glMDIChild *child);
 static void gl_mdi_set_active_window_undo_redo_verbs_sensitivity (BonoboMDI *mdi);
 static void gl_mdi_set_active_window_selection_verbs_sensitivity (BonoboMDI *mdi);
 
-static void gl_mdi_view_menu_item_toggled_cb (
-                       BonoboUIComponent           *ui_component,
-                       const char                  *path,
-                       Bonobo_UIComponent_EventType type,
-                       const char                  *state,
-                       BonoboWindow                *win);
 
 \f
 /*****************************************************************************/
@@ -247,429 +234,17 @@ gl_mdi_app_created_cb (BonoboMDI *mdi, BonoboWindow *win)
        GtkWidget *widget;
        BonoboControl *control;
        BonoboUIComponent *ui_component;
-        GnomeRecentView *view;
-        GnomeRecentModel *model;
-
-       static GtkTargetEntry drag_types[] =
-       {
-               { "text/uri-list", 0, 0 },
-       };
-
-       static gint n_drag_types =
-               sizeof (drag_types) / sizeof (drag_types [0]);
 
        gl_debug (DEBUG_MDI, "START");
        
        ui_component = bonobo_mdi_get_ui_component_from_window (win);
        g_return_if_fail (ui_component != NULL);
-       
-       /* Set the toolbar style according to prefs */
-       gl_mdi_set_app_main_toolbar_style (win);
-               
-       /* Add listener fo the view menu */
-       bonobo_ui_component_add_listener (ui_component, "ViewMainToolbar", 
-                       (BonoboUIListenerFn)gl_mdi_view_menu_item_toggled_cb, 
-                       (gpointer)win);
-
-       bonobo_ui_component_add_listener (ui_component, "MainToolbarSystem", 
-                       (BonoboUIListenerFn)gl_mdi_view_menu_item_toggled_cb, 
-                       (gpointer)win);
-       bonobo_ui_component_add_listener (ui_component, "MainToolbarIcon", 
-                       (BonoboUIListenerFn)gl_mdi_view_menu_item_toggled_cb, 
-                       (gpointer)win);
-       bonobo_ui_component_add_listener (ui_component, "MainToolbarIconText", 
-                       (BonoboUIListenerFn)gl_mdi_view_menu_item_toggled_cb, 
-                       (gpointer)win);
-       bonobo_ui_component_add_listener (ui_component, "MainToolbarTooltips", 
-                       (BonoboUIListenerFn)gl_mdi_view_menu_item_toggled_cb, 
-                       (gpointer)win);
-
-       /* Set the toolbar style according to prefs */
-       gl_mdi_set_app_drawing_toolbar_style (win);
-               
-       /* Add listener fo the view menu */
-       bonobo_ui_component_add_listener (ui_component, "ViewDrawingToolbar", 
-                       (BonoboUIListenerFn)gl_mdi_view_menu_item_toggled_cb, 
-                       (gpointer)win);
-
-       bonobo_ui_component_add_listener (ui_component, "DrawingToolbarSystem", 
-                       (BonoboUIListenerFn)gl_mdi_view_menu_item_toggled_cb, 
-                       (gpointer)win);
-       bonobo_ui_component_add_listener (ui_component, "DrawingToolbarIcon", 
-                       (BonoboUIListenerFn)gl_mdi_view_menu_item_toggled_cb, 
-                       (gpointer)win);
-       bonobo_ui_component_add_listener (ui_component, "DrawingToolbarIconText", 
-                       (BonoboUIListenerFn)gl_mdi_view_menu_item_toggled_cb, 
-                       (gpointer)win);
-       bonobo_ui_component_add_listener (ui_component, "DrawingToolbarTooltips", 
-                       (BonoboUIListenerFn)gl_mdi_view_menu_item_toggled_cb, 
-                       (gpointer)win);
-
-
-       gl_ui_set_verb_list_sensitive (ui_component, 
-                                      gl_ui_no_docs_sensible_verbs,
-                                      FALSE);
-
-        /* add a GeditRecentView object */
-        model = gl_recent_get_model ();
-        view = GNOME_RECENT_VIEW (gnome_recent_view_bonobo_new (ui_component,
-                                                               "/menu/File/Recents"));
-        gnome_recent_view_set_model (view, model);
-        
-        g_signal_connect (G_OBJECT (view), "activate",
-                          G_CALLBACK (gl_file_open_recent), win);
-
-       gl_debug (DEBUG_MDI, "END");
-}
-
-/*---------------------------------------------------------------------------*/
-/* Menu item togglded callback.                                              */
-/*---------------------------------------------------------------------------*/
-static void
-gl_mdi_view_menu_item_toggled_cb (
-                       BonoboUIComponent           *ui_component,
-                       const char                  *path,
-                       Bonobo_UIComponent_EventType type,
-                       const char                  *state,
-                       BonoboWindow                *win)
-{
-       gboolean s;
-
-       gl_debug (DEBUG_MDI, "%s toggled to '%s'", path, state);
-
-       s = (strcmp (state, "1") == 0);
-
-       if ((strcmp (path, "ViewMainToolbar") == 0) &&
-           (s != gl_prefs->main_toolbar_visible))
-       {
-               gl_prefs->main_toolbar_visible = s;
-               gl_mdi_set_app_main_toolbar_style (win);
-
-               return;
-       }
-
-       if (s && (strcmp (path, "MainToolbarSystem") == 0) &&
-           (gl_prefs->main_toolbar_buttons_style != GL_TOOLBAR_SYSTEM))
-       {               
-               gl_prefs->main_toolbar_buttons_style = GL_TOOLBAR_SYSTEM;
-               gl_mdi_set_app_main_toolbar_style (win);
-
-               return;
-       }
-
-       if (s && (strcmp (path, "MainToolbarIcon") == 0) &&
-           (gl_prefs->main_toolbar_buttons_style != GL_TOOLBAR_ICONS))
-       {               
-               gl_prefs->main_toolbar_buttons_style = GL_TOOLBAR_ICONS;
-               gl_mdi_set_app_main_toolbar_style (win);
-
-               return;
-       }
-
-       if (s && (strcmp (path, "MainToolbarIconText") == 0) &&
-           (gl_prefs->main_toolbar_buttons_style != GL_TOOLBAR_ICONS_AND_TEXT))
-       {               
-               gl_prefs->main_toolbar_buttons_style = GL_TOOLBAR_ICONS_AND_TEXT;
-               gl_mdi_set_app_main_toolbar_style (win);
-
-               return;
-       }
-
-       if ((strcmp (path, "MainToolbarTooltips") == 0) &&
-           (s != gl_prefs->main_toolbar_view_tooltips))
-       {
-               gl_prefs->main_toolbar_view_tooltips = s;
-               gl_mdi_set_app_main_toolbar_style (win);
-
-               return;
-       }
-
-       if ((strcmp (path, "ViewDrawingToolbar") == 0) &&
-           (s != gl_prefs->drawing_toolbar_visible))
-       {
-               gl_prefs->drawing_toolbar_visible = s;
-               gl_mdi_set_app_drawing_toolbar_style (win);
-
-               return;
-       }
-
-       if (s && (strcmp (path, "DrawingToolbarSystem") == 0) &&
-           (gl_prefs->drawing_toolbar_buttons_style != GL_TOOLBAR_SYSTEM))
-       {               
-               gl_prefs->drawing_toolbar_buttons_style = GL_TOOLBAR_SYSTEM;
-               gl_mdi_set_app_drawing_toolbar_style (win);
-
-               return;
-       }
-
-       if (s && (strcmp (path, "DrawingToolbarIcon") == 0) &&
-           (gl_prefs->drawing_toolbar_buttons_style != GL_TOOLBAR_ICONS))
-       {               
-               gl_prefs->drawing_toolbar_buttons_style = GL_TOOLBAR_ICONS;
-               gl_mdi_set_app_drawing_toolbar_style (win);
-
-               return;
-       }
-
-       if (s && (strcmp (path, "DrawingToolbarIconText") == 0) &&
-           (gl_prefs->drawing_toolbar_buttons_style != GL_TOOLBAR_ICONS_AND_TEXT))
-       {               
-               gl_prefs->drawing_toolbar_buttons_style = GL_TOOLBAR_ICONS_AND_TEXT;
-               gl_mdi_set_app_drawing_toolbar_style (win);
-
-               return;
-       }
-
-       if ((strcmp (path, "DrawingToolbarTooltips") == 0) &&
-           (s != gl_prefs->drawing_toolbar_view_tooltips))
-       {
-               gl_prefs->drawing_toolbar_view_tooltips = s;
-               gl_mdi_set_app_drawing_toolbar_style (win);
 
-               return;
-       }
-
-}
-
-/*---------------------------------------------------------------------------*/
-/* Set main toolbar style.                                                   */
-/*---------------------------------------------------------------------------*/
-static void
-gl_mdi_set_app_main_toolbar_style (BonoboWindow *win)
-{
-       BonoboUIComponent *ui_component;
-       GConfClient *client;
-       gboolean labels;
-
-       gl_debug (DEBUG_MDI, "START");
-       
-       g_return_if_fail (BONOBO_IS_WINDOW (win));
-                       
-       ui_component = bonobo_mdi_get_ui_component_from_window (win);
-       g_return_if_fail (ui_component != NULL);
-                       
-       bonobo_ui_component_freeze (ui_component, NULL);
-
-       /* Updated view menu */
-       gl_ui_set_verb_state (ui_component, 
-                             "/commands/ViewMainToolbar",
-                             gl_prefs->main_toolbar_visible);
-
-       gl_ui_set_verb_sensitive (ui_component, 
-                                 "/commands/MainToolbarSystem",
-                                 gl_prefs->main_toolbar_visible);
-       gl_ui_set_verb_sensitive (ui_component, 
-                                 "/commands/MainToolbarIcon",
-                                 gl_prefs->main_toolbar_visible);
-       gl_ui_set_verb_sensitive (ui_component, 
-                                 "/commands/MainToolbarIconText",
-                                 gl_prefs->main_toolbar_visible);
-       gl_ui_set_verb_sensitive (ui_component, 
-                                 "/commands/MainToolbarTooltips",
-                                 gl_prefs->main_toolbar_visible);
-
-       gl_ui_set_verb_state (ui_component, 
-                             "/commands/MainToolbarSystem",
-                             gl_prefs->main_toolbar_buttons_style == GL_TOOLBAR_SYSTEM);
-
-       gl_ui_set_verb_state (ui_component, 
-                             "/commands/MainToolbarIcon",
-                             gl_prefs->main_toolbar_buttons_style == GL_TOOLBAR_ICONS);
-
-       gl_ui_set_verb_state (ui_component, 
-                             "/commands/MainToolbarIconText",
-                             gl_prefs->main_toolbar_buttons_style == GL_TOOLBAR_ICONS_AND_TEXT);
-
-       gl_ui_set_verb_state (ui_component, 
-                             "/commands/MainToolbarTooltips",
-                             gl_prefs->main_toolbar_view_tooltips);
-
-       
-       /* Actually update main_toolbar style */
-       bonobo_ui_component_set_prop (
-               ui_component, "/MainToolbar",
-               "tips", gl_prefs->main_toolbar_view_tooltips ? "1" : "0",
-               NULL);
-       
-       switch (gl_prefs->main_toolbar_buttons_style)
-       {
-               case GL_TOOLBAR_SYSTEM:
-                                               
-                       client = gconf_client_get_default ();
-                       if (client == NULL) 
-                               goto error;
-
-                       labels = gconf_client_get_bool (client, 
-                                       "/desktop/gnome/interface/toolbar-labels", NULL);
-
-                       g_object_unref (G_OBJECT (client));
-                       
-                       if (labels)
-                       {                       
-                               gl_debug (DEBUG_MDI, "SYSTEM: BOTH");
-                               bonobo_ui_component_set_prop (
-                                       ui_component, "/MainToolbar", "look", "both", NULL);
-                       
-                       }
-                       else
-                       {
-                               gl_debug (DEBUG_MDI, "SYSTEM: ICONS");
-                               bonobo_ui_component_set_prop (
-                                       ui_component, "/MainToolbar", "look", "icons", NULL);
-                       }
-       
-                       break;
-                       
-               case GL_TOOLBAR_ICONS:
-                       gl_debug (DEBUG_MDI, "GLABELS: ICONS");
-                       bonobo_ui_component_set_prop (
-                               ui_component, "/MainToolbar", "look", "icon", NULL);
-                       
-                       break;
-                       
-               case GL_TOOLBAR_ICONS_AND_TEXT:
-                       gl_debug (DEBUG_MDI, "GLABELS: ICONS_AND_TEXT");
-                       bonobo_ui_component_set_prop (
-                               ui_component, "/MainToolbar", "look", "both", NULL);
-                       
-                       break;
-               default:
-                       goto error;
-                       break;
-       }
-       
-       bonobo_ui_component_set_prop (
-                       ui_component, "/MainToolbar",
-                       "hidden", gl_prefs->main_toolbar_visible ? "0":"1", NULL);
-
- error:
-       bonobo_ui_component_thaw (ui_component, NULL);
+       gl_ui_init (ui_component, win);
 
        gl_debug (DEBUG_MDI, "END");
 }
 
-
-/*---------------------------------------------------------------------------*/
-/* Set drawing toolbar style.                                                   */
-/*---------------------------------------------------------------------------*/
-static void
-gl_mdi_set_app_drawing_toolbar_style (BonoboWindow *win)
-{
-       BonoboUIComponent *ui_component;
-       GConfClient *client;
-       gboolean labels;
-
-       gl_debug (DEBUG_MDI, "START");
-       
-       g_return_if_fail (BONOBO_IS_WINDOW (win));
-                       
-       ui_component = bonobo_mdi_get_ui_component_from_window (win);
-       g_return_if_fail (ui_component != NULL);
-                       
-       bonobo_ui_component_freeze (ui_component, NULL);
-
-       /* Updated view menu */
-       gl_ui_set_verb_state (ui_component, 
-                             "/commands/ViewDrawingToolbar",
-                             gl_prefs->drawing_toolbar_visible);
-
-       gl_ui_set_verb_sensitive (ui_component, 
-                                 "/commands/DrawingToolbarSystem",
-                                 gl_prefs->drawing_toolbar_visible);
-       gl_ui_set_verb_sensitive (ui_component, 
-                                 "/commands/DrawingToolbarIcon",
-                                 gl_prefs->drawing_toolbar_visible);
-       gl_ui_set_verb_sensitive (ui_component, 
-                                 "/commands/DrawingToolbarIconText",
-                                 gl_prefs->drawing_toolbar_visible);
-       gl_ui_set_verb_sensitive (ui_component, 
-                                 "/commands/DrawingToolbarTooltips",
-                                 gl_prefs->drawing_toolbar_visible);
-
-       gl_ui_set_verb_state (
-               ui_component, 
-               "/commands/DrawingToolbarSystem",
-               gl_prefs->drawing_toolbar_buttons_style == GL_TOOLBAR_SYSTEM);
-
-       gl_ui_set_verb_state (
-               ui_component, 
-               "/commands/DrawingToolbarIcon",
-               gl_prefs->drawing_toolbar_buttons_style == GL_TOOLBAR_ICONS);
-
-       gl_ui_set_verb_state (
-               ui_component, 
-               "/commands/DrawingToolbarIconText",
-               gl_prefs->drawing_toolbar_buttons_style == GL_TOOLBAR_ICONS_AND_TEXT);
-
-       gl_ui_set_verb_state (ui_component, 
-                             "/commands/DrawingToolbarTooltips",
-                             gl_prefs->drawing_toolbar_view_tooltips);
-
-       
-       /* Actually update drawing_toolbar style */
-       bonobo_ui_component_set_prop (
-               ui_component, "/DrawingToolbar",
-               "tips", gl_prefs->drawing_toolbar_view_tooltips ? "1" : "0",
-               NULL);
-       
-       switch (gl_prefs->drawing_toolbar_buttons_style)
-       {
-               case GL_TOOLBAR_SYSTEM:
-                                               
-                       client = gconf_client_get_default ();
-                       if (client == NULL) 
-                               goto error;
-
-                       labels = gconf_client_get_bool (client, 
-                                       "/desktop/gnome/interface/toolbar-labels", NULL);
-
-                       g_object_unref (G_OBJECT (client));
-                       
-                       if (labels)
-                       {                       
-                               gl_debug (DEBUG_MDI, "SYSTEM: BOTH");
-                               bonobo_ui_component_set_prop (
-                                       ui_component, "/DrawingToolbar", "look", "both", NULL);
-                       
-                       }
-                       else
-                       {
-                               gl_debug (DEBUG_MDI, "SYSTEM: ICONS");
-                               bonobo_ui_component_set_prop (
-                                       ui_component, "/DrawingToolbar", "look", "icons", NULL);
-                       }
-       
-                       break;
-                       
-               case GL_TOOLBAR_ICONS:
-                       gl_debug (DEBUG_MDI, "GLABELS: ICONS");
-                       bonobo_ui_component_set_prop (
-                               ui_component, "/DrawingToolbar", "look", "icon", NULL);
-                       
-                       break;
-                       
-               case GL_TOOLBAR_ICONS_AND_TEXT:
-                       gl_debug (DEBUG_MDI, "GLABELS: ICONS_AND_TEXT");
-                       bonobo_ui_component_set_prop (
-                               ui_component, "/DrawingToolbar", "look", "both", NULL);
-                       
-                       break;
-               default:
-                       goto error;
-                       break;
-       }
-       
-       bonobo_ui_component_set_prop (
-                       ui_component, "/DrawingToolbar",
-                       "hidden", gl_prefs->drawing_toolbar_visible ? "0":"1", NULL);
-
- error:
-       bonobo_ui_component_thaw (ui_component, NULL);
-
-       gl_debug (DEBUG_MDI, "END");
-}
-
-
 /*---------------------------------------------------------------------------*/
 /* Child state changed callback.                                             */
 /*---------------------------------------------------------------------------*/
@@ -810,11 +385,11 @@ gl_mdi_remove_child_cb (BonoboMDI *mdi, BonoboMDIChild *child)
                }
 
                
-               gtk_dialog_add_button (GTK_DIALOG (msgbox), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+               gtk_dialog_add_button (GTK_DIALOG (msgbox),
+                                      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
 
                gtk_dialog_add_button (GTK_DIALOG (msgbox),
-                               GTK_STOCK_SAVE,
-                               GTK_RESPONSE_YES);
+                                      GTK_STOCK_SAVE, GTK_RESPONSE_YES);
 
                gtk_dialog_set_default_response (GTK_DIALOG (msgbox), GTK_RESPONSE_YES);
 
@@ -842,22 +417,6 @@ gl_mdi_remove_child_cb (BonoboMDI *mdi, BonoboMDIChild *child)
                gl_debug (DEBUG_MDI, "CLOSE: %s", close ? "TRUE" : "FALSE");
        }
        
-       /* FIXME: there is a bug if you "close all" >1 docs, don't save the document
-        * and then don't close the last one.
-        */
-       /* Disable to avoid the bug */
-       /*
-       if (close)
-       {
-               g_signal_handlers_disconnect_by_func (child, 
-                                                     G_CALLBACK (gl_mdi_child_state_changed_cb),
-                                                     NULL);
-               g_signal_handlers_disconnect_by_func (GTK_OBJECT (child), 
-                                                     G_CALLBACK (gl_mdi_child_undo_redo_state_changed_cb),
-                                                     NULL);
-       }
-       */
-       
        gl_debug (DEBUG_MDI, "END");
        return close;
 }
@@ -959,12 +518,9 @@ void gl_mdi_view_changed_cb (BonoboMDI *mdi, GtkWidget *old_view)
 void 
 gl_mdi_set_active_window_verbs_sensitivity (BonoboMDI *mdi)
 {
-       /* FIXME: it is too slooooooow! - Paolo */
-
        BonoboWindow      *active_window = NULL;
        BonoboMDIChild    *active_child = NULL;
        glView            *view = NULL;
-       glLabel           *doc = NULL;
        BonoboUIComponent *ui_component;
        
        gl_debug (DEBUG_MDI, "START");
@@ -978,52 +534,16 @@ gl_mdi_set_active_window_verbs_sensitivity (BonoboMDI *mdi)
        g_return_if_fail (ui_component != NULL);
        
        active_child = bonobo_mdi_get_active_child (mdi);
-       
-       bonobo_ui_component_freeze (ui_component, NULL);
-       
+
        if (active_child == NULL)
        {
-               gl_ui_set_verb_list_sensitive (ui_component, 
-                                              gl_ui_no_docs_sensible_verbs,
-                                              FALSE);
-               goto end;
-       }
-       else
-       {
-               gl_ui_set_verb_list_sensitive (ui_component, 
-                                              gl_ui_all_sensible_verbs,
-                                              TRUE);
+               gl_ui_update_nodoc (ui_component);
+               return;
        }
 
-       doc = GL_MDI_CHILD (active_child)->label;
-       g_return_if_fail (doc != NULL);
-
-       if (!gl_label_can_undo (doc))
-               gl_ui_set_verb_sensitive (ui_component,
-                                         "/commands/EditUndo",
-                                         FALSE);
-
-       if (!gl_label_can_redo (doc))
-               gl_ui_set_verb_sensitive (ui_component,
-                                         "/commands/EditRedo",
-                                         FALSE);
-
-       gl_ui_set_verb_list_sensitive (ui_component, 
-                                      gl_ui_not_modified_doc_sensible_verbs,
-                                      gl_label_is_modified (doc));
-
        view = GL_VIEW (bonobo_mdi_get_active_view (mdi));
-       g_return_if_fail (view != NULL);
 
-       gl_ui_set_verb_list_sensitive (ui_component,
-                                      gl_ui_selection_sensible_verbs,
-                                      !gl_view_is_selection_empty (view));
-       gl_ui_set_verb_list_sensitive (ui_component,
-                                      gl_ui_atomic_selection_sensible_verbs,
-                                      gl_view_is_selection_atomic (view));
-
-end:
-       bonobo_ui_component_thaw (ui_component, NULL);
+       gl_ui_update_all (ui_component, view);
 
        gl_debug (DEBUG_MDI, "END");
 }
@@ -1052,15 +572,7 @@ gl_mdi_set_active_window_undo_redo_verbs_sensitivity (BonoboMDI *mdi)
        doc = GL_MDI_CHILD (active_child)->label;
        g_return_if_fail (doc != NULL);
 
-       bonobo_ui_component_freeze (ui_component, NULL);
-
-       gl_ui_set_verb_sensitive (ui_component, "/commands/EditUndo", 
-                                 gl_label_can_undo (doc));     
-
-       gl_ui_set_verb_sensitive (ui_component, "/commands/EditRedo", 
-                                 gl_label_can_redo (doc));     
-
-       bonobo_ui_component_thaw (ui_component, NULL);
+       gl_ui_update_undo_redo_verbs (ui_component, doc);
 
        gl_debug (DEBUG_MDI, "END");
 }
@@ -1086,16 +598,7 @@ gl_mdi_set_active_window_selection_verbs_sensitivity (BonoboMDI *mdi)
        view = GL_VIEW (bonobo_mdi_get_active_view (mdi));
        g_return_if_fail (view != NULL);
 
-       bonobo_ui_component_freeze (ui_component, NULL);
-
-       gl_ui_set_verb_list_sensitive (ui_component,
-                                      gl_ui_selection_sensible_verbs,
-                                      !gl_view_is_selection_empty (view));
-       gl_ui_set_verb_list_sensitive (ui_component,
-                                      gl_ui_atomic_selection_sensible_verbs,
-                                      gl_view_is_selection_atomic (view));
-
-       bonobo_ui_component_thaw (ui_component, NULL);
+       gl_ui_update_selection_verbs (ui_component, view);
 
        gl_debug (DEBUG_MDI, "END");
 }
index 61fad4d40cb47e8225943aa93bb8b7c061eca403..efe5103dfe7b988b32143926bcaea8a346f0eecd 100644 (file)
  */
 #include <config.h>
 
+#include "gnome-recent-view.h"
+#include <gconf/gconf-client.h>
+
 #include "ui.h"
 #include "commands.h"
 #include "tools.h"
 #include "glabels.h"
+#include "recent.h" 
+#include "file.h"
+#include "prefs.h"
 
+/*===========================================*/
+/* Public globals                            */
+/*===========================================*/
 BonoboUIVerb gl_ui_verbs [] = {
        BONOBO_UI_VERB ("FileNew", gl_cmd_file_new),
        BONOBO_UI_VERB ("FileOpen", gl_cmd_file_open),
@@ -70,7 +79,21 @@ BonoboUIVerb gl_ui_verbs [] = {
        BONOBO_UI_VERB_END
 };
 
-gchar* gl_ui_no_docs_sensible_verbs [] = {
+/*========================================================*/
+/* Private macros and constants.                          */
+/*========================================================*/
+
+
+/*========================================================*/
+/* Private types.                                         */
+/*========================================================*/
+
+
+/*===========================================*/
+/* Private globals                           */
+/*===========================================*/
+
+static gchar* doc_verbs [] = {
        "/commands/FileSave",
        "/commands/FileSaveAs",
        "/commands/FilePrint",
@@ -103,13 +126,13 @@ gchar* gl_ui_no_docs_sensible_verbs [] = {
        NULL
 };
 
-gchar* gl_ui_not_modified_doc_sensible_verbs [] = {
+static gchar* doc_modified_verbs [] = {
        "/commands/FileSave",
 
        NULL
 };
 
-gchar* gl_ui_selection_sensible_verbs [] = {
+static gchar* selection_verbs [] = {
        "/commands/EditCut",
        "/commands/EditCopy",
        "/commands/EditDelete",
@@ -120,197 +143,580 @@ gchar* gl_ui_selection_sensible_verbs [] = {
        NULL
 };
 
-gchar* gl_ui_atomic_selection_sensible_verbs [] = {
+static gchar* atomic_selection_verbs [] = {
        "/commands/ToolsObjectProperties",
 
        NULL
 };
 
 
-void
-gl_ui_set_verb_sensitive (BonoboUIComponent  *ui_component,
-                         gchar              *cname,
-                         gboolean            sensitive)
+/*===========================================*/
+/* Local function prototypes                 */
+/*===========================================*/
+
+static void view_menu_item_toggled_cb (
+                       BonoboUIComponent           *ui_component,
+                       const char                  *path,
+                       Bonobo_UIComponent_EventType type,
+                       const char                  *state,
+                       BonoboWindow                *win);
+
+static void set_app_main_toolbar_style          (BonoboWindow *win);
+static void set_app_drawing_toolbar_style (BonoboWindow *win);
+
+static void
+set_verb_sensitive (BonoboUIComponent  *ui_component,
+                   gchar              *cname,
+                   gboolean            sensitive);
+static void
+set_verb_list_sensitive (BonoboUIComponent   *ui_component,
+                        gchar              **vlist,
+                        gboolean             sensitive);
+static void
+set_verb_state (BonoboUIComponent   *ui_component,
+               gchar               *cname,
+               gboolean             state);
+
+
+\f
+/*****************************************************************************/
+/* Initialize UI component for given window.                                 */
+/*****************************************************************************/
+void gl_ui_init   (BonoboUIComponent *ui_component,
+                  BonoboWindow      *win)
 {
-       g_return_if_fail (cname != NULL);
-       g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
+        GnomeRecentView *recent_view;
+        GnomeRecentModel *recent_model;
+
+       g_return_if_fail (ui_component != NULL);
+
+       /* Set the toolbar style according to prefs */
+       set_app_main_toolbar_style (win);
+               
+       /* Add listener fo the view menu */
+       bonobo_ui_component_add_listener (ui_component, "ViewMainToolbar", 
+                       (BonoboUIListenerFn)view_menu_item_toggled_cb, 
+                       (gpointer)win);
+
+       bonobo_ui_component_add_listener (ui_component, "MainToolbarSystem", 
+                       (BonoboUIListenerFn)view_menu_item_toggled_cb, 
+                       (gpointer)win);
+       bonobo_ui_component_add_listener (ui_component, "MainToolbarIcon", 
+                       (BonoboUIListenerFn)view_menu_item_toggled_cb, 
+                       (gpointer)win);
+       bonobo_ui_component_add_listener (ui_component, "MainToolbarIconText", 
+                       (BonoboUIListenerFn)view_menu_item_toggled_cb, 
+                       (gpointer)win);
+       bonobo_ui_component_add_listener (ui_component, "MainToolbarTooltips", 
+                       (BonoboUIListenerFn)view_menu_item_toggled_cb, 
+                       (gpointer)win);
+
+       /* Set the toolbar style according to prefs */
+       set_app_drawing_toolbar_style (win);
+               
+       /* Add listener fo the view menu */
+       bonobo_ui_component_add_listener (ui_component, "ViewDrawingToolbar", 
+                       (BonoboUIListenerFn)view_menu_item_toggled_cb, 
+                       (gpointer)win);
+
+       bonobo_ui_component_add_listener (ui_component, "DrawingToolbarSystem", 
+                       (BonoboUIListenerFn)view_menu_item_toggled_cb, 
+                       (gpointer)win);
+       bonobo_ui_component_add_listener (ui_component, "DrawingToolbarIcon", 
+                       (BonoboUIListenerFn)view_menu_item_toggled_cb, 
+                       (gpointer)win);
+       bonobo_ui_component_add_listener (ui_component, "DrawingToolbarIconText", 
+                       (BonoboUIListenerFn)view_menu_item_toggled_cb, 
+                       (gpointer)win);
+       bonobo_ui_component_add_listener (ui_component, "DrawingToolbarTooltips", 
+                       (BonoboUIListenerFn)view_menu_item_toggled_cb, 
+                       (gpointer)win);
+
+
+       set_verb_list_sensitive (ui_component, doc_verbs, FALSE);
+
+        /* add a GeditRecentView object */
+        recent_model = gl_recent_get_model ();
+        recent_view  =
+               GNOME_RECENT_VIEW (gnome_recent_view_bonobo_new (ui_component,
+                                                                "/menu/File/Recents"));
+        gnome_recent_view_set_model (recent_view, recent_model);
+        
+        g_signal_connect (G_OBJECT (recent_view), "activate",
+                          G_CALLBACK (gl_file_open_recent), win);
 
-       bonobo_ui_component_set_prop (ui_component,
-                                     cname,
-                                     "sensitive",
-                                     sensitive ? "1" : "0",
-                                     NULL);
 }
 
-void
-gl_ui_set_verb_list_sensitive (BonoboUIComponent   *ui_component,
-                              gchar              **vlist,
-                              gboolean             sensitive)
+/*****************************************************************************/
+/* Update all verbs of given UI component.                                   */
+/*****************************************************************************/
+void gl_ui_update_all (BonoboUIComponent *ui_component,
+                      glView            *view)
 {
-       g_return_if_fail (vlist != NULL);
-       g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
+       glLabel *label;
 
-       for ( ; *vlist; ++vlist)
-       {
-               bonobo_ui_component_set_prop (ui_component,
-                                             *vlist,
-                                             "sensitive",
-                                             sensitive ? "1" : "0",
-                                             NULL);
-       }
+       bonobo_ui_component_freeze (ui_component, NULL);
+
+       set_verb_list_sensitive (ui_component, doc_verbs, TRUE);
+
+       label = view->label;
+       g_return_if_fail (label != NULL);
+
+       set_verb_sensitive (ui_component,
+                           "/commands/EditUndo", gl_label_can_undo (label));
+
+       set_verb_sensitive (ui_component,
+                           "/commands/EditRedo", gl_label_can_redo (label));
+
+       set_verb_list_sensitive (ui_component, 
+                                doc_modified_verbs,
+                                gl_label_is_modified (label));
+
+       set_verb_list_sensitive (ui_component,
+                                selection_verbs,
+                                !gl_view_is_selection_empty (view));
+
+       set_verb_list_sensitive (ui_component,
+                                atomic_selection_verbs,
+                                gl_view_is_selection_atomic (view));
+
+       bonobo_ui_component_thaw (ui_component, NULL);
 }
 
-void
-gl_ui_set_verb_state (BonoboUIComponent   *ui_component,
-                     gchar               *cname,
-                     gboolean             state)
+/*****************************************************************************/
+/* Update all verbs of given UI component to "no document" state.            */
+/*****************************************************************************/
+void gl_ui_update_nodoc           (BonoboUIComponent *ui_component)
 {
-       g_return_if_fail (cname != NULL);
-       g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
+       bonobo_ui_component_freeze (ui_component, NULL);
+       
+       set_verb_list_sensitive (ui_component, doc_verbs, FALSE);
 
-       bonobo_ui_component_set_prop (ui_component,
-                                     cname,
-                                     "state",
-                                     state ? "1" : "0",
-                                     NULL);
+       bonobo_ui_component_thaw (ui_component, NULL);
 }
 
-void
-gl_ui_add_menu_item (BonoboWindow   *window,
-                    const gchar    *path,
-                    const gchar    *name,
-                    const gchar    *label,
-                    const gchar    *tooltip,
-                    const gchar    *stock_pixmap,
-                    BonoboUIVerbFn  cb)
+/*****************************************************************************/
+/* Update undo/redo verbs of given UI component.                             */
+/*****************************************************************************/
+void gl_ui_update_undo_redo_verbs (BonoboUIComponent *ui_component,
+                                  glLabel           *label)
 {
-       BonoboUIComponent *ui_component;
-       gchar *item_path;
-       gchar *cmd;
+       bonobo_ui_component_freeze (ui_component, NULL);
 
-       g_return_if_fail (window != NULL);
-       g_return_if_fail (path != NULL);
-       g_return_if_fail (label != NULL);
-       g_return_if_fail (cb != NULL);
-       
-       item_path = g_strconcat (path, name, NULL);
-       ui_component =
-               bonobo_mdi_get_ui_component_from_window (BONOBO_WINDOW (window));
-       if (!bonobo_ui_component_path_exists (ui_component, item_path, NULL)) {
-               gchar *xml;
-
-               xml = g_strdup_printf ("<menuitem name=\"%s\" verb=\"\""
-                                      " _label=\"%s\""
-                                      " _tip=\"%s\" hident=\"0\" />", name,
-                                      label, tooltip);
-
-
-               if (stock_pixmap != NULL) {
-                       cmd = g_strdup_printf ("<cmd name=\"%s\""
-                               " pixtype=\"stock\" pixname=\"%s\" />",
-                               name, stock_pixmap);
-               }
-               else {
-                       cmd = g_strdup_printf ("<cmd name=\"%s\" />", name);
-               }
-
-
-               bonobo_ui_component_set_translate (ui_component,
-                                                  path,
-                                                  xml,
-                                                  NULL);
-
-               bonobo_ui_component_set_translate (ui_component,
-                                                  "/commands/",
-                                                  cmd,
-                                                  NULL);
-                                                  
-               bonobo_ui_component_add_verb (ui_component, name, cb, NULL);
-
-               g_free (xml);
-               g_free (cmd);
-       }
+       set_verb_sensitive (ui_component,
+                           "/commands/EditUndo", gl_label_can_undo (label));
 
-       g_free (item_path);
+       set_verb_sensitive (ui_component,
+                           "/commands/EditRedo", gl_label_can_redo (label));
+
+       bonobo_ui_component_thaw (ui_component, NULL);
 }
 
-void
-gl_ui_remove_menu_item (BonoboWindow *window,
-                       const gchar  *path,
-                       const gchar  *name)
+/*****************************************************************************/
+/* Update verbs associated with selection state of given UI component.       */
+/*****************************************************************************/
+void gl_ui_update_selection_verbs (BonoboUIComponent *ui_component,
+                                  glView            *view)
 {
-       BonoboUIComponent *ui_component;
-       gchar *item_path;
+       bonobo_ui_component_freeze (ui_component, NULL);
 
-       g_return_if_fail (window != NULL);
-       g_return_if_fail (path != NULL);
-       g_return_if_fail (name != NULL);
+       set_verb_list_sensitive (ui_component,
+                                selection_verbs,
+                                !gl_view_is_selection_empty (view));
 
-       item_path = g_strconcat (path, name, NULL);
-       ui_component =
-               bonobo_mdi_get_ui_component_from_window (BONOBO_WINDOW (window));
+       set_verb_list_sensitive (ui_component,
+                                atomic_selection_verbs,
+                                gl_view_is_selection_atomic (view));
 
-       if (bonobo_ui_component_path_exists (ui_component, item_path, NULL)) {
-               gchar *cmd;
+       bonobo_ui_component_thaw (ui_component, NULL);
+}
 
-               cmd = g_strdup_printf ("/commands/%s", name);
-               
-               bonobo_ui_component_rm (ui_component, item_path, NULL);
-               bonobo_ui_component_rm (ui_component, cmd, NULL);
-               
-               g_free (cmd);
+/*---------------------------------------------------------------------------*/
+/* PRIVATE.  View menu item toggled callback.                                */
+/*---------------------------------------------------------------------------*/
+static void
+view_menu_item_toggled_cb (BonoboUIComponent           *ui_component,
+                          const char                  *path,
+                          Bonobo_UIComponent_EventType type,
+                          const char                  *state,
+                          BonoboWindow                *win)
+{
+       gboolean s;
+
+       s = (strcmp (state, "1") == 0);
+
+       if ((strcmp (path, "ViewMainToolbar") == 0) &&
+           (s != gl_prefs->main_toolbar_visible))
+       {
+               gl_prefs->main_toolbar_visible = s;
+               set_app_main_toolbar_style (win);
+
+               return;
+       }
+
+       if (s && (strcmp (path, "MainToolbarSystem") == 0) &&
+           (gl_prefs->main_toolbar_buttons_style != GL_TOOLBAR_SYSTEM))
+       {               
+               gl_prefs->main_toolbar_buttons_style = GL_TOOLBAR_SYSTEM;
+               set_app_main_toolbar_style (win);
+
+               return;
+       }
+
+       if (s && (strcmp (path, "MainToolbarIcon") == 0) &&
+           (gl_prefs->main_toolbar_buttons_style != GL_TOOLBAR_ICONS))
+       {               
+               gl_prefs->main_toolbar_buttons_style = GL_TOOLBAR_ICONS;
+               set_app_main_toolbar_style (win);
+
+               return;
+       }
+
+       if (s && (strcmp (path, "MainToolbarIconText") == 0) &&
+           (gl_prefs->main_toolbar_buttons_style != GL_TOOLBAR_ICONS_AND_TEXT))
+       {               
+               gl_prefs->main_toolbar_buttons_style = GL_TOOLBAR_ICONS_AND_TEXT;
+               set_app_main_toolbar_style (win);
+
+               return;
+       }
+
+       if ((strcmp (path, "MainToolbarTooltips") == 0) &&
+           (s != gl_prefs->main_toolbar_view_tooltips))
+       {
+               gl_prefs->main_toolbar_view_tooltips = s;
+               set_app_main_toolbar_style (win);
+
+               return;
+       }
+
+       if ((strcmp (path, "ViewDrawingToolbar") == 0) &&
+           (s != gl_prefs->drawing_toolbar_visible))
+       {
+               gl_prefs->drawing_toolbar_visible = s;
+               set_app_drawing_toolbar_style (win);
+
+               return;
+       }
+
+       if (s && (strcmp (path, "DrawingToolbarSystem") == 0) &&
+           (gl_prefs->drawing_toolbar_buttons_style != GL_TOOLBAR_SYSTEM))
+       {               
+               gl_prefs->drawing_toolbar_buttons_style = GL_TOOLBAR_SYSTEM;
+               set_app_drawing_toolbar_style (win);
+
+               return;
+       }
+
+       if (s && (strcmp (path, "DrawingToolbarIcon") == 0) &&
+           (gl_prefs->drawing_toolbar_buttons_style != GL_TOOLBAR_ICONS))
+       {               
+               gl_prefs->drawing_toolbar_buttons_style = GL_TOOLBAR_ICONS;
+               set_app_drawing_toolbar_style (win);
+
+               return;
+       }
+
+       if (s && (strcmp (path, "DrawingToolbarIconText") == 0) &&
+           (gl_prefs->drawing_toolbar_buttons_style != GL_TOOLBAR_ICONS_AND_TEXT))
+       {               
+               gl_prefs->drawing_toolbar_buttons_style = GL_TOOLBAR_ICONS_AND_TEXT;
+               set_app_drawing_toolbar_style (win);
+
+               return;
+       }
+
+       if ((strcmp (path, "DrawingToolbarTooltips") == 0) &&
+           (s != gl_prefs->drawing_toolbar_view_tooltips))
+       {
+               gl_prefs->drawing_toolbar_view_tooltips = s;
+               set_app_drawing_toolbar_style (win);
+
+               return;
        }
 
-       g_free (item_path);
 }
 
-void
-gl_ui_add_menu_item_all (const gchar    *path,
-                        const gchar    *name,
-                        const gchar    *label,
-                        const gchar    *tooltip,
-                        const gchar    *stock_pixmap,
-                        BonoboUIVerbFn  cb)
+/*---------------------------------------------------------------------------*/
+/* PRIVATE.  Set main toolbar style.                                         */
+/*---------------------------------------------------------------------------*/
+static void
+set_app_main_toolbar_style (BonoboWindow *win)
 {
-       GList* top_windows;
+       BonoboUIComponent *ui_component;
+       GConfClient *client;
+       gboolean labels;
+
+       g_return_if_fail (BONOBO_IS_WINDOW (win));
+                       
+       ui_component = bonobo_mdi_get_ui_component_from_window (win);
+       g_return_if_fail (ui_component != NULL);
+                       
+       bonobo_ui_component_freeze (ui_component, NULL);
+
+       /* Updated view menu */
+       set_verb_state (ui_component, 
+                       "/commands/ViewMainToolbar",
+                       gl_prefs->main_toolbar_visible);
+
+       set_verb_sensitive (ui_component, 
+                           "/commands/MainToolbarSystem",
+                           gl_prefs->main_toolbar_visible);
+       set_verb_sensitive (ui_component, 
+                           "/commands/MainToolbarIcon",
+                           gl_prefs->main_toolbar_visible);
+       set_verb_sensitive (ui_component, 
+                           "/commands/MainToolbarIconText",
+                           gl_prefs->main_toolbar_visible);
+       set_verb_sensitive (ui_component, 
+                           "/commands/MainToolbarTooltips",
+                           gl_prefs->main_toolbar_visible);
+
+       set_verb_state (ui_component, 
+                       "/commands/MainToolbarSystem",
+                       gl_prefs->main_toolbar_buttons_style == GL_TOOLBAR_SYSTEM);
+
+       set_verb_state (ui_component, 
+                       "/commands/MainToolbarIcon",
+                       gl_prefs->main_toolbar_buttons_style == GL_TOOLBAR_ICONS);
+
+       set_verb_state (ui_component, 
+                       "/commands/MainToolbarIconText",
+                       gl_prefs->main_toolbar_buttons_style == GL_TOOLBAR_ICONS_AND_TEXT);
+
+       set_verb_state (ui_component, 
+                       "/commands/MainToolbarTooltips",
+                       gl_prefs->main_toolbar_view_tooltips);
+
+       
+       /* Actually update main_toolbar style */
+       bonobo_ui_component_set_prop (
+               ui_component, "/MainToolbar",
+               "tips", gl_prefs->main_toolbar_view_tooltips ? "1" : "0",
+               NULL);
        
-       top_windows = glabels_get_top_windows ();
-       g_return_if_fail (top_windows != NULL);
-       
-       while (top_windows)
+       switch (gl_prefs->main_toolbar_buttons_style)
        {
-               BonoboWindow* window = BONOBO_WINDOW (top_windows->data);
+               case GL_TOOLBAR_SYSTEM:
+                                               
+                       client = gconf_client_get_default ();
+                       if (client == NULL) 
+                               goto error;
+
+                       labels = gconf_client_get_bool (client, 
+                                       "/desktop/gnome/interface/toolbar-labels", NULL);
+
+                       g_object_unref (G_OBJECT (client));
+                       
+                       if (labels)
+                       {                       
+                               bonobo_ui_component_set_prop (
+                                       ui_component, "/MainToolbar", "look", "both", NULL);
+                       
+                       }
+                       else
+                       {
+                               bonobo_ui_component_set_prop (
+                                       ui_component, "/MainToolbar", "look", "icons", NULL);
+                       }
+       
+                       break;
+                       
+               case GL_TOOLBAR_ICONS:
+                       bonobo_ui_component_set_prop (
+                               ui_component, "/MainToolbar", "look", "icon", NULL);
+                       
+                       break;
+                       
+               case GL_TOOLBAR_ICONS_AND_TEXT:
+                       bonobo_ui_component_set_prop (
+                               ui_component, "/MainToolbar", "look", "both", NULL);
+                       
+                       break;
+               default:
+                       goto error;
+                       break;
+       }
+       
+       bonobo_ui_component_set_prop (
+                       ui_component, "/MainToolbar",
+                       "hidden", gl_prefs->main_toolbar_visible ? "0":"1", NULL);
 
+ error:
+       bonobo_ui_component_thaw (ui_component, NULL);
 
-               gl_ui_add_menu_item (window,
-                                    path,
-                                    name,
-                                    label,
-                                    tooltip,
-                                    stock_pixmap,
-                                    cb);
-               
-               top_windows = g_list_next (top_windows);
-       }
 }
 
-void
-gl_ui_remove_menu_item_all (const gchar *path,
-                           const gchar *name)
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE.  Set drawing toolbar style.                                      */
+/*---------------------------------------------------------------------------*/
+static void
+set_app_drawing_toolbar_style (BonoboWindow *win)
 {
-       GList* top_windows;
+       BonoboUIComponent *ui_component;
+       GConfClient *client;
+       gboolean labels;
+
+       
+       g_return_if_fail (BONOBO_IS_WINDOW (win));
+                       
+       ui_component = bonobo_mdi_get_ui_component_from_window (win);
+       g_return_if_fail (ui_component != NULL);
+                       
+       bonobo_ui_component_freeze (ui_component, NULL);
+
+       /* Updated view menu */
+       set_verb_state (ui_component, 
+                       "/commands/ViewDrawingToolbar",
+                       gl_prefs->drawing_toolbar_visible);
+
+       set_verb_sensitive (ui_component, 
+                           "/commands/DrawingToolbarSystem",
+                           gl_prefs->drawing_toolbar_visible);
+       set_verb_sensitive (ui_component, 
+                           "/commands/DrawingToolbarIcon",
+                           gl_prefs->drawing_toolbar_visible);
+       set_verb_sensitive (ui_component, 
+                           "/commands/DrawingToolbarIconText",
+                           gl_prefs->drawing_toolbar_visible);
+       set_verb_sensitive (ui_component, 
+                           "/commands/DrawingToolbarTooltips",
+                           gl_prefs->drawing_toolbar_visible);
+
+       set_verb_state (
+               ui_component, 
+               "/commands/DrawingToolbarSystem",
+               gl_prefs->drawing_toolbar_buttons_style == GL_TOOLBAR_SYSTEM);
+
+       set_verb_state (
+               ui_component, 
+               "/commands/DrawingToolbarIcon",
+               gl_prefs->drawing_toolbar_buttons_style == GL_TOOLBAR_ICONS);
+
+       set_verb_state (
+               ui_component, 
+               "/commands/DrawingToolbarIconText",
+               gl_prefs->drawing_toolbar_buttons_style == GL_TOOLBAR_ICONS_AND_TEXT);
+
+       set_verb_state (ui_component, 
+                       "/commands/DrawingToolbarTooltips",
+                       gl_prefs->drawing_toolbar_view_tooltips);
+
        
-       top_windows = glabels_get_top_windows ();
-       g_return_if_fail (top_windows != NULL);
-       
-       while (top_windows)
+       /* Actually update drawing_toolbar style */
+       bonobo_ui_component_set_prop (
+               ui_component, "/DrawingToolbar",
+               "tips", gl_prefs->drawing_toolbar_view_tooltips ? "1" : "0",
+               NULL);
+       
+       switch (gl_prefs->drawing_toolbar_buttons_style)
        {
-               BonoboWindow* window = BONOBO_WINDOW (top_windows->data);
+               case GL_TOOLBAR_SYSTEM:
+                                               
+                       client = gconf_client_get_default ();
+                       if (client == NULL) 
+                               goto error;
+
+                       labels = gconf_client_get_bool (client, 
+                                       "/desktop/gnome/interface/toolbar-labels", NULL);
+
+                       g_object_unref (G_OBJECT (client));
+                       
+                       if (labels)
+                       {                       
+                               bonobo_ui_component_set_prop (
+                                       ui_component, "/DrawingToolbar", "look", "both", NULL);
+                       
+                       }
+                       else
+                       {
+                               bonobo_ui_component_set_prop (
+                                       ui_component, "/DrawingToolbar", "look", "icons", NULL);
+                       }
+       
+                       break;
+                       
+               case GL_TOOLBAR_ICONS:
+                       bonobo_ui_component_set_prop (
+                               ui_component, "/DrawingToolbar", "look", "icon", NULL);
+                       
+                       break;
+                       
+               case GL_TOOLBAR_ICONS_AND_TEXT:
+                       bonobo_ui_component_set_prop (
+                               ui_component, "/DrawingToolbar", "look", "both", NULL);
+                       
+                       break;
+               default:
+                       goto error;
+                       break;
+       }
+       
+       bonobo_ui_component_set_prop (
+                       ui_component, "/DrawingToolbar",
+                       "hidden", gl_prefs->drawing_toolbar_visible ? "0":"1", NULL);
 
+ error:
+       bonobo_ui_component_thaw (ui_component, NULL);
 
-               gl_ui_remove_menu_item (window, path, name);
+}
 
-               
-               top_windows = g_list_next (top_windows);
+
+/*---------------------------------------------------------------------------*/
+/* Set sensitivity of verb.                                                  */
+/*---------------------------------------------------------------------------*/
+static void
+set_verb_sensitive (BonoboUIComponent  *ui_component,
+                   gchar              *cname,
+                   gboolean            sensitive)
+{
+       g_return_if_fail (cname != NULL);
+       g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
+
+       bonobo_ui_component_set_prop (ui_component,
+                                     cname,
+                                     "sensitive",
+                                     sensitive ? "1" : "0",
+                                     NULL);
+}
+
+/*---------------------------------------------------------------------------*/
+/* Set sensitivity of a list of verbs.                                       */
+/*---------------------------------------------------------------------------*/
+static void
+set_verb_list_sensitive (BonoboUIComponent   *ui_component,
+                        gchar              **vlist,
+                        gboolean             sensitive)
+{
+       g_return_if_fail (vlist != NULL);
+       g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
+
+       for ( ; *vlist; ++vlist)
+       {
+               bonobo_ui_component_set_prop (ui_component,
+                                             *vlist,
+                                             "sensitive",
+                                             sensitive ? "1" : "0",
+                                             NULL);
        }
 }
+
+/*---------------------------------------------------------------------------*/
+/* Set state of a verb.                                                      */
+/*---------------------------------------------------------------------------*/
+static void
+set_verb_state (BonoboUIComponent   *ui_component,
+               gchar               *cname,
+               gboolean             state)
+{
+       g_return_if_fail (cname != NULL);
+       g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
+
+       bonobo_ui_component_set_prop (ui_component,
+                                     cname,
+                                     "state",
+                                     state ? "1" : "0",
+                                     NULL);
+}
+
index 36ecad44b197ffe65da400bd24aaf3136a78f231..541ae121dbc1604b3f884a53c37d093cb8d44979 100644 (file)
 #include <bonobo/bonobo-ui-engine.h>
 #include <bonobo/bonobo-window.h>
 
-extern BonoboUIVerb gl_ui_verbs [];
-
-extern gchar *gl_ui_no_docs_sensible_verbs []; 
-extern gchar *gl_ui_not_modified_doc_sensible_verbs []; 
-extern gchar *gl_ui_selection_sensible_verbs [];
-extern gchar *gl_ui_atomic_selection_sensible_verbs [];
-
-#define gl_ui_all_sensible_verbs gl_ui_no_docs_sensible_verbs
-
-void gl_ui_set_verb_sensitive          (BonoboUIComponent *ui_component,
-                                        gchar             *cname,
-                                        gboolean           sensitive);
-void gl_ui_set_verb_list_sensitive     (BonoboUIComponent *ui_component, 
-                                        gchar            **vlist,
-                                        gboolean           sensitive);
-void gl_ui_set_verb_state              (BonoboUIComponent *ui_component, 
-                                        gchar* cname, 
-                                        gboolean state);
-
-/* convenience functions for plugins */
+#include "view.h"
 
-void gl_ui_add_menu_item        (BonoboWindow   *window,
-                                const gchar    *path,
-                                const gchar    *name,
-                                const gchar    *label,
-                                const gchar    *tooltip,
-                                const gchar    *stock_pixmap,
-                                BonoboUIVerbFn  cb);
-
-void gl_ui_remove_menu_item     (BonoboWindow   *window,
-                                const gchar    *path,
-                                const gchar    *name);
-
-
-void gl_ui_add_menu_item_all    (const gchar    *path,
-                                const gchar    *name,
-                                const gchar    *label,
-                                const gchar    *tooltip,
-                                const gchar    *stock_pixmap,
-                                BonoboUIVerbFn  cb);
+extern BonoboUIVerb gl_ui_verbs [];
 
-void gl_ui_remove_menu_item_all (const gchar    *path,
-                                const gchar    *name);
 
+extern void gl_ui_init                   (BonoboUIComponent *ui_component,
+                                         BonoboWindow      *win);
+extern void gl_ui_update_all             (BonoboUIComponent *ui_component,
+                                         glView            *view);
+extern void gl_ui_update_nodoc           (BonoboUIComponent *ui_component);
+extern void gl_ui_update_undo_redo_verbs (BonoboUIComponent *ui_component,
+                                         glLabel           *label);
+extern void gl_ui_update_selection_verbs (BonoboUIComponent *ui_component,
+                                         glView            *view);
 
 #endif /* __GL_UI_H__ */
index 7e6172732f63780ef52f770868551102ca529405..c73fac36f4680befec82294c5b1634f7cbe4ebec 100644 (file)
@@ -55,6 +55,26 @@ gl_util_add_extension (const gchar * orig_filename)
        return new_filename;
 }
 
+/****************************************************************************/
+/* Remove ".glabels" extension from filename if needed.                     */
+/****************************************************************************/
+gchar *
+gl_util_remove_extension (const gchar * orig_filename)
+{
+       gchar *new_filename, *extension;
+
+       new_filename = g_strdup (orig_filename);
+
+       extension = strrchr (new_filename, '.');
+       if (extension != NULL) {
+               if (g_strcasecmp (extension, ".glabels") == 0) {
+                       *extension = 0; /* truncate string, rm extension */
+               }
+       }
+
+       return new_filename;
+}
+
 /****************************************************************************/
 /* Make sure we have an absolute path to filename.                          */
 /****************************************************************************/
index 2b3961a0c1f4fa11508561ba76f201511fb73041..fa62437b401eaaa6e3bc5a2cb5a148d547ba465c 100644 (file)
@@ -27,6 +27,7 @@
 #include <libgnomeprint/gnome-font.h>
 
 extern gchar *gl_util_add_extension (const gchar * orig_filename);
+extern gchar *gl_util_remove_extension (const gchar * orig_filename);
 
 extern gchar *gl_util_make_absolute (const gchar * filename);