summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2014-01-21 17:11:27 +0100
committerStefano Karapetsas <[email protected]>2014-01-21 17:11:27 +0100
commite4540e7be4b396c8b1bb34157c105e172ccdf0a1 (patch)
tree746a48a9c7256268879e5c48b5fe31d2e94d5af7 /shell
parent75173c8f5ebdac9a095a466af602d6b07324029f (diff)
downloadatril-e4540e7be4b396c8b1bb34157c105e172ccdf0a1.tar.bz2
atril-e4540e7be4b396c8b1bb34157c105e172ccdf0a1.tar.xz
shell: Add GTK3 support
Diffstat (limited to 'shell')
-rw-r--r--shell/eggfindbar.c3
-rw-r--r--shell/ev-annotation-properties-dialog.c30
-rw-r--r--shell/ev-application.c66
-rw-r--r--shell/ev-convert-metadata.c4
-rw-r--r--shell/ev-password-view.c2
-rw-r--r--shell/ev-properties-dialog.c2
-rw-r--r--shell/ev-sidebar-attachments.c16
-rw-r--r--shell/ev-sidebar-thumbnails.c2
-rw-r--r--shell/ev-sidebar.c24
-rw-r--r--shell/ev-window.c2
-rw-r--r--shell/main.c22
11 files changed, 109 insertions, 64 deletions
diff --git a/shell/eggfindbar.c b/shell/eggfindbar.c
index b557b44b..f4932160 100644
--- a/shell/eggfindbar.c
+++ b/shell/eggfindbar.c
@@ -23,6 +23,9 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
+#if GTK_CHECK_VERSION (3, 0, 0)
+#include <gdk/gdkkeysyms-compat.h>
+#endif
#include "eggfindbar.h"
diff --git a/shell/ev-annotation-properties-dialog.c b/shell/ev-annotation-properties-dialog.c
index 837d6164..40f8a972 100644
--- a/shell/ev-annotation-properties-dialog.c
+++ b/shell/ev-annotation-properties-dialog.c
@@ -100,17 +100,17 @@ ev_annotation_properties_dialog_constructed (GObject *object)
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
- dialog->icon = gtk_combo_box_new_text ();
- gtk_combo_box_append_text (GTK_COMBO_BOX (dialog->icon), _("Note"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (dialog->icon), _("Comment"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (dialog->icon), _("Key"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (dialog->icon), _("Help"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (dialog->icon), _("New Paragraph"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (dialog->icon), _("Paragraph"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (dialog->icon), _("Insert"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (dialog->icon), _("Cross"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (dialog->icon), _("Circle"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (dialog->icon), _("Unknown"));
+ dialog->icon = gtk_combo_box_text_new ();
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (dialog->icon), _("Note"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (dialog->icon), _("Comment"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (dialog->icon), _("Key"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (dialog->icon), _("Help"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (dialog->icon), _("New Paragraph"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (dialog->icon), _("Paragraph"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (dialog->icon), _("Insert"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (dialog->icon), _("Cross"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (dialog->icon), _("Circle"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (dialog->icon), _("Unknown"));
gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->icon), 0);
gtk_table_attach (GTK_TABLE (table), dialog->icon,
1, 2, 5, 6,
@@ -139,7 +139,9 @@ ev_annotation_properties_dialog_init (EvAnnotationPropertiesDialog *annot_dialog
gtk_window_set_title (GTK_WINDOW (annot_dialog), _("Annotation Properties"));
gtk_window_set_destroy_with_parent (GTK_WINDOW (annot_dialog), TRUE);
gtk_container_set_border_width (GTK_CONTAINER (annot_dialog), 5);
+#if !GTK_CHECK_VERSION (3, 0, 0)
gtk_dialog_set_has_separator (dialog, FALSE);
+#endif
gtk_dialog_add_buttons (dialog,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
GTK_STOCK_APPLY, GTK_RESPONSE_APPLY,
@@ -222,9 +224,9 @@ ev_annotation_properties_dialog_init (EvAnnotationPropertiesDialog *annot_dialog
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
- annot_dialog->popup_state = gtk_combo_box_new_text ();
- gtk_combo_box_append_text (GTK_COMBO_BOX (annot_dialog->popup_state), _("Open"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (annot_dialog->popup_state), _("Close"));
+ annot_dialog->popup_state = gtk_combo_box_text_new ();
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (annot_dialog->popup_state), _("Open"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (annot_dialog->popup_state), _("Close"));
gtk_combo_box_set_active (GTK_COMBO_BOX (annot_dialog->popup_state), 1);
gtk_table_attach (GTK_TABLE (table), annot_dialog->popup_state,
1, 2, 4, 5,
diff --git a/shell/ev-application.c b/shell/ev-application.c
index 1e762b6f..f43b10b4 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -224,17 +224,6 @@ ev_display_open_if_needed (const gchar *name)
}
static void
-child_setup (gpointer user_data)
-{
- gchar *startup_id;
-
- startup_id = g_strdup_printf ("_TIME%lu",
- (unsigned long)GPOINTER_TO_INT (user_data));
- g_setenv ("DESKTOP_STARTUP_ID", startup_id, TRUE);
- g_free (startup_id);
-}
-
-static void
ev_spawn (const char *uri,
GdkScreen *screen,
EvLinkDest *dest,
@@ -242,69 +231,78 @@ ev_spawn (const char *uri,
const gchar *search_string,
guint timestamp)
{
- gchar *argv[6];
- guint arg = 0;
- gint i;
- gboolean res;
+ GString *cmd;
+ gchar *path, *cmdline;
+ GAppInfo *app;
+ GdkAppLaunchContext *ctx;
GError *error = NULL;
+ cmd = g_string_new (NULL);
+
#ifdef G_OS_WIN32
{
gchar *dir;
dir = g_win32_get_package_installation_directory_of_module (NULL);
- argv[arg++] = g_build_filename (dir, "bin", "atril", NULL);
+ path = g_build_filename (dir, "bin", "atril", NULL);
g_free (dir);
}
#else
- argv[arg++] = g_build_filename (BINDIR, "atril", NULL);
+ path = g_build_filename (BINDIR, "atril", NULL);
#endif
+ g_string_append_printf (cmd, " %s", path);
+ g_free (path);
+
/* Page label */
if (dest) {
const gchar *page_label;
page_label = ev_link_dest_get_page_label (dest);
if (page_label)
- argv[arg++] = g_strdup_printf ("--page-label=%s", page_label);
+ g_string_append_printf (cmd, " --page-label=%s", page_label);
else
- argv[arg++] = g_strdup_printf ("--page-label=%d",
- ev_link_dest_get_page (dest));
+ g_string_append_printf (cmd, " --page-label=%d", ev_link_dest_get_page (dest));
}
/* Find string */
if (search_string) {
- argv[arg++] = g_strdup_printf ("--find=%s", search_string);
+ g_string_append_printf (cmd, " --find=%s", search_string);
}
/* Mode */
switch (mode) {
case EV_WINDOW_MODE_FULLSCREEN:
- argv[arg++] = g_strdup ("-f");
+ g_string_append (cmd, " -f");
break;
case EV_WINDOW_MODE_PRESENTATION:
- argv[arg++] = g_strdup ("-s");
+ g_string_append (cmd, " -s");
break;
default:
break;
}
- argv[arg++] = (gchar *)uri;
- argv[arg] = NULL;
+ g_string_append_printf (cmd, " %s", uri);
+
+ cmdline = g_string_free (cmd, FALSE);
+ app = g_app_info_create_from_commandline (cmdline, NULL, 0, &error);
+
+ if (app != NULL) {
+ ctx = gdk_display_get_app_launch_context (gdk_screen_get_display (screen));
+ gdk_app_launch_context_set_screen (ctx, screen);
+ gdk_app_launch_context_set_timestamp (ctx, timestamp);
- res = gdk_spawn_on_screen (screen, NULL /* wd */, argv, NULL /* env */,
- 0,
- child_setup,
- GINT_TO_POINTER(timestamp),
- NULL, &error);
- if (!res) {
+ g_app_info_launch (app, NULL, G_APP_LAUNCH_CONTEXT (ctx), &error);
+
+ g_object_unref (app);
+ g_object_unref (ctx);
+ }
+ if (error != NULL) {
g_warning ("Error launching atril %s: %s\n", uri, error->message);
g_error_free (error);
}
- for (i = 0; i < arg - 1; i++) {
- g_free (argv[i]);
- }
+ g_free (cmdline);
}
static GList *
diff --git a/shell/ev-convert-metadata.c b/shell/ev-convert-metadata.c
index 270206b1..5664253b 100644
--- a/shell/ev-convert-metadata.c
+++ b/shell/ev-convert-metadata.c
@@ -164,7 +164,11 @@ show_progress_dialog (ConvertData *data)
dialog = gtk_dialog_new_with_buttons (_("Converting metadata"),
NULL,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GTK_DIALOG_MODAL,
+#else
GTK_DIALOG_NO_SEPARATOR,
+#endif
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
NULL);
action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
diff --git a/shell/ev-password-view.c b/shell/ev-password-view.c
index 73ebbdef..b6ead823 100644
--- a/shell/ev-password-view.c
+++ b/shell/ev-password-view.c
@@ -255,7 +255,9 @@ ev_password_view_ask_password (EvPasswordView *password_view)
action_area = gtk_dialog_get_action_area (dialog);
/* Set the dialog up with HIG properties */
+#if !GTK_CHECK_VERSION (3, 0, 0)
gtk_dialog_set_has_separator (dialog, FALSE);
+#endif
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
diff --git a/shell/ev-properties-dialog.c b/shell/ev-properties-dialog.c
index f520a733..cefedbd6 100644
--- a/shell/ev-properties-dialog.c
+++ b/shell/ev-properties-dialog.c
@@ -61,7 +61,9 @@ ev_properties_dialog_init (EvPropertiesDialog *properties)
gtk_window_set_title (GTK_WINDOW (properties), _("Properties"));
gtk_window_set_destroy_with_parent (GTK_WINDOW (properties), TRUE);
+#if !GTK_CHECK_VERSION (3, 0, 0)
gtk_dialog_set_has_separator (GTK_DIALOG (properties), FALSE);
+#endif
gtk_container_set_border_width (GTK_CONTAINER (properties), 5);
gtk_box_set_spacing (content_area, 2);
diff --git a/shell/ev-sidebar-attachments.c b/shell/ev-sidebar-attachments.c
index b26711cb..989c60d5 100644
--- a/shell/ev-sidebar-attachments.c
+++ b/shell/ev-sidebar-attachments.c
@@ -472,7 +472,11 @@ ev_sidebar_attachments_get_property (GObject *object,
}
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+ev_sidebar_attachments_dispose (GObject *object)
+#else
ev_sidebar_attachments_destroy (GtkObject *object)
+#endif
{
EvSidebarAttachments *ev_attachbar = EV_SIDEBAR_ATTACHMENTS (object);
@@ -494,22 +498,34 @@ ev_sidebar_attachments_destroy (GtkObject *object)
ev_attachbar->priv->icon_cache = NULL;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ (* G_OBJECT_CLASS (ev_sidebar_attachments_parent_class)->dispose) (object);
+#else
(* GTK_OBJECT_CLASS (ev_sidebar_attachments_parent_class)->destroy) (object);
+#endif
}
static void
ev_sidebar_attachments_class_init (EvSidebarAttachmentsClass *ev_attachbar_class)
{
GObjectClass *g_object_class;
+#if !GTK_CHECK_VERSION (3, 0, 0)
GtkObjectClass *gtk_object_class;
+#endif
GtkWidgetClass *gtk_widget_class;
g_object_class = G_OBJECT_CLASS (ev_attachbar_class);
+#if !GTK_CHECK_VERSION (3, 0, 0)
gtk_object_class = GTK_OBJECT_CLASS (ev_attachbar_class);
+#endif
gtk_widget_class = GTK_WIDGET_CLASS (ev_attachbar_class);
g_object_class->get_property = ev_sidebar_attachments_get_property;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ g_object_class->dispose = ev_sidebar_attachments_dispose;
+#else
gtk_object_class->destroy = ev_sidebar_attachments_destroy;
+#endif
gtk_widget_class->popup_menu = ev_sidebar_attachments_popup_menu;
gtk_widget_class->screen_changed = ev_sidebar_attachments_screen_changed;
diff --git a/shell/ev-sidebar-thumbnails.c b/shell/ev-sidebar-thumbnails.c
index 901bdade..913d8504 100644
--- a/shell/ev-sidebar-thumbnails.c
+++ b/shell/ev-sidebar-thumbnails.c
@@ -299,11 +299,9 @@ static void
ev_sidebar_thumbnails_class_init (EvSidebarThumbnailsClass *ev_sidebar_thumbnails_class)
{
GObjectClass *g_object_class;
- GtkObjectClass *gtk_object_class;
GtkWidgetClass *widget_class;
g_object_class = G_OBJECT_CLASS (ev_sidebar_thumbnails_class);
- gtk_object_class = GTK_OBJECT_CLASS (ev_sidebar_thumbnails_class);
widget_class = GTK_WIDGET_CLASS (ev_sidebar_thumbnails_class);
g_object_class->dispose = ev_sidebar_thumbnails_dispose;
diff --git a/shell/ev-sidebar.c b/shell/ev-sidebar.c
index e9d0f75a..322717b5 100644
--- a/shell/ev-sidebar.c
+++ b/shell/ev-sidebar.c
@@ -28,6 +28,9 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
+#if GTK_CHECK_VERSION (3, 0, 0)
+#include <gdk/gdkkeysyms-compat.h>
+#endif
#include "ev-sidebar.h"
#include "ev-sidebar-page.h"
@@ -64,7 +67,11 @@ G_DEFINE_TYPE (EvSidebar, ev_sidebar, GTK_TYPE_VBOX)
(G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_SIDEBAR, EvSidebarPrivate))
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+ev_sidebar_dispose (GObject *object)
+#else
ev_sidebar_destroy (GtkObject *object)
+#endif
{
EvSidebar *ev_sidebar = EV_SIDEBAR (object);
@@ -78,8 +85,11 @@ ev_sidebar_destroy (GtkObject *object)
ev_sidebar->priv->page_model = NULL;
}
-
+#if GTK_CHECK_VERSION (3, 0, 0)
+ (* G_OBJECT_CLASS (ev_sidebar_parent_class)->dispose) (object);
+#else
(* GTK_OBJECT_CLASS (ev_sidebar_parent_class)->destroy) (object);
+#endif
}
static void
@@ -176,16 +186,22 @@ static void
ev_sidebar_class_init (EvSidebarClass *ev_sidebar_class)
{
GObjectClass *g_object_class;
- GtkWidgetClass *widget_class;
+#if !GTK_CHECK_VERSION (3, 0, 0)
GtkObjectClass *gtk_object_klass;
-
+#endif
+
g_object_class = G_OBJECT_CLASS (ev_sidebar_class);
- widget_class = GTK_WIDGET_CLASS (ev_sidebar_class);
+#if !GTK_CHECK_VERSION (3, 0, 0)
gtk_object_klass = GTK_OBJECT_CLASS (ev_sidebar_class);
+#endif
g_type_class_add_private (g_object_class, sizeof (EvSidebarPrivate));
+#if GTK_CHECK_VERSION (3, 0, 0)
+ g_object_class->dispose = ev_sidebar_dispose;
+#else
gtk_object_klass->destroy = ev_sidebar_destroy;
+#endif
g_object_class->get_property = ev_sidebar_get_property;
g_object_class->set_property = ev_sidebar_set_property;
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 7705a9ec..f4e9a67c 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -4157,7 +4157,9 @@ ev_window_cmd_edit_toolbar (GtkAction *action, EvWindow *ev_window)
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)), 5);
gtk_box_set_spacing (GTK_BOX (content_area), 2);
+#if !GTK_CHECK_VERSION (3, 0, 0)
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+#endif
gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 400);
toolbar = EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar);
diff --git a/shell/main.c b/shell/main.c
index 7f00c6f9..3164d3da 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -92,8 +92,6 @@ launch_previewer (void)
{
GString *cmd_str;
gchar *cmd;
- gint argc;
- gchar **argv;
gboolean retval = FALSE;
GError *error = NULL;
@@ -123,16 +121,16 @@ launch_previewer (void)
}
cmd = g_string_free (cmd_str, FALSE);
- g_shell_parse_argv (cmd, &argc, &argv, &error);
- g_free (cmd);
if (!error) {
- retval = gdk_spawn_on_screen (gdk_screen_get_default (),
- NULL, argv, NULL,
- G_SPAWN_SEARCH_PATH,
- NULL, NULL, NULL,
- &error);
- g_strfreev (argv);
+ GAppInfo *app;
+
+ app = g_app_info_create_from_commandline (cmd, NULL, 0, &error);
+
+ if (app != NULL) {
+ retval = g_app_info_launch (app, NULL, NULL, &error);
+ g_object_unref (app);
+ }
}
if (error) {
@@ -140,6 +138,8 @@ launch_previewer (void)
g_error_free (error);
}
+ g_free (cmd);
+
return retval;
}
@@ -260,9 +260,11 @@ main (int argc, char *argv[])
}
#endif
+#if !GLIB_CHECK_VERSION (2, 32, 0)
/* Init glib threads asap */
if (!g_thread_supported ())
g_thread_init (NULL);
+#endif
#ifdef ENABLE_NLS
/* Initialize the i18n stuff */