]> git.sur5r.net Git - glabels/blobdiff - glabels2/src/ui.c
2009-09-17 Jim Evins <evins@snaught.com>
[glabels] / glabels2 / src / ui.c
index 9703cfc41355f6e050ff9ee52b5394f05f4aa9ab..62b67d4ecc56a87d56b837be2da05e7f1172e8c6 100644 (file)
@@ -1,34 +1,31 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
 /*
- *  (GLABELS) Label and Business Card Creation program for GNOME
- *
- *  ui.c:  GLabels ui module
+ *  ui.c
+ *  Copyright (C) 2001-2009  Jim Evins <evins@snaught.com>.
  *
- *  Copyright (C) 2001-2002  Jim Evins <evins@snaught.com>.
+ *  This file is part of gLabels.
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  gLabels is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
- *  This program is distributed in the hope that it will be useful,
+ *  gLabels is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ *  along with gLabels.  If not, see <http://www.gnu.org/licenses/>.
  */
+
 #include <config.h>
 
 #include "ui.h"
 
 #include <glib/gi18n.h>
 #include <gconf/gconf-client.h>
-#include "recent-files/egg-recent-view.h"
-#include "recent-files/egg-recent-view-uimanager.h"
+#include <gtk/gtk.h>
+#include <string.h>
 
 #include "ui-util.h"
 #include "ui-commands.h"
 
 #include "debug.h"
 
+
 /*==========================================================================*/
 /* Private macros and constants.                                            */
 /*==========================================================================*/
 
+
 /*==========================================================================*/
 /* Private types.                                                           */
 /*==========================================================================*/
