#include <config.h>
+#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "ev-application.h"
#include "ev-document-factory.h"
#include "ev-file-helpers.h"
+#include "ev-metadata-manager.h"
#include "ev-utils.h"
#ifdef ENABLE_DBUS
struct _EvApplication {
GObject base_instance;
+ gchar *dot_dir;
gchar *accel_map_file;
-
gchar *toolbars_file;
EggToolbarsModel *toolbars_model;
GObjectClass base_class;
};
+static EvApplication *instance;
+
G_DEFINE_TYPE (EvApplication, ev_application, G_TYPE_OBJECT);
#define APPLICATION_SERVICE_NAME "org.gnome.evince.ApplicationService"
G_OBJECT (application));
application->scr_saver = totem_scrsaver_new (connection);
-
+
+ ev_metadata_manager_init ();
+
return TRUE;
}
#endif /* ENABLE_DBUS */
EvApplication *
ev_application_get_instance (void)
{
- static EvApplication *instance;
-
if (!instance) {
instance = EV_APPLICATION (g_object_new (EV_TYPE_APPLICATION, NULL));
}
if (!GTK_WIDGET_REALIZED (new_window))
gtk_widget_realize (new_window);
+#ifdef GDK_WINDOWING_X11
if (timestamp <= 0)
timestamp = gdk_x11_get_server_time (GTK_WIDGET (new_window)->window);
gdk_x11_window_set_user_time (GTK_WIDGET (new_window)->window, timestamp);
gtk_window_present (GTK_WINDOW (new_window));
+#else
+ gtk_window_present_with_time (GTK_WINDOW (new_window), timestamp);
+#endif /* GDK_WINDOWING_X11 */
return TRUE;
}
if (!GTK_WIDGET_REALIZED (GTK_WIDGET (new_window)))
gtk_widget_realize (GTK_WIDGET (new_window));
+#ifdef GDK_WINDOWING_X11
if (timestamp <= 0)
timestamp = gdk_x11_get_server_time (GTK_WIDGET (new_window)->window);
gdk_x11_window_set_user_time (GTK_WIDGET (new_window)->window, timestamp);
ev_document_fc_mutex_lock ();
gtk_window_present (GTK_WINDOW (new_window));
ev_document_fc_mutex_unlock ();
+#else
+ ev_document_fc_mutex_lock ();
+ gtk_window_present_with_time (GTK_WINDOW (new_window), timestamp);
+ ev_document_fc_mutex_unlock ();
+#endif /* GDK_WINDOWING_X11 */
}
/**
}
#endif /* ENABLE_DBUS */
+ ev_metadata_manager_shutdown ();
+
+ g_free (application->dot_dir);
+ application->dot_dir = NULL;
g_free (application->last_chooser_uri);
+ application->last_chooser_uri = NULL;
+
g_object_unref (application);
+ instance = NULL;
gtk_main_quit ();
}
ev_application_init_session (ev_application);
+ ev_application->dot_dir = g_build_filename (g_get_home_dir (),
+ ".gnome2",
+ "evince",
+ NULL);
+
+ /* FIXME: why make this fatal? */
+ if (!ev_dir_ensure_exists (ev_application->dot_dir, 0700))
+ exit (1);
+
home_dir = g_get_home_dir ();
if (home_dir) {
ev_application->accel_map_file = g_build_filename (home_dir,
ev_application->toolbars_model = egg_toolbars_model_new ();
ev_application->toolbars_file = g_build_filename
- (ev_dot_dir (), "evince_toolbar.xml", NULL);
+ (ev_application->dot_dir, "evince_toolbar.xml", NULL);
egg_toolbars_model_load_names (ev_application->toolbars_model,
DATADIR "/evince-toolbar.xml");
application->print_settings_file = g_key_file_new ();
- filename = g_build_filename (ev_dot_dir (), EV_PRINT_SETTINGS_FILE, NULL);
+ filename = g_build_filename (ev_application_get_dot_dir (application), EV_PRINT_SETTINGS_FILE, NULL);
if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
GError *error = NULL;
key_file,
EV_PAGE_SETUP_GROUP);
- filename = g_build_filename (ev_dot_dir (), EV_PRINT_SETTINGS_FILE, NULL);
+ filename = g_build_filename (ev_application_get_dot_dir (application), EV_PRINT_SETTINGS_FILE, NULL);
data = g_key_file_to_data (key_file, (gsize *)&data_length, NULL);
g_file_set_contents (filename, data, data_length, &error);
if (error) {
application->page_setup = g_object_ref (page_setup);
gtk_page_setup_to_key_file (page_setup, key_file, EV_PAGE_SETUP_GROUP);
}
+
+const gchar *
+ev_application_get_dot_dir (EvApplication *application)
+{
+ return application->dot_dir;
+}