]> git.sur5r.net Git - glabels/commitdiff
Replacing gnome-recent* with current egg recent files module.
authorJim Evins <evins@snaught.com>
Thu, 9 Oct 2003 02:03:31 +0000 (02:03 +0000)
committerJim Evins <evins@snaught.com>
Thu, 9 Oct 2003 02:03:31 +0000 (02:03 +0000)
git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@309 f5e0f49d-192f-0410-a22d-a8d8700d0965

17 files changed:
glabels2/src/Makefile.am
glabels2/src/file.c
glabels2/src/file.h
glabels2/src/glabels.c
glabels2/src/gnome-recent-marshal.list [deleted file]
glabels2/src/gnome-recent-model.c [deleted file]
glabels2/src/gnome-recent-model.h [deleted file]
glabels2/src/gnome-recent-util.c [deleted file]
glabels2/src/gnome-recent-util.h [deleted file]
glabels2/src/gnome-recent-view-bonobo.c [deleted file]
glabels2/src/gnome-recent-view-bonobo.h [deleted file]
glabels2/src/gnome-recent-view.c [deleted file]
glabels2/src/gnome-recent-view.h [deleted file]
glabels2/src/recent.c
glabels2/src/recent.h
glabels2/src/ui.c
glabels2/src/xml-label.c

index 915bc1af1f442974d21d22fe2a243b037e5b2949..3581fefdf863204399d285c78a975603ccf68564 100644 (file)
@@ -1,6 +1,6 @@
 LIB_BARCODE_DIR = ../barcode-0.98
 
-SUBDIRS= pixmaps stock-pixmaps mygal
+SUBDIRS= pixmaps stock-pixmaps mygal recent-files
 
 bin_PROGRAMS = glabels glabels-batch
 
@@ -29,6 +29,7 @@ glabels_LDFLAGS = -export-dynamic
 glabels_LDADD =                        \
        $(GLABELS_LIBS)                 \
        mygal/libmygal.la               \
+       recent-files/librecent.la       \
        -L$(LIB_BARCODE_DIR) -lbarcode  
 
 glabels_batch_LDFLAGS = -export-dynamic
@@ -39,9 +40,7 @@ glabels_batch_LDADD =                         \
 
 BUILT_SOURCES =                        \
        marshal.c                       \
-       marshal.h                       \
-       gnome-recent-marshal.c          \
-       gnome-recent-marshal.h
+       marshal.h                       
 
 glabels_SOURCES =                      \
        glabels.c                       \
@@ -183,14 +182,6 @@ glabels_SOURCES =                  \
        color.h                         \
        canvas-hacktext.c               \
        canvas-hacktext.h               \
-       gnome-recent-model.c            \
-       gnome-recent-model.h            \
-       gnome-recent-util.c             \
-       gnome-recent-util.h             \
-       gnome-recent-view.c             \
-       gnome-recent-view.h             \
-       gnome-recent-view-bonobo.c      \
-       gnome-recent-view-bonobo.h      \
        debug.c                         \
        debug.h                         \
        $(BUILT_SOURCES)
@@ -264,20 +255,11 @@ marshal.c: marshal.list $(GLIB_GENMARSHAL)
        echo "#include \"marshal.h\"" > $@ && \
        $(GLIB_GENMARSHAL) $< --body --prefix=gl_marshal >> $@
 
-gnome-recent-marshal.h: gnome-recent-marshal.list $(GLIB_GENMARSHAL)
-       $(GLIB_GENMARSHAL) $< --header --prefix=gnome_recent > $@
-
-gnome-recent-marshal.c: gnome-recent-marshal.list $(GLIB_GENMARSHAL)
-       echo "#include \"gnome-recent-marshal.h\"" > $@ && \
-       $(GLIB_GENMARSHAL) $< --body --prefix=gnome_recent >> $@
-
-
 ui_DATA = glabels-ui.xml
 
 EXTRA_DIST = \
        $(ui_DATA)                      \
-       marshal.list                    \
-       gnome-recent-marshal.list
+       marshal.list                    
 
 CLEANFILES = $(BUILT_SOURCES)
 
