+2006-05-13 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
+
+ * 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 <nshmyrev@yandex.ru>
* shell/ev-sidebar-attachments.c: (ev_sidebar_attachments_init):
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)
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
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);
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;
}
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);
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
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),
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;
}
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
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);
g_free (rectangles);
}
-
-#ifndef HAVE_G_FILE_SET_CONTENTS
-
-#include <errno.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <string.h>
-#include <glib/gstdio.h>
-
-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)
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 */
-
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);
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),
#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 "<unique>_TIME<timestamp>".
- *
- * <unique> might contain a T but <timestamp> 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)
{
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);