static EogWindow * eog_application_get_file_window (EogApplication *application, GFile *file) { EogWindow *file_window = NULL; GList *windows; GList *l; g_return_val_if_fail (file != NULL, NULL); g_return_val_if_fail (EOG_IS_APPLICATION (application), NULL); windows = gtk_window_list_toplevels (); for (l = windows; l != NULL; l = l->next) { if (EOG_IS_WINDOW (l->data)) { EogWindow *window = EOG_WINDOW (l->data); if (!eog_window_is_empty (window)) { EogImage *image = eog_window_get_image (window); GFile *window_file; window_file = eog_image_get_file (image); if (g_file_equal (window_file, file)) { file_window = window; break; } } } } g_list_free (windows); return file_window; }
static void fit_to_width_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data) { EogWindow *window; GtkWidget *view; EogImage *image; gint image_width; gint image_height; gint view_width; double zoom; GtkAllocation allocation; g_return_if_fail (EOG_IS_WINDOW (user_data)); window = EOG_WINDOW (user_data); view = eog_window_get_view (window); image = eog_window_get_image (window); g_return_if_fail (EOG_IS_SCROLL_VIEW (view)); g_return_if_fail (EOG_IS_IMAGE (image)); eog_image_get_size (image, &image_width, &image_height); gtk_widget_get_allocation (view, &allocation); view_width = allocation.width; // HACK: It's necessary subtract the width size (15) of vscrollbar // to scrollview for obtain the display area. zoom = (double) (view_width - 15) / image_width; eog_scroll_view_set_zoom (EOG_SCROLL_VIEW (view), zoom); }
static void reload_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data) { eog_window_reload_image (EOG_WINDOW (user_data)); }
static EogWindow* get_focus_window (GtkApplication *application) { GList *windows; GtkWindow *window = NULL; /* the windows are ordered with the last focused first */ windows = gtk_application_get_windows (application); if (windows != NULL) { window = g_list_nth_data (windows, 0); } return EOG_WINDOW (window); }
static EogWindow * eog_application_get_first_window (EogApplication *application) { g_return_val_if_fail (EOG_IS_APPLICATION (application), NULL); GList *windows; GList *l; EogWindow *window = NULL; windows = gtk_window_list_toplevels (); for (l = windows; l != NULL; l = l->next) { if (EOG_IS_WINDOW (l->data)) { window = EOG_WINDOW (l->data); break; } } g_list_free (windows); return window; }
static void eog_reload_plugin_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { EogReloadPlugin *plugin = EOG_RELOAD_PLUGIN (object); switch (prop_id) { case PROP_WINDOW: plugin->window = EOG_WINDOW (g_value_dup_object (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void eog_fit_to_width_plugin_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { EogFitToWidthPlugin *plugin = EOG_FIT_TO_WIDTH_PLUGIN (object); switch (prop_id) { case PROP_WINDOW: plugin->window = EOG_WINDOW (g_value_dup_object (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
/** * eog_application_open_file_list: * @application: An #EogApplication. * @file_list: (element-type GFile): A list of #GFile<!-- -->s. * @timestamp: The timestamp of the user interaction which triggered this call * (see gtk_window_present_with_time()). * @flags: A set of #EogStartupFlags influencing a new windows' state. * @error: Return location for a #GError, or NULL to ignore errors. * * Opens a list of files in a #EogWindow. If an #EogWindow displaying the first * image in the list is already open, this will be used. Otherwise, an empty * #EogWindow is used, either already existing or newly created. * If the EOG_STARTUP_SINGLE_WINDOW flag is set, the files are opened in the * first #EogWindow and no new one is opened. * * Returns: Currently always %TRUE. **/ gboolean eog_application_open_file_list (EogApplication *application, GSList *file_list, guint timestamp, EogStartupFlags flags, GError **error) { EogWindow *new_window = NULL; if (file_list != NULL) { if(flags & EOG_STARTUP_SINGLE_WINDOW) new_window = eog_application_get_first_window (application); else new_window = eog_application_get_file_window (application, (GFile *) file_list->data); } if (new_window != NULL) { if(flags & EOG_STARTUP_SINGLE_WINDOW) eog_window_open_file_list (new_window, file_list); else gtk_window_present_with_time (GTK_WINDOW (new_window), timestamp); return TRUE; } new_window = eog_application_get_empty_window (application); if (new_window == NULL) { new_window = EOG_WINDOW (eog_window_new (flags)); } g_signal_connect (new_window, "prepared", G_CALLBACK (eog_application_show_window), GUINT_TO_POINTER (timestamp)); eog_window_open_file_list (new_window, file_list); return TRUE; }
static void postr_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data) { EogWindow *window; GtkWidget *thumbview; GList *images, *i; gchar *cmd = g_strdup ("postr "); eog_debug(DEBUG_PLUGINS); g_return_if_fail (EOG_IS_WINDOW (user_data)); window = EOG_WINDOW (user_data); thumbview = eog_window_get_thumb_view (window); images = eog_thumb_view_get_selected_images (EOG_THUMB_VIEW (thumbview)); for (i = g_list_first (images); i; i = i->next) { EogImage *image = (EogImage *) i->data; GFile *imgfile; gchar *imgpath; gchar *oldcmd = cmd; imgfile = eog_image_get_file (image); imgpath = g_file_get_path (imgfile); if (G_LIKELY (imgpath != NULL)) { cmd = g_strconcat (oldcmd, "\"", imgpath, "\"", " ", NULL); g_free (oldcmd); } g_free (imgpath); g_object_unref (imgfile); } g_spawn_command_line_async (cmd, NULL); g_list_free_full (images, g_object_unref); g_free (cmd); }
static EogWindow * eog_application_get_empty_window (EogApplication *application) { EogWindow *empty_window = NULL; GList *windows; GList *l; g_return_val_if_fail (EOG_IS_APPLICATION (application), NULL); windows = gtk_application_get_windows (GTK_APPLICATION (application)); for (l = windows; l != NULL; l = l->next) { EogWindow *window = EOG_WINDOW (l->data); /* Make sure the window is empty and not initializing */ if (eog_window_is_empty (window) && eog_window_is_not_initializing (window)) { empty_window = window; break; } } return empty_window; }