From 70f641411b2fbab930b481ac844984819b48805d Mon Sep 17 00:00:00 2001 From: Nickolay V. Shmyrev Date: Sat, 13 May 2006 03:54:09 +0000 Subject: Bump requirements to gtk 2.8 and drop all idfefs used. * configure.ac: * properties/ev-properties-main.c: (ev_properties_get_pages): * shell/ev-application.c: (ev_application_open_window), (ev_application_open_uri_at_dest): * shell/ev-sidebar-attachments.c: (ev_sidebar_attachments_init): * shell/ev-sidebar-thumbnails.c: (adjustment_changed_cb), (ev_sidebar_thumbnails_use_icon_view), (page_changed_cb): * shell/ev-utils.c: (save_print_config_to_file): * shell/ev-window.c: (ev_window_cmd_save_as), (ev_attachment_popup_cmd_save_attachment_as): * shell/main.c: (load_files_remote): Bump requirements to gtk 2.8 and drop all idfefs used. --- diff --git a/ChangeLog b/ChangeLog index 7648714..a977047 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2006-05-13 Nickolay V. Shmyrev + + * configure.ac: + * properties/ev-properties-main.c: (ev_properties_get_pages): + * shell/ev-application.c: (ev_application_open_window), + (ev_application_open_uri_at_dest): + * shell/ev-sidebar-attachments.c: (ev_sidebar_attachments_init): + * shell/ev-sidebar-thumbnails.c: (adjustment_changed_cb), + (ev_sidebar_thumbnails_use_icon_view), (page_changed_cb): + * shell/ev-utils.c: (save_print_config_to_file): + * shell/ev-window.c: (ev_window_cmd_save_as), + (ev_attachment_popup_cmd_save_attachment_as): + * shell/main.c: (load_files_remote): + + Bump requirements to gtk 2.8 and drop all idfefs used. + 2006-05-11 Nickolay V. Shmyrev * shell/ev-sidebar-attachments.c: (ev_sidebar_attachments_init): diff --git a/configure.ac b/configure.ac index e670809..256a871 100644 --- a/configure.ac +++ b/configure.ac @@ -43,9 +43,10 @@ dnl Check dependencies POPPLER_REQUIRED=0.5.1 DBUS_GLIB_REQUIRED=0.33 -GTK_REQUIRED=2.6.0 -LIBGNOMEUI_REQUIRED=2.6.0 +GTK_REQUIRED=2.8.15 KEYRING_REQUIRED=0.4.0 + +LIBGNOMEUI_REQUIRED=2.6.0 LIBGNOMEPRINTUI_REQUIRED=2.5.1 PKG_CHECK_MODULES(LIB, gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED) @@ -137,16 +138,6 @@ if test x$HAVE_NAUTILUS = "xyes"; then fi AM_CONDITIONAL(HAVE_NAUTILUS, test x$HAVE_NAUTILUS = "xyes") -dnl Check for functions not present in gtk 2.6 -evince_save_LIBS=$LIBS -LIBS="$LIBS $FRONTEND_CORE_LIBS" -AC_CHECK_FUNCS(gtk_icon_view_get_visible_range) -AC_CHECK_FUNCS(gtk_window_present_with_time) -AC_CHECK_FUNCS(g_file_set_contents) -AC_CHECK_FUNCS(gtk_file_chooser_set_do_overwrite_confirmation) -AC_CHECK_FUNCS(gtk_icon_view_enable_model_drag_source) -LIBS=$evince_save_LIBS - dnl GConf configuration AM_GCONF_SOURCE_2 diff --git a/properties/ev-properties-main.c b/properties/ev-properties-main.c index f726591..3b1e8e0 100644 --- a/properties/ev-properties-main.c +++ b/properties/ev-properties-main.c @@ -89,18 +89,13 @@ ev_properties_get_pages (NautilusPropertyPageProvider *provider, char *uri = NULL; GtkWidget *page, *label; NautilusPropertyPage *property_page; - GType type = G_TYPE_INVALID; - + /* only add properties page if a single file is selected */ if (files == NULL || files->next != NULL) goto end; file = files->data; /* okay, make the page */ - - if (document == NULL) - goto end; - uri = nautilus_file_info_get_uri (file); document = ev_document_factory_get_document (uri, &error); diff --git a/shell/ev-application.c b/shell/ev-application.c index ffa58ee..e3c78a9 100644 --- a/shell/ev-application.c +++ b/shell/ev-application.c @@ -183,12 +183,8 @@ ev_application_open_window (EvApplication *application, gtk_widget_show (new_window); -#ifdef HAVE_GTK_WINDOW_PRESENT_WITH_TIME gtk_window_present_with_time (GTK_WINDOW (new_window), timestamp); -#else - gtk_window_present (GTK_WINDOW (new_window)); -#endif return TRUE; } @@ -251,12 +247,8 @@ ev_application_open_uri_at_dest (EvApplication *application, new_window = ev_application_get_uri_window (application, uri); if (new_window != NULL) { -#ifdef HAVE_GTK_WINDOW_PRESENT_WITH_TIME gtk_window_present_with_time (GTK_WINDOW (new_window), timestamp); -#else - gtk_window_present (GTK_WINDOW (new_window)); -#endif if (dest) ev_window_goto_dest (new_window, dest); @@ -275,12 +267,8 @@ ev_application_open_uri_at_dest (EvApplication *application, gtk_widget_show (GTK_WIDGET (new_window)); -#ifdef HAVE_GTK_WINDOW_PRESENT_WITH_TIME gtk_window_present_with_time (GTK_WINDOW (new_window), timestamp); -#else - gtk_window_present (GTK_WINDOW (new_window)); -#endif } gboolean diff --git a/shell/ev-sidebar-attachments.c b/shell/ev-sidebar-attachments.c index 1533dc8..2b7393d 100644 --- a/shell/ev-sidebar-attachments.c +++ b/shell/ev-sidebar-attachments.c @@ -539,14 +539,13 @@ ev_sidebar_attachments_init (EvSidebarAttachments *ev_attachbar) g_object_unref); /* Drag and Drop */ -#ifdef HAVE_GTK_ICON_VIEW_ENABLE_MODEL_DRAG_SOURCE gtk_icon_view_enable_model_drag_source ( GTK_ICON_VIEW (ev_attachbar->priv->icon_view), GDK_BUTTON1_MASK, drag_targets, G_N_ELEMENTS (drag_targets), GDK_ACTION_COPY); -#endif + g_signal_connect (G_OBJECT (ev_attachbar->priv->icon_view), "drag-data-get", G_CALLBACK (ev_sidebar_attachments_drag_data_get), diff --git a/shell/ev-sidebar-thumbnails.c b/shell/ev-sidebar-thumbnails.c index ac449d8..b454dd5 100644 --- a/shell/ev-sidebar-thumbnails.c +++ b/shell/ev-sidebar-thumbnails.c @@ -307,14 +307,10 @@ adjustment_changed_cb (EvSidebarThumbnails *sidebar_thumbnails) 1, wy2 -1, &path2, NULL, NULL, NULL); } else if (priv->icon_view) { -#ifdef HAVE_GTK_ICON_VIEW_GET_VISIBLE_RANGE if (! GTK_WIDGET_REALIZED (priv->icon_view)) return; if (! gtk_icon_view_get_visible_range (GTK_ICON_VIEW (priv->icon_view), &path, &path2)) return; -#else - g_assert_not_reached (); -#endif } else { return; } @@ -495,14 +491,10 @@ ev_sidebar_init_icon_view (EvSidebarThumbnails *ev_sidebar_thumbnails) static gboolean ev_sidebar_thumbnails_use_icon_view (EvSidebarThumbnails *sidebar_thumbnails) { -#ifdef HAVE_GTK_ICON_VIEW_GET_VISIBLE_RANGE EvSidebarThumbnailsPrivate *priv = sidebar_thumbnails->priv; if (ev_page_cache_get_n_pages (priv->page_cache) > MAX_ICON_VIEW_PAGE_COUNT) return FALSE; return TRUE; -#else - return FALSE; -#endif } static void @@ -552,11 +544,8 @@ page_changed_cb (EvPageCache *page_cache, gtk_tree_view_set_cursor (tree_view, path, NULL, FALSE); gtk_tree_view_scroll_to_cell (tree_view, path, NULL, FALSE, 0.0, 0.0); } else if (sidebar->priv->icon_view) { - /* Guard against gtk-2.6 */ -#ifdef HAVE_GTK_ICON_VIEW_GET_VISIBLE_RANGE gtk_icon_view_select_path (GTK_ICON_VIEW (sidebar->priv->icon_view), path); gtk_icon_view_set_cursor (GTK_ICON_VIEW (sidebar->priv->icon_view), path, NULL, FALSE); -#endif } gtk_tree_path_free (path); diff --git a/shell/ev-utils.c b/shell/ev-utils.c index 3dc849c..b35b77b 100644 --- a/shell/ev-utils.c +++ b/shell/ev-utils.c @@ -210,216 +210,6 @@ ev_print_region_contents (GdkRegion *region) g_free (rectangles); } - -#ifndef HAVE_G_FILE_SET_CONTENTS - -#include -#include -#include -#include -#include -#include - -static gboolean -rename_file (const char *old_name, - const char *new_name, - GError **err) -{ - errno = 0; - if (g_rename (old_name, new_name) == -1) - { - return FALSE; - } - - return TRUE; -} - -static gboolean -set_umask_permissions (int fd, - GError **err) -{ - /* All of this function is just to work around the fact that - * there is no way to get the umask without changing it. - * - * We can't just change-and-reset the umask because that would - * lead to a race condition if another thread tried to change - * the umask in between the getting and the setting of the umask. - * So we have to do the whole thing in a child process. - */ - pid_t pid; - - pid = fork (); - - if (pid == -1) - { - return FALSE; - } - else if (pid == 0) - { - /* child */ - mode_t mask = umask (0666); - - errno = 0; - if (fchmod (fd, 0666 & ~mask) == -1) - _exit (errno); - else - _exit (0); - - return TRUE; /* To quiet gcc */ - } - else - { - /* parent */ - int status; - - errno = 0; - if (waitpid (pid, &status, 0) == -1) - { - return FALSE; - } - - if (WIFEXITED (status)) - { - if (WEXITSTATUS (status) == 0) - { - return TRUE; - } - else - { - return FALSE; - } - } - else if (WIFSIGNALED (status)) - { - return FALSE; - } - else - { - return FALSE; - } - } -} - -static gchar * -write_to_temp_file (const gchar *contents, - gssize length, - const gchar *template, - GError **err) -{ - gchar *tmp_name; - gchar *display_name; - gchar *retval; - FILE *file; - gint fd; - - retval = NULL; - - tmp_name = g_strdup_printf ("%s.XXXXXX", template); - - errno = 0; - fd = g_mkstemp (tmp_name); - display_name = g_filename_display_name (tmp_name); - - if (fd == -1) - { - goto out; - } - - if (!set_umask_permissions (fd, err)) - { - close (fd); - g_unlink (tmp_name); - - goto out; - } - - errno = 0; - file = fdopen (fd, "wb"); - if (!file) - { - close (fd); - g_unlink (tmp_name); - - goto out; - } - - if (length > 0) - { - size_t n_written; - - errno = 0; - - n_written = fwrite (contents, 1, length, file); - - if (n_written < length) - { - fclose (file); - g_unlink (tmp_name); - - goto out; - } - } - - errno = 0; - if (fclose (file) == EOF) - { - g_unlink (tmp_name); - - goto out; - } - - retval = g_strdup (tmp_name); - - out: - g_free (tmp_name); - g_free (display_name); - - return retval; -} - -static gboolean -ev_file_set_contents (const gchar *filename, - const gchar *contents, - gssize length, - GError **error) -{ - gchar *tmp_filename; - gboolean retval; - GError *rename_error = NULL; - - g_return_val_if_fail (filename != NULL, FALSE); - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - g_return_val_if_fail (contents != NULL || length == 0, FALSE); - g_return_val_if_fail (length >= -1, FALSE); - - if (length == -1) - length = strlen (contents); - - tmp_filename = write_to_temp_file (contents, length, filename, error); - - if (!tmp_filename) - { - retval = FALSE; - goto out; - } - - if (!rename_file (tmp_filename, filename, &rename_error)) - { - g_unlink (tmp_filename); - g_propagate_error (error, rename_error); - retval = FALSE; - goto out; - } - - retval = TRUE; - - out: - g_free (tmp_filename); - return retval; -} - -#endif /* HAVE_G_FILE_SET_CONTENTS */ - #ifdef WITH_GNOME_PRINT gboolean using_pdf_printer (GnomePrintConfig *config) @@ -503,15 +293,10 @@ save_print_config_to_file (GnomePrintConfig *config) PRINT_CONFIG_FILENAME, NULL); -#ifdef HAVE_G_FILE_SET_CONTENTS g_file_set_contents (file_name, str, -1, NULL); -#else - ev_file_set_contents (file_name, str, -1, NULL); -#endif g_free (file_name); g_free (str); } #endif /* WITH_GNOME_PRINT */ - diff --git a/shell/ev-window.c b/shell/ev-window.c index 1cd024d..d30e9cb 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -1178,9 +1178,7 @@ ev_window_cmd_save_as (GtkAction *action, EvWindow *ev_window) ev_document_factory_add_filters (fc, ev_window->priv->document); gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK); -#ifdef HAVE_GTK_FILE_CHOOSER_SET_DO_OVERWRITE_CONFIRMATION gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER (fc), TRUE); -#endif file_name = gnome_vfs_format_uri_for_display (ev_window->priv->uri); base_name = g_path_get_basename (file_name); gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (fc), base_name); @@ -3453,10 +3451,7 @@ ev_attachment_popup_cmd_save_attachment_as (GtkAction *action, EvWindow *window) NULL); gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK); - -#ifdef HAVE_GTK_FILE_CHOOSER_SET_DO_OVERWRITE_CONFIRMATION gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (fc), TRUE); -#endif if (attachment) gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (fc), diff --git a/shell/main.c b/shell/main.c index 91a62d2..480d00e 100644 --- a/shell/main.c +++ b/shell/main.c @@ -73,47 +73,6 @@ load_files (const char **files) #ifdef ENABLE_DBUS -#ifndef HAVE_GTK_WINDOW_PRESENT_WITH_TIME -static guint32 -get_startup_time (void) -{ - const char *envvar, *timestamp; - unsigned long value; - char *end; - - envvar = getenv ("DESKTOP_STARTUP_ID"); - - if (envvar == NULL) - return 0; - -/* DESKTOP_STARTUP_ID is of form "_TIME". - * - * might contain a T but is an integer. As such, - * the last 'T' in the string must be the start of "TIME". - */ - timestamp = rindex (envvar, 'T'); - -/* Maybe the word "TIME" was not found... */ - if (timestamp == NULL || strncmp (timestamp, "TIME", 4)) - return 0; - - timestamp += 4; - -/* strtoul sets errno = ERANGE on overflow, but it is not specified - * if it sets it to 0 on success. Doing so ourselves is the only - * way to know for sure. - */ - errno = 0; - value = strtoul (timestamp, &end, 10); - -/* unsigned long might be 64bit, so double-check! */ - if (errno != 0 || *end != '\0' || value > G_MAXINT32) - return 0; - - return value; -} -#endif - static gboolean load_files_remote (const char **files) { @@ -125,19 +84,13 @@ load_files_remote (const char **files) DBusGPendingCall *call; #endif DBusGProxy *remote_object; -#ifdef HAVE_GTK_WINDOW_PRESENT_WITH_TIME GdkDisplay *display; -#endif guint32 timestamp; -#ifdef HAVE_GTK_WINDOW_PRESENT_WITH_TIME display = gdk_display_get_default(); timestamp = gdk_x11_display_get_user_time (display); -#else - /* Fake it for GTK+2.6 */ - timestamp = get_startup_time (); -#endif connection = dbus_g_bus_get (DBUS_BUS_STARTER, &error); + if (connection == NULL) { g_warning (error->message); g_error_free (error); -- cgit v0.9.1