@@ -78,10 +77,6 @@ static void menu_item_select_cb            (GtkMenuItem     *proxy,
 static void menu_item_deselect_cb          (GtkMenuItem     *proxy,
                                            glWindow        *window);
 
-static char *recent_tooltip_func           (EggRecentItem   *item,
-                                           gpointer         user_data);
-
-
 
 /*==========================================================================*/
 /* Private globals                                                          */
@@ -91,7 +86,7 @@ static GtkActionEntry entries[] = {
 
        /* Menu entries. */
        { "FileMenu",                NULL, N_("_File") },
-       { "FileRecentsMenu",         NULL, N_("Recent _Files") },
+       { "FileRecentsMenu",         NULL, N_("Open Recent _Files") },
        { "EditMenu",                NULL, N_("_Edit") },
        { "ViewMenu",                NULL, N_("_View") },
        { "ViewMainToolBarMenu",     NULL, N_("Customize Main Toolbar") },
@@ -439,14 +434,6 @@ static GtkToggleActionEntry toggle_entries[] = {
          G_CALLBACK (gl_ui_cmd_view_property_bar_toggle),
          TRUE },
 
-       { "ViewPropertyToolBarToolTips",
-         NULL,
-         N_("Show tooltips"),
-         NULL,
-         N_("Show tooltips for property toolbar"),
-         G_CALLBACK (gl_ui_cmd_view_property_bar_tips_toggle),
-         TRUE },
-
        { "ViewGrid",
          NULL,
          N_("Grid"),
@@ -484,22 +471,6 @@ static GtkToggleActionEntry ui_toggle_entries[] = {
          G_CALLBACK (view_ui_item_toggled_cb),
          TRUE },
 
-       { "ViewMainToolBarToolTips",
-         NULL,
-         N_("Show tooltips"),
-         NULL,
-         N_("Show tooltips for main toolbar"),
-         G_CALLBACK (view_ui_item_toggled_cb),
-         TRUE },
-
-       { "ViewDrawingToolBarToolTips",
-         NULL,
-         N_("Show tooltips"),
-         NULL,
-         N_("Show tooltips for drawing toolbar"),
-         G_CALLBACK (view_ui_item_toggled_cb),
-         TRUE },
-
 };
 static guint n_ui_toggle_entries = G_N_ELEMENTS (ui_toggle_entries);
 
@@ -510,9 +481,7 @@ static const gchar *ui_info =
 "              <menu action='FileMenu'>"
 "                      <menuitem action='FileNew' />"
 "                      <menuitem action='FileOpen' />"
-"                       <menu action='FileRecentsMenu'>"
-"                              <placeholder name='FileRecentsPlaceHolder' />"
-"                       </menu>"
+"                      <menuitem action='FileRecentsMenu' />"
 "                      <separator />"
 "                      <menuitem action='FileSave' />"
 "                      <menuitem action='FileSaveAs' />"
@@ -541,16 +510,6 @@ static const gchar *ui_info =
 "                      <menuitem action='ViewDrawingToolBar' />"
 "                      <menuitem action='ViewPropertyToolBar' />"
 "                      <separator />"
-"                      <menu action='ViewMainToolBarMenu'>"
-"                              <menuitem action='ViewMainToolBarToolTips' />"
-"                      </menu>"
-"                      <menu action='ViewDrawingToolBarMenu'>"
-"                              <menuitem action='ViewDrawingToolBarToolTips' />"
-"                      </menu>"
-"                      <menu action='ViewPropertyToolBarMenu'>"
-"                              <menuitem action='ViewPropertyToolBarToolTips' />"
-"                      </menu>"
-"                      <separator />"
 "                      <menuitem action='ViewGrid' />"
 "                      <menuitem action='ViewMarkup' />"
 "                      <separator />"
@@ -713,7 +672,7 @@ static gchar* doc_verbs [] = {
 };
 
 static gchar* doc_modified_verbs [] = {
-       "/ui/MenuBar/FileMenu/Save",
+       "/ui/MenuBar/FileMenu/FileSave",
 
        NULL
 };
@@ -761,7 +720,7 @@ gl_ui_new (glWindow *window)
        GtkUIManager            *ui;
        GtkActionGroup          *actions;
        GError                  *error = NULL;
-       EggRecentViewUIManager  *recent_view;
+       GtkWidget               *recent_menu;
 
        gl_debug (DEBUG_UI, "START");
 
@@ -777,6 +736,7 @@ gl_ui_new (glWindow *window)
                          G_CALLBACK (disconnect_proxy_cb), window);
 
        actions = gtk_action_group_new ("Actions");
+        gtk_action_group_set_translation_domain (actions, NULL);
        gtk_action_group_add_actions (actions, entries, n_entries, GTK_WINDOW (window));
        gtk_action_group_add_toggle_actions (actions, 
                                             toggle_entries, n_toggle_entries, 
@@ -801,16 +761,13 @@ gl_ui_new (glWindow *window)
        /* Set view grid and markup visibility according to prefs */
        set_view_style (ui);
                
-       /* add an eggRecentView */
-        recent_view  =
-               egg_recent_view_uimanager_new (ui,
-                                              "/ui/MenuBar/FileMenu/FileRecentsMenu/FileRecentsPlaceHolder",
-                                              G_CALLBACK (gl_ui_cmd_file_open_recent),
-                                              window);
-       egg_recent_view_uimanager_show_icons (recent_view, FALSE);
-       egg_recent_view_uimanager_set_tooltip_func (recent_view, recent_tooltip_func, NULL);
-       egg_recent_view_set_model (EGG_RECENT_VIEW (recent_view), gl_recent_get_model ());
-       g_object_set_data (G_OBJECT (ui), "recent-view", recent_view);
+       /* add an Open Recents Submenu */
+        recent_menu  = gl_recent_create_menu ();
+       g_signal_connect (G_OBJECT (recent_menu), "item-activated",
+                         G_CALLBACK (gl_ui_cmd_file_open_recent), window);
+       gtk_menu_item_set_submenu (GTK_MENU_ITEM (gtk_ui_manager_get_widget (ui, "/MenuBar/FileMenu/FileRecentsMenu")),
+                                  recent_menu);
+
 
        gl_ui_util_set_verb_list_sensitive (ui, doc_verbs, FALSE);
 
@@ -819,27 +776,21 @@ gl_ui_new (glWindow *window)
        return ui;
 }
 
+
 /*****************************************************************************/
 /** Unref wrapper.                                                           */
 /*****************************************************************************/
 void
 gl_ui_unref (GtkUIManager *ui)
 {
-       GObject *recent_view;
-
        gl_debug (DEBUG_UI, "START");
 
-       /* Pull out recent view to unreference. */
-       recent_view = g_object_get_data (G_OBJECT(ui), "recent-view");
-       if (recent_view) {
-               g_object_unref (recent_view);
-       }
-
        g_object_unref(ui);
 
        gl_debug (DEBUG_UI, "END");
 }
 
+
 /*****************************************************************************/
 /** Update all verbs of given UI component.                                  */
 /*****************************************************************************/
@@ -882,6 +833,7 @@ gl_ui_update_all (GtkUIManager *ui,
        gl_debug (DEBUG_UI, "END");
 }
 
+
 /*****************************************************************************/
 /** Update all verbs of given UI component to "no document" state.           */
 /*****************************************************************************/
@@ -895,6 +847,7 @@ gl_ui_update_nodoc (GtkUIManager *ui)
        gl_debug (DEBUG_UI, "END");
 }
 
