]> www.fi.muni.cz Git - evince.git/commitdiff
Put the toolbar xml in evince own dot dir
authorMarco Pesenti Gritti <mpg@redhat.com>
Tue, 10 May 2005 12:48:34 +0000 (12:48 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Tue, 10 May 2005 12:48:34 +0000 (12:48 +0000)
2005-05-10  Marco Pesenti Gritti  <mpg@redhat.com>

        * lib/Makefile.am:
        * shell/ev-window.c: (ev_window_cmd_edit_toolbar_cb),
        (ev_window_init):
        * shell/main.c: (main):

        Put the toolbar xml in evince own dot dir

ChangeLog
lib/Makefile.am
lib/ev-file-helpers.c [new file with mode: 0644]
lib/ev-file-helpers.h [new file with mode: 0644]
shell/ev-window.c
shell/main.c

index 5e72f8637b8037954a88f9db69381740b212dae5..e474af63dca6189778c3a8cf1519f9007e3ed5bc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-05-10  Marco Pesenti Gritti  <mpg@redhat.com>
+
+       * lib/Makefile.am:
+       * shell/ev-window.c: (ev_window_cmd_edit_toolbar_cb),
+       (ev_window_init):
+       * shell/main.c: (main):
+
+       Put the toolbar xml in evince own dot dir
+
 2005-05-10  Marco Pesenti Gritti  <mpg@redhat.com>
 
        * shell/ev-window.c: (ev_window_init):
index 9a3bd51ae39e9869d9fc994ff434a181373936fa..6bcfc2e7e98b8222d473165cc466c0f05db89c74 100644 (file)
@@ -12,4 +12,6 @@ noinst_LTLIBRARIES = libev.la
 libev_la_SOURCES=                              \
        ev-debug.c                              \
        ev-debug.h                              \
+       ev-file-helpers.c                       \
+       ev-file-helpers.h                       \
        $(NULL)
diff --git a/lib/ev-file-helpers.c b/lib/ev-file-helpers.c
new file mode 100644 (file)
index 0000000..d9daf6a
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ *  Copyright (C) 2002 Jorn Baayen
+ *
+ *  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, 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.
+ *
+ *  $Id$
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/stat.h>
+#include <glib.h>
+#include <libgnome/gnome-init.h>
+
+#include "ev-file-helpers.h"
+
+static char *dot_dir = NULL;
+
+static gboolean
+ensure_dir_exists (const char *dir)
+{
+       if (g_file_test (dir, G_FILE_TEST_IS_DIR) == FALSE)
+       {
+               if (g_file_test (dir, G_FILE_TEST_EXISTS) == TRUE)
+               {
+                       g_warning ("%s exists, please move it out of the way.", dir);
+                       return FALSE;
+               }
+
+               if (mkdir (dir, 488) != 0)
+               {
+                       g_warning ("Failed to create directory %s.", dir);
+                       return FALSE;
+               }
+       }
+
+       return TRUE;
+}
+
+const char *
+ev_dot_dir (void)
+{
+       if (dot_dir == NULL)
+       {
+               gboolean exists;
+
+               dot_dir = g_build_filename (g_get_home_dir (),
+                                           GNOME_DOT_GNOME,
+                                           "evince",
+                                           NULL);
+
+               exists = ensure_dir_exists (dot_dir);
+               g_assert (exists);
+       }
+
+       return dot_dir;
+}
+
+void
+ev_file_helpers_init (void)
+{
+}
+
+void
+ev_file_helpers_shutdown (void)
+{
+       g_free (dot_dir);
+       dot_dir = NULL;
+}
diff --git a/lib/ev-file-helpers.h b/lib/ev-file-helpers.h
new file mode 100644 (file)
index 0000000..43dc75c
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ *  Copyright (C) 2002 Jorn Baayen
+ *
+ *  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, 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.
+ *
+ *  $Id$
+ */
+
+#ifndef EPHY_FILE_HELPERS_H
+#define EPHY_FILE_HELPERS_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+const char *ev_dot_dir               (void);
+
+void        ev_file_helpers_init     (void);
+
+void        ev_file_helpers_shutdown (void);
+
+G_END_DECLS
+
+#endif /* EPHY_FILE_HELPERS_H */
index 6a6e00d0f14deda59ecac856bc39cfefe3062c32..2db012df0006f153d79a61ec20eb203922764576 100644 (file)
@@ -52,6 +52,9 @@
 #include "egg-editable-toolbar.h"
 #include "ephy-zoom.h"
 #include "ephy-zoom-action.h"
+#include "ev-application.h"
+#include "ev-stock-icons.h"
+#include "ev-file-helpers.h"
 
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
@@ -66,9 +69,6 @@
 
 #include <string.h>
 
-#include "ev-application.h"
-#include "ev-stock-icons.h"
-
 typedef enum {
        PAGE_MODE_SINGLE_PAGE,
        PAGE_MODE_CONTINUOUS_PAGE,
@@ -1666,8 +1666,10 @@ static void
 ev_window_cmd_edit_toolbar_cb (GtkDialog *dialog, gint response, gpointer data)
 {
        EvWindow *ev_window = EV_WINDOW (data);
-        egg_editable_toolbar_set_edit_mode (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar), FALSE);
-        egg_toolbars_model_save (ev_window->priv->toolbar_model, ev_window->priv->toolbar_file, "1.0");
+        egg_editable_toolbar_set_edit_mode
+                       (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar), FALSE);
+        egg_toolbars_model_save (ev_window->priv->toolbar_model,
+                                ev_window->priv->toolbar_file, "1.0");
         gtk_widget_destroy (GTK_WIDGET (dialog));
 }
 
@@ -2714,7 +2716,7 @@ ev_window_init (EvWindow *ev_window)
        ev_window->priv->toolbar_model = egg_toolbars_model_new ();
        
        ev_window->priv->toolbar_file = g_build_filename
-                       (g_get_home_dir (), ".gnome2/evince_toolbar.xml", NULL);
+                       (ev_dot_dir (), "evince_toolbar.xml", NULL);
 
        if (!g_file_test (ev_window->priv->toolbar_file, G_FILE_TEST_EXISTS)) {
                egg_toolbars_model_load (ev_window->priv->toolbar_model,
index 321334b03d93a59de197dd2da2fc1651adfc21e9..b0a0b76a3afc5796b3ae6261fedeba931fecb1a6 100644 (file)
@@ -32,6 +32,7 @@
 #include "ev-stock-icons.h"
 #include "ev-debug.h"
 #include "ev-job-queue.h"
+#include "ev-file-helpers.h"
 
 static struct poptOption popt_options[] =
 {
@@ -87,6 +88,7 @@ main (int argc, char *argv[])
        ev_job_queue_init ();
        g_set_application_name (_("Evince Document Viewer"));
 
+       ev_file_helpers_init ();
        ev_debug_init ();
        ev_stock_icons_init ();
        gtk_window_set_default_icon_name ("postscript-viewer");
@@ -102,6 +104,7 @@ main (int argc, char *argv[])
 
        gnome_accelerators_sync ();
        poptFreeContext (context);
+       ev_file_helpers_shutdown ();
 
        return 0;
 }