index ee07bbb9dd9ed8ea357fc9d978099ab500c9610c..82f12ba4c849f66d55ffc0720501b13b9202c0c4 100644 (file)
@@ -449,10 +449,11 @@ static void
 open_ok (GtkWidget        *widget,
         GtkFileSelection *fsel)
 {
-       gchar            *filename;
+       gchar            *raw_filename;
+       gchar            *filename;
        GtkWidget        *dlg;
        gint              ret;
-       GnomeRecentModel *recent;
+       EggRecentModel   *recent;
        GtkWindow        *window;
 
        gl_debug (DEBUG_FILE, "START");
@@ -460,9 +461,12 @@ open_ok (GtkWidget        *widget,
        g_return_if_fail (GTK_IS_FILE_SELECTION (fsel));
 
        /* get the filename */
-       filename = g_strdup (gtk_file_selection_get_filename (fsel));
+       raw_filename = g_strdup (gtk_file_selection_get_filename (fsel));
+       filename = g_filename_to_utf8 (raw_filename, -1, NULL, NULL, NULL);
 
-       if (!filename || g_file_test (filename, G_FILE_TEST_IS_DIR)) {
+       if (!raw_filename || 
+           !filename || 
+           g_file_test (raw_filename, G_FILE_TEST_IS_DIR)) {
 
                dlg = gl_hig_alert_new (GTK_WINDOW(fsel),
                                        GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -476,7 +480,7 @@ open_ok (GtkWidget        *widget,
 
        } else {
 
-               if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
+               if (!g_file_test (raw_filename, G_FILE_TEST_IS_REGULAR)) {
 
                        dlg = gl_hig_alert_new (GTK_WINDOW(fsel),
                                                GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -503,6 +507,7 @@ open_ok (GtkWidget        *widget,
        }
 
        g_free (filename);
+       g_free (raw_filename);
 
        gl_debug (DEBUG_FILE, "END");
 }
@@ -511,13 +516,25 @@ open_ok (GtkWidget        *widget,
 /* "Open recent" menu callback.                                              */
 /*****************************************************************************/
 gboolean
-gl_file_open_recent (GnomeRecentView *view,
-                    const gchar     *filename,
+gl_file_open_recent (EggRecentView   *view,
+                    EggRecentItem   *item,
                     GtkWindow       *window)
 {
+       gboolean result = FALSE;
+       gchar *filename;
+       
        gl_debug (DEBUG_FILE, "");
 
-       return gl_file_open_real (filename, window);
+       filename = gl_recent_get_filename (item);
+
+       if (filename) {
+               gl_debug (DEBUG_FILE, "open recent: %s", filename);
+
+               result = gl_file_open_real (filename, window);
+               g_free (filename);
+       }
+
+       return result;
 }
 
 /*---------------------------------------------------------------------------*/
@@ -530,7 +547,7 @@ gl_file_open_real (const gchar     *filename,
        gchar            *abs_filename;
        glLabel          *label;
        glXMLLabelStatus  status;
-       GnomeRecentModel *recent;
+       EggRecentModel   *recent;
        gint              ret;
        GtkWidget        *new_window;
 
@@ -574,8 +591,7 @@ gl_file_open_real (const gchar     *filename,
                        gtk_widget_show_all (new_window);
                }
 
-               recent = gl_recent_get_model ();
-               gnome_recent_model_add (recent, abs_filename);
+               gl_recent_add_uri (abs_filename);
 
                if (open_path != NULL)
                        g_free (open_path);
@@ -602,7 +618,7 @@ gl_file_save (glLabel   *label,
        glXMLLabelStatus  status;
        GError           *error = NULL;
        gchar            *filename = NULL;
-       GnomeRecentModel *recent;
+       EggRecentModel   *recent;
 
        gl_debug (DEBUG_FILE, "");
 
@@ -657,8 +673,7 @@ gl_file_save (glLabel   *label,
        {
                gl_debug (DEBUG_FILE, "OK");
 
-               recent = gl_recent_get_model ();
-               gnome_recent_model_add (recent, filename);
+               gl_recent_add_uri (filename);
 
                g_free (filename);
 
@@ -739,11 +754,11 @@ static void
 save_as_ok_cb (GtkWidget        *widget,
               GtkFileSelection *fsel)
 {
-       gchar            *raw_filename, *filename;
+       gchar            *raw_filename, *filename, *full_filename;
        GtkWidget        *dlg;
        glLabel          *label;
        glXMLLabelStatus  status;
-       GnomeRecentModel *recent;
+       EggRecentModel   *recent;
        gboolean         *saved_flag;
        gchar            *primary_msg;
        gboolean          cancel_flag = FALSE;
@@ -774,11 +789,13 @@ save_as_ok_cb (GtkWidget        *widget,
 
        } else {
 
-               filename = gl_util_add_extension (raw_filename);
+               full_filename = gl_util_add_extension (raw_filename);
+
+               filename = g_filename_to_utf8 (full_filename, -1, NULL, NULL, NULL);
 
                gl_debug (DEBUG_FILE, "filename = \"%s\"", filename);
 
-               if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
+               if (g_file_test (full_filename, G_FILE_TEST_IS_REGULAR)) {
                        gint ret;
 
                        primary_msg = g_strdup_printf (_("Overwrite file \"%s\"?"),
@@ -827,8 +844,7 @@ save_as_ok_cb (GtkWidget        *widget,
 
                                *saved_flag = TRUE;
 
-                               recent = gl_recent_get_model ();
-                               gnome_recent_model_add (recent, filename);
+                               gl_recent_add_uri (filename);
 
                                if (save_path != NULL)
                                        g_free (save_path);
@@ -842,6 +858,7 @@ save_as_ok_cb (GtkWidget        *widget,
                }
 
                g_free (filename);
+               g_free (full_filename);
        }
 
        g_free (raw_filename);
index d7fb086f3cd8aca9b2252ee87429fc6c5c9d063c..cecef9dc710334836cb5b6d5d0ea3abcba49d57c 100644 (file)
@@ -23,7 +23,7 @@
 #ifndef __FILE_H__
 #define __FILE_H__
 
-#include "gnome-recent-view.h"
+#include "recent-files/egg-recent-view.h"
 #include <gtk/gtk.h>
 
 #include "label.h"
@@ -41,8 +41,8 @@ void     gl_file_properties  (glLabel         *label,
 void     gl_file_open        (GtkWindow       *window);
 
 
-gboolean gl_file_open_recent (GnomeRecentView *view,
-                             const gchar     *filename,
+gboolean gl_file_open_recent (EggRecentView   *view,
+                             EggRecentItem   *filename,
                              GtkWindow       *window);;
 
 gboolean gl_file_open_real   (const gchar     *filename,
index 4a064de79c918ee666793ab964c394b9dd89d4d0..6709da6cf95dbcc004779d96eeb885b2f974ede2 100644 (file)
@@ -142,6 +142,7 @@ main (int argc, char **argv)
        GList         *file_list = NULL, *p;
        gint           i;
        GtkWidget     *win;
+       gchar         *utf8_filename;
 
        bindtextdomain (GETTEXT_PACKAGE, GLABELS_LOCALEDIR);
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@@ -178,7 +179,7 @@ main (int argc, char **argv)
        gl_template_init();
        gl_merge_init();
        gl_recent_init();
-
+       
        if (bonobo_ui_init ("glabels", VERSION, &argc, argv) == FALSE) {
                g_error (_("Could not initialize Bonobo!\n"));
        }
@@ -201,13 +202,16 @@ main (int argc, char **argv)
        args = (char**) poptGetArgs(ctx);
        for (i = 0; args && args[i]; i++) 
        {
-               file_list = g_list_append (file_list, args[i]);
+               utf8_filename = g_filename_to_utf8 (args[i], -1, NULL, NULL, NULL);
+               if (utf8_filename)
+                       file_list = g_list_append (file_list, utf8_filename);
        }
 
        /* Open files or create empty top-level window. */
        for (p = file_list; p; p = p->next) {
                win = gl_window_new_from_file (p->data);
                gtk_widget_show_all (win);
+               g_free (p->data);
        }
        if ( gl_window_get_window_list() == NULL ) {
                win = gl_window_new ();
diff --git a/glabels2/src/gnome-recent-marshal.list b/glabels2/src/gnome-recent-marshal.list
deleted file mode 100644 (file)
index 1e99a95..0000000
+++ /dev/null
@@ -1 +0,0 @@
-BOOL:STRING
diff --git a/glabels2/src/gnome-recent-model.c b/glabels2/src/gnome-recent-model.c
deleted file mode 100644 (file)
index 9c02705..0000000
+++ /dev/null
@@ -1,771 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/**
- * This program 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 (at your option) any later version.
- *
- * This program 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.
- *
- * Authors:
- *   James Willcox <jwillcox@cs.indiana.edu>
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <gtk/gtk.h>
-#include <gconf/gconf-client.h>
-#include <libbonoboui.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include "gnome-recent-model.h"
-#include "gnome-recent-view.h"
-
-#define GNOME_RECENT_MODEL_BASE_KEY "/desktop/gnome/recent_files"
-#define GNOME_RECENT_MODEL_GLOBAL_LIMIT_KEY "global_limit"
-#define GNOME_RECENT_MODEL_GLOBAL_LIMIT_ENV "GNOME_RECENT_MODEL_GLOBAL_LIMIT"
-#define GNOME_RECENT_MODEL_GLOBAL_LIST "gnome-recent-global"
-
-static void gnome_recent_model_class_init      (GnomeRecentModelClass * klass);
-static void gnome_recent_model_init            (GnomeRecentModel * recent);
-static gchar *gnome_recent_model_gconf_key     (GnomeRecentModel * recent);
-static void gnome_recent_model_notify_cb       (GConfClient *client,
-                                               guint cnxn_id,
-                                               GConfEntry *entry,
-                                               gpointer user_data);
-static GSList * gnome_recent_model_delete_from_list (GnomeRecentModel *recent,
-                                              GSList *list,
-                                              const gchar *uri);
-static GSList * gnome_recent_model_gconf_to_list (GConfValue* value);
-static void gnome_recent_model_g_slist_deep_free (GSList *list);
-static void gnome_recent_model_set_appname (GnomeRecentModel *recent, gchar *appname);
-
-struct _GnomeRecentModel {
-       GObject parent_instance;        /* We emit signals */
-
-       gchar *appname;                 /* the app that owns this object */
-       GConfClient *gconf_client;      /* we use GConf to store stuff */
-       unsigned int limit;             /* maximum number of items to store */
-
-       GnomeRecentModel *global;       /* Another GnomeRecentModel object,
-                                        * representing the global
-                                        * recent uri list
-                                        */
-
-       GHashTable *monitors;           /* A hash table holding
-                                        * GnomeVfsMonitorHandle objects.
-                                        */
-};
-
-struct _GnomeRecentModelClass {
-       GObjectClass parent_class;
-       
-       void (*changed) (GnomeRecentModel *recent, const GSList *list);
-};
-
-struct _GnomeRecentModelMenuData {
-       GnomeRecentModel *recent;
-       gchar *uri;
-};
-
-typedef struct _GnomeRecentModelMenuData GnomeRecentModelMenuData;
-
-enum {
-       CHANGED,
-       LAST_SIGNAL
-};
-
-/* GObject properties */
-enum {
-       PROP_BOGUS,
-       PROP_APPNAME,
-       PROP_LIMIT,
-};
-
-static GType model_signals[LAST_SIGNAL] = { 0 };
-static GObjectClass *parent_class = NULL;
-
-/**
- * gnome_recent_model_get_type:
- * @:
- *
- * This returns a GType representing a GnomeRecentModel object.
- *
- * Returns: a GType
- */
-GType
-gnome_recent_model_get_type (void)
-{
-       static GType gnome_recent_model_type = 0;
-
-       if(!gnome_recent_model_type) {
-               static const GTypeInfo gnome_recent_model_info = {
-                       sizeof (GnomeRecentModelClass),
-                       NULL, /* base init */
-                       NULL, /* base finalize */
-                       (GClassInitFunc)gnome_recent_model_class_init, /* class init */
-                       NULL, /* class finalize */
-                       NULL, /* class data */
-                       sizeof (GnomeRecentModel),
-                       0,
-                       (GInstanceInitFunc) gnome_recent_model_init
-               };
-
-               gnome_recent_model_type = g_type_register_static (G_TYPE_OBJECT,
-                                                       "GnomeRecentModel",
-                                                       &gnome_recent_model_info, 0);
-       }
-
-       return gnome_recent_model_type;
-}
-
-static void
-gnome_recent_model_set_property (GObject *object,
-                          guint prop_id,
-                          const GValue *value,
-                          GParamSpec *pspec)
-{
-       GnomeRecentModel *recent = GNOME_RECENT_MODEL (object);
-       gchar *appname;
-
-       switch (prop_id)
-       {
-               case PROP_APPNAME:
-                       appname = g_strdup (g_value_get_string (value));
-                       gnome_recent_model_set_appname (recent, appname);
-               break;
-               case PROP_LIMIT:
-                       gnome_recent_model_set_limit (GNOME_RECENT_MODEL (recent),
-                                               g_value_get_int (value));
-               break;
-               default:
-               break;
-       }
-}
-
-static void
-gnome_recent_model_get_property (GObject *object,
-                          guint prop_id,
-                          GValue *value,
-                          GParamSpec *pspec)
-{
-       GnomeRecentModel *recent = GNOME_RECENT_MODEL (object);
-
-       switch (prop_id)
-       {
-               case PROP_APPNAME:
-                       g_value_set_string (value, recent->appname);
-               break;
-               case PROP_LIMIT:
-                       g_value_set_int (value, recent->limit);
-               break;
-               default:
-                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-       }
-}
-
-static void
-gnome_recent_model_class_init (GnomeRecentModelClass * klass)
-{
-       GObjectClass *object_class;
-
-       object_class = G_OBJECT_CLASS (klass);
-
-       parent_class = g_type_class_peek_parent (klass);
-
-       object_class->set_property = gnome_recent_model_set_property;
-       object_class->get_property = gnome_recent_model_get_property;
-
-       model_signals[CHANGED] = g_signal_new ("changed",
-                       G_OBJECT_CLASS_TYPE (object_class),
-                       G_SIGNAL_RUN_LAST,
-                       G_STRUCT_OFFSET (GnomeRecentModelClass, changed),
-                       NULL, NULL,
-                       g_cclosure_marshal_VOID__POINTER,
-                       G_TYPE_NONE, 1,
-                       G_TYPE_POINTER);
-
-       g_object_class_install_property (object_class,
-                                        PROP_APPNAME,
-                                        g_param_spec_string ("appname",
-                                                             "Application Name",
-                                                             "The name of the application using this object.",
-                                                             "gnome-app",
-                                                             G_PARAM_READWRITE));
-       g_object_class_install_property (object_class,
-                                        PROP_LIMIT,
-                                        g_param_spec_int    ("limit",
-                                                             "Limit",
-                                                             "The maximum number of items to be allowed in the list.",
-                                                             1,
-                                                             1000,
-                                                             10,
-                                                             G_PARAM_READWRITE));
-
-       klass->changed = NULL;
-}
-
-
-static void
-gnome_recent_model_init (GnomeRecentModel * recent)
-{
-       int argc=0;
-       char **argv=NULL;
-
-       if (!gconf_init (argc, argv, NULL))
-       {
-               g_warning ("GConf Initialization failed.");
-               return;
-       }
-       
-       if (!gnome_vfs_init ()) {
-               g_warning ("gnome-vfs initialization failed.");
-               return;
-       }
-
-       recent->gconf_client = gconf_client_get_default ();
-       recent->monitors = g_hash_table_new (g_str_hash, g_str_equal);
-}
-
-static gint
-gnome_recent_model_get_global_limit (GnomeRecentModel *model)
-{
-       char *key;
-       gint limit;
-
-       key = g_strdup_printf ("%s/%s", GNOME_RECENT_MODEL_BASE_KEY,
-                              GNOME_RECENT_MODEL_GLOBAL_LIMIT_KEY);
-
-
-       limit = gconf_client_get_int (model->gconf_client,
-                                     key, NULL);
-
-       if (limit <= 0) {
-               /* ok, gconf schemas are not functioning, so assign a sane value */
-               limit = 10;
-       }
-
-       g_free (key);
-       
-       return limit;
-}
-
-
-/**
- * gnome_recent_model_new:
- * @appname: The name of your application.
- * @limit:  The maximum number of items allowed.
- *
- * This creates a new GnomeRecentModel object.
- *
- * Returns: a GnomeRecentModel object
- */
-GnomeRecentModel *
-gnome_recent_model_new (const gchar *appname, gint limit)
-{
-       GnomeRecentModel *model;
-
-       g_return_val_if_fail (appname, NULL);
-       g_return_val_if_fail (limit > 0, NULL);
-
-       model = GNOME_RECENT_MODEL (g_object_new (gnome_recent_model_get_type (),
-                                          "appname",
-                                          appname,
-                                          "limit",
-                                          limit, NULL));
-
-       g_return_val_if_fail (model, NULL);
-       
-       return model;
-}
-
-/**
- * gnome_recent_model_new_global:
- * @
- *
- * This creates a new GnomeRecentModel object, with the global history list.
- *
- * Returns: a GnomeRecentModel object
- */
-GnomeRecentModel *
-gnome_recent_model_new_global (void)
-{
-       GnomeRecentModel *model;
-       gint limit;
-
-       model = GNOME_RECENT_MODEL (g_object_new(gnome_recent_model_get_type (),
-                                          "appname",
-                                          GNOME_RECENT_MODEL_GLOBAL_LIST,
-                                          NULL));
-
-       g_return_val_if_fail (model, NULL);
-
-       limit = gnome_recent_model_get_global_limit (model);
-       gnome_recent_model_set_limit (model, limit);
-       
-       return model;
-}
-
-
-
-static void
-gnome_recent_model_monitor_cb (GnomeVFSMonitorHandle *handle,
-                        const gchar *monitor_uri,
-                        const gchar *info_uri,
-                        GnomeVFSMonitorEventType event_type,
-                        gpointer data)
-{
-       GnomeRecentModel *recent= GNOME_RECENT_MODEL (data);
-
-       g_return_if_fail (recent);
-
-       /* if a file was deleted, we just remove it from our list */
-       switch (event_type) {
-               case GNOME_VFS_MONITOR_EVENT_DELETED:
-                       gnome_recent_model_delete (recent, monitor_uri);
-                       g_hash_table_remove (recent->monitors, monitor_uri);
-                       break;
-               default:
-               break;
-       }
-
-}
-
-static void
-gnome_recent_model_monitor_uri (GnomeRecentModel *recent, const gchar *uri)
-{
-       GnomeVFSMonitorHandle *handle=NULL;
-       GnomeVFSResult result;
-
-       g_return_if_fail (recent);
-       g_return_if_fail (GNOME_IS_RECENT_MODEL (recent));
-       g_return_if_fail (uri);
-
-       handle = g_hash_table_lookup (recent->monitors, uri);
-       if (handle == NULL) {
-
-               /* this is a new uri, so we need to monitor it */
-               result = gnome_vfs_monitor_add (&handle,
-                                      uri,
-                                      GNOME_VFS_MONITOR_FILE,
-                                      gnome_recent_model_monitor_cb,
-                                      recent);
-               if (result == GNOME_VFS_OK) {
-                       g_hash_table_insert (recent->monitors,
-                                            g_strdup (uri),
-                                            handle);
-               }
-       }
-}
-
-static void
-gnome_recent_model_monitor_uri_list (GnomeRecentModel *recent,
-                                    GSList *list)
-{
-       GSList *p;
-       const gchar *uri;
-
-       p = list;
-       while (p != NULL) {
-               uri = (const gchar *)p->data;
-
-               gnome_recent_model_monitor_uri (recent, uri);
-
-               p = p->next;
-       }
-}
-
-#if 0
-static void
-gnome_recent_model_monitor_cancel (GnomeRecentModel *recent, const gchar *uri)
-{
-       g_return_if_fail (recent);
-       g_return_if_fail (GNOME_IS_RECENT_MODEL (recent));
-       g_return_if_fail (uri);
-
-       g_hash_table_remove (recent->monitors, uri);
-}
-#endif
-
-/**
- * gnome_recent_model_add:
- * @recent:  A GnomeRecentModel object.
- * @uri: The URI you want to add to the list.
- *
- * This function adds a URI to the list of recently used URIs.
- *
- * Returns: a gboolean
- */
-gboolean
-gnome_recent_model_add (GnomeRecentModel * recent, const gchar * uri)
-{
-       GSList *uri_lst;
-       gchar *gconf_key;
-
-       g_return_val_if_fail (recent, FALSE);
-       g_return_val_if_fail (GNOME_IS_RECENT_MODEL (recent), FALSE);
-       g_return_val_if_fail (recent->gconf_client, FALSE);
-       g_return_val_if_fail (uri, FALSE);
-
-       gconf_key = gnome_recent_model_gconf_key (recent);
-
-
-       uri_lst = gconf_client_get_list (recent->gconf_client,
-                                      gconf_key,
-                                      GCONF_VALUE_STRING, NULL);
-
-       /* if this is already in our list, remove it */
-       uri_lst = gnome_recent_model_delete_from_list (recent, uri_lst, uri);
-
-       /* prepend the new one */
-       uri_lst = g_slist_prepend (uri_lst, g_strdup (uri));
-
-       /* if we're over the limit, delete from the end */
-       while (g_slist_length (uri_lst) > recent->limit)
-       {
-               gchar *tmp_uri;
-               tmp_uri = g_slist_nth_data (uri_lst, g_slist_length (uri_lst)-1);
-               uri_lst = g_slist_remove (uri_lst, tmp_uri);
-               g_free (tmp_uri);
-       }
-       
-       gconf_client_set_list (recent->gconf_client,
-                             gconf_key,
-                             GCONF_VALUE_STRING,
-                             uri_lst, NULL);
-
-       gconf_client_suggest_sync (recent->gconf_client, NULL);
-
-       /* add to the global list */
-       if (recent->global)
-               gnome_recent_model_add (GNOME_RECENT_MODEL (recent->global), uri);
-
-       g_free (gconf_key);
-       gnome_recent_model_g_slist_deep_free (uri_lst);
-
-       return TRUE;
-}
-
-
-/**
- * gnome_recent_model_delete:
- * @recent:  A GnomeRecentModel object.
- * @uri: The URI you want to delete from the list.
- *
- * This function deletes a URI from the list of recently used URIs.
- *
- * Returns: a gboolean
- */
-gboolean
-gnome_recent_model_delete (GnomeRecentModel * recent, const gchar * uri)
-{
-       GSList *uri_lst;
-       GSList *new_uri_lst;
-       gboolean ret = FALSE;
-       gchar *gconf_key;
-
-       g_return_val_if_fail (recent, FALSE);
-       g_return_val_if_fail (GNOME_IS_RECENT_MODEL (recent), FALSE);
-       g_return_val_if_fail (recent->gconf_client, FALSE);
-       g_return_val_if_fail (uri, FALSE);
-
-       gconf_key = gnome_recent_model_gconf_key (recent);
-       uri_lst = gconf_client_get_list (recent->gconf_client,
-                                      gconf_key,
-                                      GCONF_VALUE_STRING, NULL);
-
-       new_uri_lst = gnome_recent_model_delete_from_list (recent, uri_lst, uri);
-
-       /* if it wasn't deleted, no need to cause unneeded updates */
-       /*
-       if (new_uri_lst == uri_lst) {
-               return FALSE;
-       }
-       else
-               uri_lst = new_uri_lst;
-       */
-
-       /* delete it from gconf */
-       gconf_client_set_list (recent->gconf_client,
-                              gconf_key,
-                              GCONF_VALUE_STRING,
-                              new_uri_lst,
-                              NULL);
-       gconf_client_suggest_sync (recent->gconf_client, NULL);
-
-       /* delete from the global list */
-       if (recent->global)
-               gnome_recent_model_delete (GNOME_RECENT_MODEL (recent->global), uri);
-
-
-       g_free (gconf_key);
-       gnome_recent_model_g_slist_deep_free (new_uri_lst);
-
-       return ret;
-}
-
-/**
- * gnome_recent_model_get_list:
- * @recent: A GnomeRecentModel object.
- *
- * This returns a linked list of strings (URIs) currently held
- * by this object.
- *
- * Returns: A GSList *
- */
-GSList *
-gnome_recent_model_get_list (GnomeRecentModel * recent)
-{
-       GSList *uri_lst;
-       gchar *gconf_key = gnome_recent_model_gconf_key (recent);
-
-       g_return_val_if_fail (recent, NULL);
-       g_return_val_if_fail (recent->gconf_client, NULL);
-       g_return_val_if_fail (GNOME_IS_RECENT_MODEL (recent), NULL);
-
-       uri_lst = gconf_client_get_list (recent->gconf_client,
-                                      gconf_key,
-                                      GCONF_VALUE_STRING, NULL);
-
-       g_free (gconf_key);
-
-       /* FIXME:  This sucks. */
-       gnome_recent_model_monitor_uri_list (recent, uri_lst);
-
-       return uri_lst;
-}
-
-
-
-/**
- * gnome_recent_model_set_limit:
- * @recent: A GnomeRecentModel object.
- * @limit: The maximum number of items allowed in the list.
- *
- * Use this function to constrain the number of items allowed in the list.
- * The default is %GNOME_RECENT_MODEL_DEFAULT_LIMIT.
- *
- */
-void
-gnome_recent_model_set_limit (GnomeRecentModel *recent, gint limit)
-{
-       GSList *list;
-       int len;
-       unsigned int i;
-
-       g_return_if_fail (recent);
-       g_return_if_fail (GNOME_IS_RECENT_MODEL (recent));
-       g_return_if_fail (limit > 0);
-       recent->limit = limit;
-
-       list = gnome_recent_model_get_list (recent);
-       len = g_slist_length (list);
-
-       if (len <= limit) return;
-
-       /* if we're over the limit, delete from the end */
-       i=g_slist_length (list);
-       while (i > recent->limit)
-       {
-               gchar *uri = g_slist_nth_data (list, i-1);
-               gnome_recent_model_delete (recent, uri);
-
-               i--;
-       }
-
-       gnome_recent_model_g_slist_deep_free (list);
-}
-
-
-/**
- * gnome_recent_model_get_limit:
- * @recent: A GnomeRecentModel object.
- *
- */
-gint
-gnome_recent_model_get_limit (GnomeRecentModel *recent)
-{
-       g_return_val_if_fail (recent, -1);
-       g_return_val_if_fail (GNOME_IS_RECENT_MODEL (recent), -1);
-
-       return recent->limit;
-}
-
-
-/**
- * gnome_recent_model_clear:
- * @recent: A GnomeRecentModel object.
- *
- * This function clears the list of recently used URIs.
- *
- */
-void
-gnome_recent_model_clear (GnomeRecentModel *recent)
-{
-       gchar *key;
-
-       g_return_if_fail (recent);
-       g_return_if_fail (recent->gconf_client);
-       g_return_if_fail (GNOME_IS_RECENT_MODEL (recent));
-
-       key = gnome_recent_model_gconf_key (recent);
-
-       gconf_client_unset (recent->gconf_client, key, NULL);
-}
-
-static void
-gnome_recent_model_set_appname (GnomeRecentModel *recent, gchar *appname)
-{
-       gchar *key;
-       gint notify_id;
-
-       g_return_if_fail (recent);
-       g_return_if_fail (appname);
-
-       recent->appname = appname;
-
-       /* if this isn't the global list embed a global one */
-       if (strcmp (appname, GNOME_RECENT_MODEL_GLOBAL_LIST)) {
-               recent->global = gnome_recent_model_new_global ();
-       }
-
-       /* Set up the gconf notification stuff */
-       key = gnome_recent_model_gconf_key (recent);
-       gconf_client_add_dir (recent->gconf_client,
-                       GNOME_RECENT_MODEL_BASE_KEY, GCONF_CLIENT_PRELOAD_NONE, NULL);
-       notify_id = gconf_client_notify_add (recent->gconf_client,
-                                           key,
-                                           gnome_recent_model_notify_cb,
-                                           recent, NULL, NULL);
-
-
-
-       g_free (key);
-}
-
-static GSList *
-gnome_recent_model_delete_from_list (GnomeRecentModel *recent, GSList *list,
-                              const gchar *uri)
-{
-       unsigned int i;
-       gchar *text;
-
-       for (i = 0; i < g_slist_length (list); i++) {
-               text = g_slist_nth_data (list, i);
-               
-               if (!strcmp (text, uri)) {
-                       list = g_slist_remove (list, text);
-                       g_free (text);
-               }
-       }
-
-       return list;
-}
-
-/* this takes a list of GConfValues, and returns a list of strings */
-static GSList *
-gnome_recent_model_gconf_to_list (GConfValue* value)
-{    
-       GSList* iter;
-       GSList *list = NULL;
-
-       g_return_val_if_fail (value, NULL);
-
-       iter = gconf_value_get_list(value);
-
-       while (iter != NULL)
-       {
-               GConfValue* element = iter->data;
-               gchar *text = g_strdup (gconf_value_get_string (element));
-
-               list = g_slist_prepend (list, text);
-
-               iter = g_slist_next(iter);
-       }
-
-       list = g_slist_reverse (list);
-
-       return list;
-}
-
-static void
-gnome_recent_model_g_slist_deep_free (GSList *list)
-{
-       GSList *lst;
-
-       if (list == NULL)
-               return;
-
-       lst = list;
-       while (lst) {
-               g_free (lst->data);
-               lst->data = NULL;
-               lst = lst->next;
-       }
-
-       g_slist_free (list);
-}
-
-static gchar *
-gnome_recent_model_gconf_key (GnomeRecentModel * model)
-{
-       gchar *key;
-
-       g_return_val_if_fail (model, NULL);
-
-       key = g_strdup_printf ("%s/%s", GNOME_RECENT_MODEL_BASE_KEY, model->appname);
-       return key;
-}
-
-/*
-static void
-print_list (GSList *list)
-{
-       while (list) {
-               g_print ("%s, ", (char *)list->data);
-
-               list = list->next;
-       }
-       g_print ("\n\n");
-}
-*/
-
-/* this is the gconf notification callback. */
-static void
-gnome_recent_model_notify_cb (GConfClient *client, guint cnxn_id,
-                       GConfEntry *entry, gpointer user_data)
-{
-       GSList *list=NULL;
-       GnomeRecentModel *recent = user_data;
-
-       if (entry->value == NULL) {
-               g_signal_emit (G_OBJECT(recent), model_signals[CHANGED], 0, NULL);
-               return;
-       }
-
-       list = gnome_recent_model_gconf_to_list (entry->value);
-
-       gnome_recent_model_monitor_uri_list (recent, list);
-
-       g_signal_emit (G_OBJECT(recent), model_signals[CHANGED], 0, list);
-
-       gnome_recent_model_g_slist_deep_free (list);
-}
-
-
-gchar *
-gnome_recent_model_get_appname (GnomeRecentModel *model)
-{
-       return g_strdup (model->appname);
-}
diff --git a/glabels2/src/gnome-recent-model.h b/glabels2/src/gnome-recent-model.h
deleted file mode 100644 (file)
index 1ccc67d..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-#ifndef __GNOME_RECENT_MODEL_H__
-#define __GNOME_RECENT_MODEL_H__
-
-#include <libbonoboui.h>
-
-G_BEGIN_DECLS
-
-#define GNOME_RECENT_MODEL(obj)                G_TYPE_CHECK_INSTANCE_CAST (obj, gnome_recent_model_get_type (), GnomeRecentModel)
-#define GNOME_RECENT_MODEL_CLASS(klass)        G_TYPE_CHECK_CLASS_CAST (klass, gnome_recent_model_get_type (), GnomeRecentModelClass)
-#define GNOME_IS_RECENT_MODEL(obj)             G_TYPE_CHECK_INSTANCE_TYPE (obj, gnome_recent_model_get_type ())
-
-typedef struct _GnomeRecentModel GnomeRecentModel;
-
-typedef struct _GnomeRecentModelClass GnomeRecentModelClass;
-
-GType                gnome_recent_model_get_type     (void);
-
-/* constructors */
-GnomeRecentModel *   gnome_recent_model_new          (const gchar *appname,
-                                                     gint limit);
-GnomeRecentModel *   gnome_recent_model_new_global   (void);
-
-
-
-/* public methods */
-gboolean gnome_recent_model_add          (GnomeRecentModel *recent,
-                                          const gchar *uri);
-gboolean gnome_recent_model_delete       (GnomeRecentModel *recent,
-                                          const gchar *uri);
-void     gnome_recent_model_clear        (GnomeRecentModel *recent);
-GSList * gnome_recent_model_get_list     (GnomeRecentModel *recent);
-void     gnome_recent_model_set_limit    (GnomeRecentModel *recent,
-                                          gint limit);
-gint     gnome_recent_model_get_limit    (GnomeRecentModel *recent);
-gchar   *gnome_recent_model_get_appname  (GnomeRecentModel *recent);
-
-G_END_DECLS
-
-#endif /* __GNOME_RECENT_MODEL_H__ */
diff --git a/glabels2/src/gnome-recent-util.c b/glabels2/src/gnome-recent-util.c
deleted file mode 100644 (file)
index c898876..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#include <stdio.h>
-#include <gtk/gtk.h>
-#include <string.h>
-#include "gnome-recent-util.h"
-
-/* ripped out of gedit2 */
-gchar* 
-gnome_recent_util_escape_underlines (const gchar* text)
-{
-       GString *str;
-       gint length;
-       const gchar *p;
-       const gchar *end;
-
-       g_return_val_if_fail (text != NULL, NULL);
-
-       length = strlen (text);
-
-       str = g_string_new ("");
-
-       p = text;
-       end = text + length;
-
-       while (p != end)
-       {
-               const gchar *next;
-               next = g_utf8_next_char (p);
-
-               switch (*p)
-               {
-                               case '_':
-                               g_string_append (str, "__");
-                               break;
-                       default:
-                               g_string_append_len (str, p, next - p);
-                               break;
-               }
-
-               p = next;
-       }
-
-       return g_string_free (str, FALSE);
-}
diff --git a/glabels2/src/gnome-recent-util.h b/glabels2/src/gnome-recent-util.h
deleted file mode 100644 (file)
index 989c830..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-
-G_BEGIN_DECLS
-
-
-gchar *gnome_recent_util_escape_underlines (const gchar *uri);
-
-
-
-G_END_DECLS
diff --git a/glabels2/src/gnome-recent-view-bonobo.c b/glabels2/src/gnome-recent-view-bonobo.c
deleted file mode 100644 (file)
index f5a015c..0000000
+++ /dev/null
@@ -1,500 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/**
- * This program 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 (at your option) any later version.
- *
- * This program 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.
- *
- * Authors:
- *   James Willcox <jwillcox@cs.indiana.edu>
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <gtk/gtk.h>
-#include <gconf/gconf-client.h>
-#include <libbonoboui.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include "gnome-recent-model.h"
-#include "gnome-recent-view.h"
-#include "gnome-recent-view-bonobo.h"
-#include "gnome-recent-util.h"
-#include "gnome-recent-marshal.h"
-
-#define GNOME_RECENT_VERB_NAME "-uri-"
-
-struct _GnomeRecentViewBonobo {
-       GObject parent_instance;        /* We emit signals */
-
-       BonoboUIComponent *uic;
-       gchar *path;                    /* The menu path where our stuff
-                                        *  will go
-                                        */
-
-       gulong changed_cb_id;
-
-       GnomeRecentModel *model;
-};
-
-struct _GnomeRecentViewBonoboClass {
-       GObjectClass parent_class;
-       
-       void (*activate) (GnomeRecentViewBonobo *view, const gchar *uri);
-};
-
-struct _GnomeRecentViewBonoboMenuData {
-       GnomeRecentViewBonobo *view;
-       gchar *uri;
-};
-
-typedef struct _GnomeRecentViewBonoboMenuData GnomeRecentViewBonoboMenuData;
-
-enum {
-       ACTIVATE,
-       LAST_SIGNAL
-};
-
-/* GObject properties */
-enum {
-       PROP_BOGUS,
-       PROP_UI_COMPONENT,
-       PROP_MENU_PATH
-};
-
-static guint gnome_recent_view_bonobo_signals[LAST_SIGNAL] = { 0 };
-
-static void
-gnome_recent_view_bonobo_clear (GnomeRecentView *view_parent)
-{
-       gint i=1;
-       gboolean done=FALSE;
-       gchar *appname;
-       GnomeRecentModel *model;
-       GnomeRecentViewBonobo *view;
-
-       g_return_if_fail (view_parent);
-       view = GNOME_RECENT_VIEW_BONOBO (view_parent);
-       g_return_if_fail (view->uic);
-
-       model = gnome_recent_view_get_model (GNOME_RECENT_VIEW (view));
-       appname = gnome_recent_model_get_appname (model);
-       
-       while (!done)
-       {
-               gchar *verb_name = g_strdup_printf ("%s%s%d", appname,GNOME_RECENT_VERB_NAME, i);
-               gchar *item_path = g_strconcat (view->path, "/", verb_name, NULL);
-               if (bonobo_ui_component_path_exists (view->uic, item_path, NULL))
-                       bonobo_ui_component_rm (view->uic, item_path, NULL);
-               else
-                       done=TRUE;
-
-               g_free (item_path);
-               g_free (verb_name);
-
-               i++;
-       }
-
-       g_free (appname);
-}
-
-static void
-gnome_recent_view_bonobo_menu_cb (BonoboUIComponent *uic, gpointer data, const char *cname)
-{
-       gboolean ret;
-       GnomeRecentViewBonoboMenuData *md = (GnomeRecentViewBonoboMenuData *) data;
-       GnomeRecentModel *model;
-
-       g_return_if_fail (md);
-       g_return_if_fail (md->uri);
-       g_return_if_fail (md->view);
-       g_return_if_fail (GNOME_IS_RECENT_VIEW_BONOBO (md->view));
-
-       ret = FALSE;
-       g_signal_emit (G_OBJECT(md->view),
-                      gnome_recent_view_bonobo_signals[ACTIVATE], 0,
-                      md->uri, &ret);
-
-       if (!ret) {
-               model = gnome_recent_view_get_model (GNOME_RECENT_VIEW (md->view));
-               gnome_recent_model_delete (model, md->uri);
-       }
-}
-
-static void
-gnome_recent_view_bonobo_menu_data_destroy_cb (gpointer data, GClosure *closure)
-{
-       GnomeRecentViewBonoboMenuData *md = data;
-
-       g_free (md->uri);
-       g_free (md);
-}
-
-
-static void
-gnome_recent_view_bonobo_set_list (GnomeRecentViewBonobo *view, GSList *list)
-{
-       BonoboUIComponent* ui_component;
-       unsigned int i;
-       gchar *label = NULL;
-       gchar *verb_name = NULL;
-       gchar *tip = NULL;
-       gchar *escaped_name = NULL;
-       gchar *item_path = NULL;
-       gchar *uri;
-       gchar *cmd;
-       gchar *appname;
-       GnomeRecentViewBonoboMenuData *md;
-       GnomeRecentModel *model;
-       GClosure *closure;
-
-       g_return_if_fail (view);
-
-       ui_component = view->uic;
-       g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
-
-       model = gnome_recent_view_get_model (GNOME_RECENT_VIEW (view));
-       appname = gnome_recent_model_get_appname (model);
-
-       gnome_recent_view_bonobo_clear (GNOME_RECENT_VIEW (view));
-       
-       bonobo_ui_component_freeze (ui_component, NULL);
-
-       for (i = 1; i <= g_slist_length (list); ++i)
-       {
-               
-               /* this is what gets passed to our private "activate" callback */
-               md = (GnomeRecentViewBonoboMenuData *)g_malloc (sizeof (GnomeRecentViewBonoboMenuData));
-               md->view = view;
-               md->uri = g_strdup (g_slist_nth_data (list, i-1));
-
-               /* Maybe we should use a gnome-vfs call here?? */
-               uri = g_path_get_basename (g_slist_nth_data (list, i - 1));
-       
-               escaped_name = gnome_recent_util_escape_underlines (uri);
-
-               tip =  g_strdup_printf (_("Open %s"), uri);
-
-               verb_name = g_strdup_printf ("%s%s%d", appname,GNOME_RECENT_VERB_NAME, i);
-               cmd = g_strdup_printf ("<cmd name = \"%s\" /> ", verb_name);
-               bonobo_ui_component_set_translate (ui_component, "/commands/", cmd, NULL);
-
-               closure = g_cclosure_new (G_CALLBACK (gnome_recent_view_bonobo_menu_cb),
-                                         md, gnome_recent_view_bonobo_menu_data_destroy_cb);
-                                         
-               bonobo_ui_component_add_verb_full (ui_component, verb_name,
-                                                  closure); 
-               
-               if (i < 10)
-                       label = g_strdup_printf ("_%d. %s", i, escaped_name);
-               else
-                       label = g_strdup_printf ("%d. %s", i, escaped_name);
-                       
-               
-               
-               item_path = g_strconcat (view->path, "/", verb_name, NULL);
-
-               if (bonobo_ui_component_path_exists (ui_component, item_path, NULL))
-               {
-                       bonobo_ui_component_set_prop (ui_component, item_path, 
-                                                     "label", label, NULL);
-
-                       bonobo_ui_component_set_prop (ui_component, item_path, 
-                                                     "tip", tip, NULL);
-               }
-               else
-               {
-                       gchar *xml;
-
-                       xml = g_strdup_printf ("<menuitem name=\"%s\" "
-                                               "verb=\"%s\""
-                                               " _label=\"%s\"  _tip=\"%s\" "
-                                               "hidden=\"0\" />", 
-                                               verb_name, verb_name, label,
-                                               tip);
-
-                       bonobo_ui_component_set_translate (ui_component, view->path, xml, NULL);
-
-                       g_free (xml); 
-               }
-               
-               g_free (label);
-               g_free (verb_name);
-               g_free (tip);
-               g_free (escaped_name);
-               g_free (item_path);
-               g_free (uri);
-               g_free (cmd);
-       }
-
-
-       bonobo_ui_component_thaw (ui_component, NULL);
-}
-
-static void
-model_changed_cb (GnomeRecentModel *model, GSList *list, GnomeRecentViewBonobo *view)
-{
-       gnome_recent_view_bonobo_set_list (view, list);
-}
-
-
-
-static void
-gnome_recent_view_bonobo_populate (GnomeRecentViewBonobo *view)
-{
-       GnomeRecentModel *model;
-       GSList *list;
-
-       model = gnome_recent_view_get_model (GNOME_RECENT_VIEW (view));
-       list = gnome_recent_model_get_list (model);
-
-       gnome_recent_view_bonobo_set_list (view, list);
-}
-
-static GnomeRecentModel *
-gnome_recent_view_bonobo_get_model (GnomeRecentView *view_parent)
-{
-       GnomeRecentViewBonobo *view;
-       
-       g_return_val_if_fail (view_parent, NULL);
-       view = GNOME_RECENT_VIEW_BONOBO (view_parent);
-       
-       return view->model;
-}
-
-static void
-gnome_recent_view_bonobo_set_model (GnomeRecentView *view_parent, GnomeRecentModel *model)
-{
-       GnomeRecentViewBonobo *view;
-       
-       g_return_if_fail (view_parent);
-       view = GNOME_RECENT_VIEW_BONOBO (view_parent);
-       
-       if (view->model)
-               g_signal_handler_disconnect (G_OBJECT (view->model),
-                                            view->changed_cb_id);
-       
-       view->model = model;
-       view->changed_cb_id = g_signal_connect (G_OBJECT (model), "changed",
-                                       G_CALLBACK (model_changed_cb), view);
-
-       gnome_recent_view_bonobo_populate (view);
-}
-
-static void
-gnome_recent_view_bonobo_set_property (GObject *object,
-                          guint prop_id,
-                          const GValue *value,
-                          GParamSpec *pspec)
-{
-       GnomeRecentViewBonobo *view = GNOME_RECENT_VIEW_BONOBO (object);
-
-       switch (prop_id)
-       {
-               case PROP_UI_COMPONENT:
-                       gnome_recent_view_bonobo_set_ui_component (GNOME_RECENT_VIEW_BONOBO (view),
-                                                      BONOBO_UI_COMPONENT (g_value_get_object (value)));
-               break;
-               case PROP_MENU_PATH:
-                       view->path = g_strdup (g_value_get_string (value));
-               break;
-               default:
-               break;
-       }
-}
-
-static void
-gnome_recent_view_bonobo_get_property (GObject *object,
-                          guint prop_id,
-                          GValue *value,
-                          GParamSpec *pspec)
-{
-       GnomeRecentViewBonobo *view = GNOME_RECENT_VIEW_BONOBO (object);
-
-       switch (prop_id)
-       {
-               case PROP_UI_COMPONENT:
-                       g_value_set_pointer (value, view->uic);
-               break;
-               case PROP_MENU_PATH:
-                       g_value_set_string (value, g_strdup (view->path));
-               break;
-               default:
-                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-       }
-}
-
-static void
-gnome_recent_view_bonobo_class_init (GnomeRecentViewBonoboClass * klass)
-{
-       GObjectClass *object_class;
-
-       
-       object_class = G_OBJECT_CLASS (klass);
-
-       object_class->set_property = gnome_recent_view_bonobo_set_property;
-       object_class->get_property = gnome_recent_view_bonobo_get_property;
-
-       gnome_recent_view_bonobo_signals[ACTIVATE] = g_signal_new ("activate",
-                       G_OBJECT_CLASS_TYPE (object_class),
-                       G_SIGNAL_RUN_LAST,
-                       G_STRUCT_OFFSET (GnomeRecentViewBonoboClass, activate),
-                       NULL, NULL,
-                       gnome_recent_BOOLEAN__STRING,
-                       G_TYPE_BOOLEAN, 1,
-                       G_TYPE_STRING);
-
-       g_object_class_install_property (object_class,
-                                        PROP_UI_COMPONENT,
-                                        g_param_spec_object ("ui-component",
-                                          "UI Component",
-                                          "BonoboUIComponent for menus.",
-                                          bonobo_ui_component_get_type(),
-                                          G_PARAM_READWRITE));
-
-       g_object_class_install_property (object_class,
-                                        PROP_MENU_PATH,
-                                        g_param_spec_string ("ui-path",
-                                          "Path",
-                                          "The path to put the menu items.",
-                                          "/menus/File/GnomeRecentDocuments",
-                                          G_PARAM_READWRITE));
-
-
-       klass->activate = NULL;
-}
-
-static void
-gnome_recent_view_init (GnomeRecentViewClass *iface)
-{
-       iface->do_clear = gnome_recent_view_bonobo_clear;
-       iface->do_get_model = gnome_recent_view_bonobo_get_model;
-       iface->do_set_model = gnome_recent_view_bonobo_set_model;
-}
-
-
-static void
-gnome_recent_view_bonobo_init (GnomeRecentViewBonobo * recent)
-{
-       /* maybe should remove this */
-}
-
-void
-gnome_recent_view_bonobo_set_ui_component (GnomeRecentViewBonobo *view, BonoboUIComponent *uic)
-{
-       g_return_if_fail (view);
-       g_return_if_fail (uic);
-
-       view->uic = uic;
-}
-
-void
-gnome_recent_view_bonobo_set_ui_path (GnomeRecentViewBonobo *view, const gchar *path)
-{
-       g_return_if_fail (view);
-       g_return_if_fail (path);
-
-       view->path = g_strdup (path);
-}
-
-BonoboUIComponent *
-gnome_recent_view_bonobo_get_ui_component (GnomeRecentViewBonobo *view)
-{
-       g_return_val_if_fail (view, NULL);
-
-       return view->uic;
-}
-
-gchar *
-gnome_recent_view_bonobo_get_ui_path (GnomeRecentViewBonobo *view)
-{
-       g_return_val_if_fail (view, NULL);
-
-       return g_strdup (view->path);
-}
-
-/**
- * gnome_recent_view_bonobo_new:
- * @appname: The name of your application.
- * @limit:  The maximum number of items allowed.
- *
- * This creates a new GnomeRecentViewBonobo object.
- *
- * Returns: a GnomeRecentViewBonobo object
- */
-GnomeRecentViewBonobo *
-gnome_recent_view_bonobo_new (BonoboUIComponent *uic, const gchar *path)
-{
-       GnomeRecentViewBonobo *view;
-
-       g_return_val_if_fail (uic, NULL);
-       g_return_val_if_fail (path, NULL);
-
-       view = GNOME_RECENT_VIEW_BONOBO (g_object_new (gnome_recent_view_bonobo_get_type (),
-                                          "ui-path",
-                                          path,
-                                          "ui-component",
-                                          uic, NULL));
-
-       g_return_val_if_fail (view, NULL);
-       
-       return view;
-}
-
-/**
- * gnome_recent_view_bonobo_get_type:
- * @:
- *
- * This returns a GType representing a GnomeRecentViewBonobo object.
- *
- * Returns: a GType
- */
-GType
-gnome_recent_view_bonobo_get_type (void)
-{
-       static GType gnome_recent_view_bonobo_type = 0;
-
-       if(!gnome_recent_view_bonobo_type) {
-               static const GTypeInfo gnome_recent_view_bonobo_info = {
-                       sizeof (GnomeRecentViewBonoboClass),
-                       NULL, /* base init */
-                       NULL, /* base finalize */
-                       (GClassInitFunc)gnome_recent_view_bonobo_class_init, /* class init */
-                       NULL, /* class finalize */
-                       NULL, /* class data */
-                       sizeof (GnomeRecentViewBonobo),
-                       0,
-                       (GInstanceInitFunc) gnome_recent_view_bonobo_init
-               };
-
-               static const GInterfaceInfo view_info =
-               {
-                       (GInterfaceInitFunc) gnome_recent_view_init,
-                       NULL,
-                       NULL
-               };
-
-               gnome_recent_view_bonobo_type = g_type_register_static (G_TYPE_OBJECT,
-                                                       "GnomeRecentViewBonobo",
-                                                       &gnome_recent_view_bonobo_info, 0);
-               g_type_add_interface_static (gnome_recent_view_bonobo_type,
-                                            GNOME_TYPE_RECENT_VIEW,
-                                            &view_info);
-       }
-
-       return gnome_recent_view_bonobo_type;
-}
-
diff --git a/glabels2/src/gnome-recent-view-bonobo.h b/glabels2/src/gnome-recent-view-bonobo.h
deleted file mode 100644 (file)
index 92d63f1..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-#ifndef __GNOME_RECENT_VIEW_BONOBO_H__
-#define __GNOME_RECENT_VIEW_BONOBO_H__
-
-#include <libbonoboui.h>
-
-G_BEGIN_DECLS
-
-#define GNOME_RECENT_VIEW_BONOBO(obj)          G_TYPE_CHECK_INSTANCE_CAST (obj, gnome_recent_view_bonobo_get_type (), GnomeRecentViewBonobo)
-#define GNOME_RECENT_VIEW_BONOBO_CLASS(klass)  G_TYPE_CHECK_CLASS_CAST (klass, gnome_recent_view_bonobo_get_type (), GnomeRecentViewBonoboClass)
-#define GNOME_IS_RECENT_VIEW_BONOBO(obj)               G_TYPE_CHECK_INSTANCE_TYPE (obj, gnome_recent_view_bonobo_get_type ())
-
-typedef struct _GnomeRecentViewBonobo GnomeRecentViewBonobo;
-
-typedef struct _GnomeRecentViewBonoboClass GnomeRecentViewBonoboClass;
-
-GType        gnome_recent_view_bonobo_get_type (void);
-
-GnomeRecentViewBonobo * gnome_recent_view_bonobo_new (BonoboUIComponent *uic,
-                                                     const gchar *path);
-
-
-void gnome_recent_view_bonobo_set_ui_component (GnomeRecentViewBonobo *view,
-                                               BonoboUIComponent *uic);
-
-void gnome_recent_view_bonobo_set_ui_path      (GnomeRecentViewBonobo *view,
-                                               const gchar *path);
-
-gchar * gnome_recent_view_bonobo_get_ui_path   (GnomeRecentViewBonobo *view);
-BonoboUIComponent *gnome_recent_view_bonobo_get_ui_component (GnomeRecentViewBonobo *view);
-
-G_END_DECLS
-
-#endif /* __GNOME_RECENT_VIEW_BONOBO_H__ */
diff --git a/glabels2/src/gnome-recent-view.c b/glabels2/src/gnome-recent-view.c
deleted file mode 100644 (file)
index edb145c..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#include <string.h>
-#include <gtk/gtk.h>
-#include "gnome-recent-view.h"
-
-
-GtkType
-gnome_recent_view_get_type (void)
-{
-       static GtkType view_type = 0;
-
-       if (!view_type)
-       {
-               static const GTypeInfo view_info =
-               {
-                       sizeof (GnomeRecentViewClass),  /* class_size */
-                       NULL,                       /* base_init */
-                       NULL,                       /* base_finalize */
-               };
-
-               view_type = g_type_register_static (G_TYPE_INTERFACE,
-                                                   "GnomeRecentView",
-                                                   &view_info, 0);
-       }
-
-       return view_type;
-}
-
-void
-gnome_recent_view_clear (GnomeRecentView *view)
-{
-       g_return_if_fail (GNOME_IS_RECENT_VIEW (view));
-  
-       GNOME_RECENT_VIEW_GET_CLASS (view)->do_clear (view);
-}
-
-GnomeRecentModel *
-gnome_recent_view_get_model (GnomeRecentView *view)
-{
-       g_return_val_if_fail (view, NULL);
-
-       return GNOME_RECENT_VIEW_GET_CLASS (view)->do_get_model (view);
-}
-
-void
-gnome_recent_view_set_model (GnomeRecentView *view, GnomeRecentModel *model)
-{
-       g_return_if_fail (view);
-       g_return_if_fail (model);
-
-       GNOME_RECENT_VIEW_GET_CLASS (view)->do_set_model (view, model);
-}
diff --git a/glabels2/src/gnome-recent-view.h b/glabels2/src/gnome-recent-view.h
deleted file mode 100644 (file)
index aedf67c..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef __GNOME_RECENT_VIEW_H__
-#define __GNOME_RECENT_VIEW_H__
-
-
-#include <gdk/gdk.h>
-#include <gtk/gtkwidget.h>
-#include "gnome-recent-model.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-
-#define GNOME_TYPE_RECENT_VIEW             (gnome_recent_view_get_type ())
-#define GNOME_RECENT_VIEW(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_RECENT_VIEW, GnomeRecentView))
-#define GNOME_RECENT_VIEW_CLASS(vtable)    (G_TYPE_CHECK_CLASS_CAST ((vtable), GNOME_TYPE_RECENT_VIEW, GnomeRecentViewClass))
-#define GNOME_IS_RECENT_VIEW(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_RECENT_VIEW))
-#define GNOME_IS_RECENT_VIEW_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), GNOME_TYPE_RECENT_VIEW))
-#define GNOME_RECENT_VIEW_GET_CLASS(inst)  (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GNOME_TYPE_RECENT_VIEW, GnomeRecentViewClass))
-
-typedef struct _GnomeRecentView       GnomeRecentView;         /* Dummy typedef */
-typedef struct _GnomeRecentViewClass  GnomeRecentViewClass;
-
-struct _GnomeRecentViewClass
-{
-  GTypeInterface                  base_iface;
-  
-  /* vtable, not signals */
-  void (* do_clear)                            (GnomeRecentView *view);
-  void (* do_set_model)                                (GnomeRecentView *view,
-                                                GnomeRecentModel *model);
-  GnomeRecentModel * (* do_get_model)          (GnomeRecentView *view);
-};
-
-GtkType  gnome_recent_view_get_type            (void) G_GNUC_CONST;
-void     gnome_recent_view_set_list            (GnomeRecentView *view,
-                                                GSList *list);
-void     gnome_recent_view_clear               (GnomeRecentView *view);
-GnomeRecentModel *gnome_recent_view_get_model   (GnomeRecentView *view);
-void    gnome_recent_view_set_model            (GnomeRecentView *view,
-                                                GnomeRecentModel *model);
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __GNOME_RECENT_VIEW_H__ */
index 6e0e40dfd3f77eae72569e6fd8421612ebd79ca9..cac3426d8dc394c91952c152b95d5f3b26a91d6e 100644 (file)
 
 #include "debug.h"
 
-static GnomeRecentModel *model;
+static EggRecentModel *model;
 
+/**
+ * unescape_string:
+ * @escaped_string: an escaped URI, path, or other string
+ * @illegal_characters: a string containing a sequence of characters
+ * considered "illegal", '\0' is automatically in this list.
+ *
+ * Decodes escaped characters (i.e. PERCENTxx sequences) in @escaped_string.
+ * Characters are encoded in PERCENTxy form, where xy is the ASCII hex code 
+ * for character 16x+y.
+ * 
+ * Return value: a newly allocated string with the unescaped equivalents, 
+ * or %NULL if @escaped_string contained one of the characters 
+ * in @illegal_characters.
+ *
+ * this code comes from gnome-vfs-utils.c
+ **/
+
+#define HEX_ESCAPE '%'
+
+static int
+hex_to_int (gchar c)
+{
+       return  c >= '0' && c <= '9' ? c - '0'
+               : c >= 'A' && c <= 'F' ? c - 'A' + 10
+               : c >= 'a' && c <= 'f' ? c - 'a' + 10
+               : -1;
+}
+
+static int
+unescape_character (const char *scanner)
+{
+       int first_digit;
+       int second_digit;
+
+       first_digit = hex_to_int (*scanner++);
+       if (first_digit < 0) {
+               return -1;
+       }
+
+       second_digit = hex_to_int (*scanner++);
+       if (second_digit < 0) {
+               return -1;
+       }
+
+       return (first_digit << 4) | second_digit;
+}
+
+static char *
+unescape_string (const gchar *escaped_string, 
+                const gchar *illegal_characters)
+{
+       const gchar *in;
+       gchar *out, *result;
+       gint character;
+
+       if (escaped_string == NULL) {
+               return NULL;
+       }
+
+       result = g_malloc (strlen (escaped_string) + 1);
+       
+       out = result;
+       for (in = escaped_string; *in != '\0'; in++) {
+               character = *in;
+               if (*in == HEX_ESCAPE) {
+                       character = unescape_character (in + 1);
+
+                       /* Check for an illegal character. We consider '\0' illegal here. */
+                       if (character <= 0
+                           || (illegal_characters != NULL
+                               && strchr (illegal_characters, (char)character) != NULL)) {
+                               g_free (result);
+                               return NULL;
+                       }
+                       in += 2;
+               }
+               *out++ = (char)character;
+       }
+       
+       *out = '\0';
+       g_assert (out - result <= strlen (escaped_string));
+       return result;
+       
+}
+
+gchar *
+gl_recent_get_filename (EggRecentItem *item)
+{
+       char *uri, *filename;
+       char *utf8_filename = NULL;
+       int prefix_len = strlen ("file://");
+       gboolean result = FALSE;
+
+        uri = egg_recent_item_get_uri (item);
+
+       if (strlen (uri) > prefix_len) { 
+               filename = unescape_string (uri + prefix_len, "");
+               utf8_filename = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
+               g_free (filename);
+       }
+       
+        g_free (uri);
+
+        return utf8_filename;
+}
+
+void
+gl_recent_add_uri (gchar *uri)
+{
+       EggRecentItem *item;
+       
+       gl_debug (DEBUG_RECENT, "add_uri = %s", uri);
+
+       item = egg_recent_item_new_from_uri (uri);
+       egg_recent_item_add_group (item, "glabels");
+       egg_recent_model_add_full (model, item);
+       egg_recent_item_unref (item); 
+}
 
-GnomeRecentModel *
+EggRecentModel *
 gl_recent_get_model (void)
 {
        return model;
@@ -41,5 +159,9 @@ gl_recent_init (void)
 {
        gl_debug (DEBUG_RECENT, "max_recents = %d", gl_prefs->max_recents);
 
-       model = gnome_recent_model_new ("glabels", gl_prefs->max_recents);
+       model = egg_recent_model_new (EGG_RECENT_MODEL_SORT_MRU);
+       egg_recent_model_set_limit (model,
+                                   gl_prefs->max_recents);
+       egg_recent_model_set_filter_groups (model, "glabels", NULL);
+        egg_recent_model_set_filter_uri_schemes (model, "file", NULL); 
 }
index 0be911d15a0647a79ad0dc96386b6245549cb8b9..d3616997e89451d57cfadd54d8fbdb337d676517 100644 (file)
 #ifndef __RECENT_H__
 #define __RECENT_H__
 
-#include "gnome-recent-model.h"
+#include "recent-files/egg-recent-model.h"
 
 
-GnomeRecentModel * gl_recent_get_model (void);
-void               gl_recent_init (void);
+gchar *                gl_recent_get_filename (EggRecentItem *item);
+void                   gl_recent_add_uri (gchar *uri);
+EggRecentModel *       gl_recent_get_model (void);
+void                   gl_recent_init (void);
 
 #endif /*__RECENT_H__*/
 
index efd13926bd809e52098171b90a3b4176084bd65a..4efd9219463997255e92ded0f313b69cfd376a42 100644 (file)
@@ -21,7 +21,8 @@
  */
 #include <config.h>
 
-#include "gnome-recent-view.h"
+#include "recent-files/egg-recent-view.h"
+#include "recent-files/egg-recent-view-bonobo.h"
 #include <gconf/gconf-client.h>
 
 #include "ui.h"
@@ -221,9 +222,9 @@ gl_ui_init (BonoboUIComponent *ui_component,
            GtkWidget         *cursor_info_frame,
            GtkWidget         *zoom_info_frame)
 {
-        GnomeRecentView  *recent_view;
-        GnomeRecentModel *recent_model;
-       BonoboControl    *control;
+        EggRecentView  *recent_view;
+        EggRecentModel         *recent_model;
+       BonoboControl   *control;
 
        gl_debug (DEBUG_UI, "START");
 
@@ -321,12 +322,12 @@ gl_ui_init (BonoboUIComponent *ui_component,
        /* 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);
+               EGG_RECENT_VIEW (egg_recent_view_bonobo_new (ui_component,
+                                                              "/menu/File/Recents"));
+       egg_recent_view_set_model (recent_view, recent_model);
+
+       g_signal_connect (G_OBJECT (recent_view), "activate",
+                         G_CALLBACK (gl_file_open_recent), win);
 
        gl_debug (DEBUG_UI, "END");
 }
index 19d4c7e7e66aeaf3684e4b7e368441f54f655437..9df777b3684f50376a837b6d13c50acebede53f6 100644 (file)
@@ -160,14 +160,18 @@ static void           xml_create_toplevel_span (xmlNodePtr        node,
 /* Open and read label from xml file.                                       */
 /****************************************************************************/
 glLabel *
-gl_xml_label_open (const gchar      *filename,
+gl_xml_label_open (const gchar      *utf8_filename,
                   glXMLLabelStatus *status)
 {
        xmlDocPtr  doc;
        glLabel   *label;
+       gchar     *filename;
 
        gl_debug (DEBUG_XML, "START");
 
+       filename = g_filename_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
+       g_return_val_if_fail (filename, NULL);
+
        doc = xmlParseFile (filename);
        if (!doc) {
                g_warning (_("xmlParseFile error"));
@@ -183,10 +187,11 @@ gl_xml_label_open (const gchar      *filename,
        xmlFreeDoc (doc);
 
        if (label) {
-               gl_label_set_filename (label, filename);
+               gl_label_set_filename (label, utf8_filename);
                gl_label_clear_modified (label);
        }
 
+       g_free (filename);
        gl_debug (DEBUG_XML, "END");
 
        return label;
@@ -917,29 +922,36 @@ xml_parse_toplevel_span  (xmlNodePtr        node,
 /****************************************************************************/
 void
 gl_xml_label_save (glLabel          *label,
-                  const gchar      *filename,
+                  const gchar      *utf8_filename,
                   glXMLLabelStatus *status)
 {
        xmlDocPtr doc;
        gint      xml_ret;
+       gchar     *filename;
 
        gl_debug (DEBUG_XML, "START");
 
        doc = xml_label_to_doc (label, status);
 
-       xmlSetDocCompressMode (doc, 9);
-       xml_ret = xmlSaveFormatFile (filename, doc, TRUE);
-       xmlFreeDoc (doc);
-       if (xml_ret == -1) {
+       filename = g_filename_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
+       if (!filename)
+               g_warning (_("Utf8 conversion error."));
+       else {
+               xmlSetDocCompressMode (doc, 9);
+               xml_ret = xmlSaveFormatFile (filename, doc, TRUE);
+               xmlFreeDoc (doc);
+               if (xml_ret == -1) {
 
-               g_warning (_("Problem saving xml file."));
-               *status = XML_LABEL_ERROR_SAVE_FILE;
+                       g_warning (_("Problem saving xml file."));
+                       *status = XML_LABEL_ERROR_SAVE_FILE;
 
-       } else {
+               } else {
 
-               gl_label_set_filename (label, filename);
-               gl_label_clear_modified (label);
+                       gl_label_set_filename (label, utf8_filename);
+                       gl_label_clear_modified (label);
 
+               }
+               g_free (filename);
        }
 
        gl_debug (DEBUG_XML, "END");