+
 /*****************************************************************************/
 /** Update label modified verbs of given UI component.                       */
 /*****************************************************************************/
@@ -911,6 +864,7 @@ gl_ui_update_modified_verbs (GtkUIManager *ui,
        gl_debug (DEBUG_UI, "END");
 }
 
+
 /*****************************************************************************/
 /** Update verbs associated with selection state of given UI component.      */
 /*****************************************************************************/
@@ -933,6 +887,7 @@ gl_ui_update_selection_verbs (GtkUIManager *ui,
        gl_debug (DEBUG_UI, "END");
 }
 
+
 /*****************************************************************************/
 /** Update verbs associated with zoom level of given UI component.           */
 /*****************************************************************************/
@@ -950,6 +905,7 @@ gl_ui_update_zoom_verbs (GtkUIManager *ui,
        gl_debug (DEBUG_UI, "END");
 }
 
+
 /*****************************************************************************/
 /** Update undo/redo verbs of given UI component.                            */
 /*****************************************************************************/
@@ -968,6 +924,7 @@ gl_ui_update_undo_redo_verbs (GtkUIManager *ui,
        gl_debug (DEBUG_UI, "END");
 }
 
+
 /*---------------------------------------------------------------------------*/
 /** PRIVATE.  View menu item toggled callback.                               */
 /*---------------------------------------------------------------------------*/
@@ -994,13 +951,6 @@ view_ui_item_toggled_cb (GtkToggleAction *action,
                gl_prefs_model_save_settings (gl_prefs);
        }
 
-       if (strcmp (name, "ViewMainToolBarToolTips") == 0)
-       {
-               gl_prefs->main_toolbar_view_tooltips = state;
-               set_app_main_toolbar_style (ui);
-               gl_prefs_model_save_settings (gl_prefs);
-       }
-
        if (strcmp (name, "ViewDrawingToolBar") == 0)
        {
                gl_prefs->drawing_toolbar_visible = state;
@@ -1008,16 +958,10 @@ view_ui_item_toggled_cb (GtkToggleAction *action,
                gl_prefs_model_save_settings (gl_prefs);
        }
 
-       if (strcmp (name, "ViewDrawingToolBarToolTips") == 0)
-       {
-               gl_prefs->drawing_toolbar_view_tooltips = state;
-               set_app_drawing_toolbar_style (ui);
-               gl_prefs_model_save_settings (gl_prefs);
-       }
-
        gl_debug (DEBUG_UI, "");
 }
 
+
 /*---------------------------------------------------------------------------*/
 /** PRIVATE.  Set main toolbar style.                                        */
 /*---------------------------------------------------------------------------*/
@@ -1034,18 +978,8 @@ set_app_main_toolbar_style (GtkUIManager *ui)
        gl_ui_util_set_verb_state (ui, "/ui/ViewMenu/ViewMainToolBar",
                                   gl_prefs->main_toolbar_visible);
 
-       gl_ui_util_set_verb_sensitive (ui, "/ui/ViewMenu/ViewMainToolBarToolTips",
-                                      gl_prefs->main_toolbar_visible);
-
-       gl_ui_util_set_verb_state (ui, "/ui/ViewMenu/ViewMainToolBarToolTips",
-                                  gl_prefs->main_toolbar_view_tooltips);
-
-       
        toolbar = gtk_ui_manager_get_widget (ui, "/MainToolBar");
 
