+2005-07-07 Marco Pesenti Gritti <mpg@redhat.com>
+
+ * shell/ev-metadata-manager.c: (ev_metadata_manager_init),
+ (ev_metadata_manager_get), (ev_metadata_manager_set):
+ * shell/ev-metadata-manager.h:
+
+ Add an _init functions that enabled metadata management
+ at runtime.
+
+ * shell/ev-window.c: (page_changed_cb),
+ (setup_document_from_metadata), (ev_window_setup_document),
+ (setup_view_from_metadata), (ev_window_open_uri),
+ (ev_window_run_fullscreen), (ev_window_stop_fullscreen),
+ (ev_window_run_presentation), (ev_window_stop_presentation),
+ (save_sizing_mode), (ev_window_zoom_changed_cb),
+ (ev_window_continuous_changed_cb),
+ (ev_window_dual_mode_changed_cb), (window_state_event_cb),
+ (window_configure_event_cb):
+
+ Remove all ugly metadata define since we deal with it
+ at runtime now.
+
+ * shell/main.c: (load_files_remote), (main):
+
+ Add support for dbus cvs head. Hopefully didnt break one
+ of the other versions now!
+
+ If we dont get a response from the dbus server just
+ give up with it and not enable metadata.
+
2005-07-07 Marco Pesenti Gritti <mpg@redhat.com>
* Makefile.am:
g_free (item);
}
-static gboolean
+void
ev_metadata_manager_init (void)
{
- if (ev_metadata_manager != NULL)
- return TRUE;
-
ev_metadata_manager = g_new0 (GeditMetadataManager, 1);
ev_metadata_manager->values_loaded = FALSE;
(GSourceFunc)ev_metadata_manager_save,
NULL,
NULL);
-
- return TRUE;
}
/* This function must be called before exiting ev */
g_return_val_if_fail (key != NULL, FALSE);
if (ev_metadata_manager == NULL)
- ev_metadata_manager_init ();
+ return FALSE;
if (!ev_metadata_manager->values_loaded)
{
g_return_if_fail (key != NULL);
if (ev_metadata_manager == NULL)
- ev_metadata_manager_init ();
+ return;
if (!ev_metadata_manager->values_loaded)
{
G_BEGIN_DECLS
+void ev_metadata_manager_init (void);
gboolean ev_metadata_manager_get (const gchar *uri,
const gchar *key,
GValue *value);
{
update_action_sensitivity (ev_window);
-#ifdef ENABLE_METADATA
ev_metadata_manager_set_int (ev_window->priv->uri, "page", page);
-#endif
}
static void
}
}
-#ifdef ENABLE_METADATA
static void
setup_document_from_metadata (EvWindow *window)
{
}
}
-#endif
static void
ev_window_setup_document (EvWindow *ev_window)
ev_window->priv->document);
}
-#ifdef ENABLE_METADATA
setup_document_from_metadata (ev_window);
-#endif
}
static void
}
}
-#ifdef ENABLE_METADATA
static void
setup_view_from_metadata (EvWindow *window)
{
}
}
}
-#endif
void
ev_window_open_uri (EvWindow *ev_window, const char *uri)
g_free (ev_window->priv->uri);
ev_window->priv->uri = g_strdup (uri);
-#ifdef ENABLE_METADATA
setup_view_from_metadata (ev_window);
-#endif
ev_window_clear_jobs (ev_window);
ev_window_clear_local_uri (ev_window);
gtk_window_fullscreen (GTK_WINDOW (window));
ev_window_update_fullscreen_popup (window);
-#ifdef ENABLE_METADATA
ev_metadata_manager_set_boolean (window->priv->uri, "fullscreen", TRUE);
-#endif
}
static void
gtk_window_unfullscreen (GTK_WINDOW (window));
update_chrome_visibility (window);
-#ifdef ENABLE_METADATA
ev_metadata_manager_set_boolean (window->priv->uri, "fullscreen", FALSE);
-#endif
}
static void
ev_window_update_presentation_action (window);
update_chrome_visibility (window);
-#ifdef ENABLE_METADATA
ev_metadata_manager_set_boolean (window->priv->uri, "presentation", TRUE);
-#endif
}
static void
ev_window_update_presentation_action (window);
update_chrome_visibility (window);
-#ifdef ENABLE_METADATA
ev_metadata_manager_set_boolean (window->priv->uri, "presentation", FALSE);
-#endif
}
static void
static void
save_sizing_mode (EvWindow *window)
{
-#ifdef ENABLE_METADATA
EvSizingMode mode;
GEnumValue *enum_value;
ev_metadata_manager_set_string (window->priv->uri, "sizing_mode",
enum_value->value_nick);
}
-#endif
}
static void
{
update_action_sensitivity (ev_window);
-#ifdef ENABLE_METADATA
if (ev_view_get_sizing_mode (view) == EV_SIZING_FREE) {
ev_metadata_manager_set_double (ev_window->priv->uri, "zoom",
ev_view_get_zoom (view));
}
-#endif
}
static void
{
ev_window_update_continuous_action (ev_window);
-#ifdef ENABLE_METADATA
ev_metadata_manager_set_boolean (ev_window->priv->uri, "continuous",
ev_view_get_continuous (EV_VIEW (ev_window->priv->view)));
-#endif
}
static void
{
ev_window_update_dual_page_action (ev_window);
-#ifdef ENABLE_METADATA
ev_metadata_manager_set_boolean (ev_window->priv->uri, "dual-page",
ev_view_get_dual_page (EV_VIEW (ev_window->priv->view)));
-#endif
}
static char *
static gboolean
window_state_event_cb (EvWindow *window, GdkEventWindowState *event, gpointer dummy)
{
-#ifdef ENABLE_METADATA
char *uri = window->priv->uri;
if (uri && !(event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)) {
maximized = event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED;
ev_metadata_manager_set_boolean (uri, "window_maximized", maximized);
}
-#endif
return FALSE;
}
static gboolean
window_configure_event_cb (EvWindow *window, GdkEventConfigure *event, gpointer dummy)
{
-#ifdef ENABLE_METADATA
char *uri = window->priv->uri;
GdkWindowState state;
int x, y, width, height;
ev_metadata_manager_set_int (uri, "window_width", width);
ev_metadata_manager_set_int (uri, "window_height", height);
}
-#endif
return FALSE;
}
}
#ifdef ENABLE_DBUS
-static void
+static gboolean
load_files_remote (const char **files)
{
int i;
GError *error = NULL;
DBusGConnection *connection;
+#if DBUS_VERSION < 35
DBusGPendingCall *call;
+#endif
DBusGProxy *remote_object;
connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (connection == NULL) {
g_warning (error->message);
- g_error_free (error);
-
- return;
+ g_error_free (error);
+
+ return FALSE;
}
remote_object = dbus_g_proxy_new_for_name (connection,
"/org/gnome/evince/Evince",
"org.gnome.evince.Application");
if (!files) {
+#if DBUS_VERSION < 35
call = dbus_g_proxy_begin_call (remote_object, "OpenWindow", G_TYPE_INVALID);
if (!dbus_g_proxy_end_call (remote_object, call, &error, G_TYPE_INVALID)) {
g_warning (error->message);
g_clear_error (&error);
+ return FALSE;
}
- return;
+#else
+ if (!dbus_g_proxy_call (remote_object, "OpenWindow", &error, G_TYPE_INVALID)) {
+ g_warning (error->message);
+ g_clear_error (&error);
+ return FALSE;
+ }
+#endif
+ return TRUE;
}
for (i = 0; files[i]; i++) {
+ gboolean result = TRUE;
const char *page_label;
char *uri;
uri = gnome_vfs_make_uri_from_shell_arg (files[i]);
page_label = ev_page_label ? ev_page_label : "";
-
+#if DBUS_VERSION < 35
call = dbus_g_proxy_begin_call (remote_object, "OpenURI",
G_TYPE_STRING, uri,
G_TYPE_STRING, page_label,
if (!dbus_g_proxy_end_call (remote_object, call, &error, G_TYPE_INVALID)) {
g_warning (error->message);
g_clear_error (&error);
+ result = FALSE;
}
-
+#else
+ if (!dbus_g_proxy_call (remote_object, "OpenURI", &error,
+ G_TYPE_STRING, uri,
+ G_TYPE_STRING, page_label,
+ G_TYPE_INVALID)) {
+ g_warning (error->message);
+ g_clear_error (&error);
+ result = FALSE;
+ }
+#endif
g_free (uri);
+ return result;
}
+
+ return TRUE;
}
#endif /* ENABLE_DBUS */
int
main (int argc, char *argv[])
{
+#ifdef ENABLE_METADATA
+ gboolean enable_metadata = FALSE;
+#endif
poptContext context;
GValue context_as_value = { 0 };
GnomeProgram *program;
#ifdef ENABLE_DBUS
if (!ev_application_register_service (EV_APP)) {
- load_files_remote (poptGetArgs (context));
- g_warning ("Another process was running.");
- return 0;
+ if (load_files_remote (poptGetArgs (context))) {
+ g_warning ("Another process was running.");
+ return 0;
+ }
} else {
g_warning ("Starting evince process.");
+ enable_metadata = TRUE;
}
#endif
gnome_authentication_manager_init ();
+#if ENABLE_METADATA
+ if (enable_metadata) {
+ ev_metadata_manager_init ();
+ }
+#endif
+
ev_job_queue_init ();
g_set_application_name (_("Evince Document Viewer"));
gnome_accelerators_sync ();
poptFreeContext (context);
ev_file_helpers_shutdown ();
+
#if ENABLE_METADATA
- ev_metadata_manager_shutdown ();
+ if (enable_metadata) {
+ ev_metadata_manager_shutdown ();
+ }
#endif
return 0;