-       gtk_toolbar_set_tooltips (GTK_TOOLBAR (toolbar),
-                                 gl_prefs->main_toolbar_view_tooltips);
-
        if (gl_prefs->main_toolbar_visible) {
                gtk_widget_show_all (toolbar);
        } else {
@@ -1072,18 +1006,8 @@ set_app_drawing_toolbar_style (GtkUIManager *ui)
        gl_ui_util_set_verb_state (ui, "/ui/MenuBar/ViewMenu/ViewDrawingToolBar",
                                   gl_prefs->drawing_toolbar_visible);
 
-       gl_ui_util_set_verb_sensitive (ui, "/ui/MenuBar/ViewMenu/ViewDrawingToolBarToolTips",
-                                      gl_prefs->drawing_toolbar_visible);
-
-       gl_ui_util_set_verb_state (ui, "/ui/MenuBar/ViewMenuDrawingToolBarToolTips",
-                                  gl_prefs->drawing_toolbar_view_tooltips);
-
-       
        toolbar = gtk_ui_manager_get_widget (ui, "/DrawingToolBar");
 
-       gtk_toolbar_set_tooltips (GTK_TOOLBAR (toolbar),
-                                 gl_prefs->drawing_toolbar_view_tooltips);
-
        gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
 
        if (gl_prefs->drawing_toolbar_visible) {
@@ -1095,6 +1019,7 @@ set_app_drawing_toolbar_style (GtkUIManager *ui)
        gl_debug (DEBUG_UI, "END");
 }
 
+
 /*---------------------------------------------------------------------------*/
 /** PRIVATE.  Set visibility of grid and markup.                             */
 /*---------------------------------------------------------------------------*/
@@ -1114,6 +1039,7 @@ set_view_style (GtkUIManager *ui)
        gl_debug (DEBUG_UI, "END");
 }
 
+
 /*---------------------------------------------------------------------------*/
 /** PRIVATE.  Connect proxy callback.                                        */
 /*---------------------------------------------------------------------------*/
@@ -1132,6 +1058,7 @@ connect_proxy_cb (GtkUIManager *ui,
        }
 }
 
+
 /*---------------------------------------------------------------------------*/
 /** PRIVATE.  Disconnect proxy callback.                                     */
 /*---------------------------------------------------------------------------*/
@@ -1150,6 +1077,7 @@ disconnect_proxy_cb (GtkUIManager *ui,
        }
 }
 
+
 /*---------------------------------------------------------------------------*/
 /** PRIVATE.  Menu item select callback.                                     */
 /*---------------------------------------------------------------------------*/
@@ -1175,6 +1103,7 @@ menu_item_select_cb (GtkMenuItem *proxy,
        }
 }
 
+
 /*---------------------------------------------------------------------------*/
 /** PRIVATE.  Menu item deselect callback.                                   */
 /*---------------------------------------------------------------------------*/
@@ -1189,23 +1118,13 @@ menu_item_deselect_cb (GtkMenuItem *proxy,
                           window->menu_tips_context_id);
 }
 
-/*---------------------------------------------------------------------------*/
-/** PRIVATE.  Tooltip function for recent file menu items.                   */
-/*---------------------------------------------------------------------------*/
-static char *
-recent_tooltip_func (EggRecentItem *item, gpointer user_data)
-{
-       char *tip;
-       char *uri_for_display;
-
-       uri_for_display = egg_recent_item_get_uri_for_display (item);
-       g_return_val_if_fail (uri_for_display != NULL, NULL);
-
-       tip = g_strdup_printf (_("Open '%s'"), uri_for_display);
-
-       g_free (uri_for_display);
-
-       return tip;
-}
 
 
+/*
+ * Local Variables:       -- emacs
+ * mode: C                -- emacs
+ * c-basic-offset: 8      -- emacs
+ * tab-width: 8           -- emacs
+ * indent-tabs-mode: nil  -- emacs
+ * End:                   -- emacs
+ */