static void eog_reload_plugin_activate (EogWindowActivatable *activatable) { GtkUIManager *manager; EogReloadPlugin *plugin = EOG_RELOAD_PLUGIN (activatable); eog_debug (DEBUG_PLUGINS); manager = eog_window_get_ui_manager (plugin->window); plugin->ui_action_group = gtk_action_group_new ("EogReloadPluginActions"); gtk_action_group_set_translation_domain (plugin->ui_action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions (plugin->ui_action_group, action_entries, G_N_ELEMENTS (action_entries), plugin->window); gtk_ui_manager_insert_action_group (manager, plugin->ui_action_group, -1); plugin->ui_id = gtk_ui_manager_add_ui_from_string (manager, ui_definition, -1, NULL); g_warn_if_fail (plugin->ui_id != 0); }
static void impl_deactivate (EogWindowActivatable *activatable) { EogPostrPlugin *plugin = EOG_POSTR_PLUGIN (activatable); GMenu *menu; GMenuModel *model; gint i; eog_debug (DEBUG_PLUGINS); menu = eog_window_get_gear_menu_section (plugin->window, "plugins-section"); g_return_if_fail (G_IS_MENU (menu)); /* Remove menu entry */ model = G_MENU_MODEL (menu); for (i = 0; i < g_menu_model_get_n_items (model); i++) { gchar *id; if (g_menu_model_get_item_attribute (model, i, "id", "s", &id)) { const gboolean found = (g_strcmp0 (id, EOG_POSTR_PLUGIN_MENU_ID) == 0); g_free (id); if (found) { g_menu_remove (menu, i); break; } } } /* Finally remove action */ g_action_map_remove_action (G_ACTION_MAP (plugin->window), EOG_POSTR_PLUGIN_ACTION); }
static void impl_deactivate (EogWindowActivatable *activatable) { EogMapPlugin *plugin = EOG_MAP_PLUGIN (activatable); GtkWidget *sidebar, *thumbview; eog_debug (DEBUG_PLUGINS); sidebar = eog_window_get_sidebar (plugin->window); eog_sidebar_remove_page (EOG_SIDEBAR (sidebar), plugin->viewport); thumbview = eog_window_get_thumb_view (plugin->window); if (thumbview && plugin->selection_changed_id > 0) { g_signal_handler_disconnect (thumbview, plugin->selection_changed_id); plugin->selection_changed_id = 0; } if (plugin->window && plugin->win_prepared_id > 0) { g_signal_handler_disconnect (plugin->window, plugin->win_prepared_id); plugin->win_prepared_id = 0; } }
static void migrate_config_folder (const gchar* new_dir) { gchar* old_dir = g_build_filename (g_get_home_dir (), ".gnome2", "eog", NULL); gchar* old_filename = NULL; gchar* new_filename = NULL; GError *error = NULL; GFile *dir_file = NULL; gsize i; static const gchar *old_files[] = { "eog-print-settings.ini", "eog_toolbar.xml", NULL }; if(!g_file_test (old_dir, G_FILE_TEST_IS_DIR)) { /* Nothing to migrate */ g_free (old_dir); return; } eog_debug (DEBUG_PREFERENCES); for (i = 0; old_files[i] != NULL; i++) { old_filename = g_build_filename (old_dir, old_files[i], NULL); new_filename = g_build_filename (new_dir, old_files[i], NULL); migrate_config_file (old_filename, new_filename); g_free (new_filename); g_free (old_filename); } /* Migrate accels file */ old_filename = g_build_filename (g_get_home_dir (), ".gnome2", "accels", "eog", NULL); /* move file to ~/.config/eog/accels if its not already there */ new_filename = g_build_filename (new_dir, "accels", NULL); migrate_config_file (old_filename, new_filename); g_free (new_filename); g_free (old_filename); dir_file = g_file_new_for_path (old_dir); if (!g_file_delete (dir_file, NULL, &error)) { g_warning ("An error occurred while deleting the old config folder %s: %s\n", old_dir, error->message); g_error_free (error); } g_object_unref (dir_file); g_free(old_dir); }
static void eog_reload_plugin_activate (EogWindowActivatable *activatable) { const gchar * const accel_keys[] = { "R", NULL }; EogReloadPlugin *plugin = EOG_RELOAD_PLUGIN (activatable); GMenu *model, *menu; GMenuItem *item; GSimpleAction *action; eog_debug (DEBUG_PLUGINS); model= eog_window_get_gear_menu_section (plugin->window, "plugins-section"); g_return_if_fail (G_IS_MENU (model)); /* Setup and inject action */ action = g_simple_action_new (EOG_RELOAD_PLUGIN_ACTION, NULL); g_signal_connect(action, "activate", G_CALLBACK (reload_cb), plugin->window); g_action_map_add_action (G_ACTION_MAP (plugin->window), G_ACTION (action)); g_object_unref (action); g_signal_connect (G_OBJECT (eog_window_get_thumb_view (plugin->window)), "selection-changed", G_CALLBACK (_selection_changed_cb), plugin); eog_reload_plugin_update_action_state (plugin); /* Append entry to the window's gear menu */ menu = g_menu_new (); g_menu_append (menu, _("Reload Image"), "win." EOG_RELOAD_PLUGIN_ACTION); item = g_menu_item_new_section (NULL, G_MENU_MODEL (menu)); g_menu_item_set_attribute (item, "id", "s", EOG_RELOAD_PLUGIN_MENU_ID); g_menu_item_set_attribute (item, G_MENU_ATTRIBUTE_ICON, "s", "view-refresh-symbolic"); g_menu_append_item (model, item); g_object_unref (item); g_object_unref (menu); /* Define accelerator keys */ gtk_application_set_accels_for_action (GTK_APPLICATION (EOG_APP), "win." EOG_RELOAD_PLUGIN_ACTION, accel_keys); }
static void eog_reload_plugin_deactivate (EogWindowActivatable *activatable) { GtkUIManager *manager; EogReloadPlugin *plugin = EOG_RELOAD_PLUGIN (activatable); eog_debug (DEBUG_PLUGINS); manager = eog_window_get_ui_manager (plugin->window); gtk_ui_manager_remove_ui (manager, plugin->ui_id); gtk_ui_manager_remove_action_group (manager, plugin->ui_action_group); }
static void eog_reload_plugin_deactivate (EogWindowActivatable *activatable) { const gchar * const empty_accels[1] = { NULL }; EogReloadPlugin *plugin = EOG_RELOAD_PLUGIN (activatable); GMenu *menu; GMenuModel *model; gint i; eog_debug (DEBUG_PLUGINS); menu = eog_window_get_gear_menu_section (plugin->window, "plugins-section"); g_return_if_fail (G_IS_MENU (menu)); /* Remove menu entry */ model = G_MENU_MODEL (menu); for (i = 0; i < g_menu_model_get_n_items (model); i++) { gchar *id; if (g_menu_model_get_item_attribute (model, i, "id", "s", &id)) { const gboolean found = (g_strcmp0 (id, EOG_RELOAD_PLUGIN_MENU_ID) == 0); g_free (id); if (found) { g_menu_remove (menu, i); break; } } } /* Unset accelerator */ gtk_application_set_accels_for_action(GTK_APPLICATION (EOG_APP), "win." EOG_RELOAD_PLUGIN_ACTION, empty_accels); /* Disconnect selection-changed handler as the thumbview would * otherwise still cause callbacks during its own disposal */ g_signal_handlers_disconnect_by_func (eog_window_get_thumb_view (plugin->window), _selection_changed_cb, plugin); /* Finally remove action */ g_action_map_remove_action (G_ACTION_MAP (plugin->window), EOG_RELOAD_PLUGIN_ACTION); }
static void impl_activate (EogWindowActivatable *activatable) { EogPostrPlugin *plugin = EOG_POSTR_PLUGIN (activatable); GMenu *model, *menu; GMenuItem *item; GSimpleAction *action; eog_debug (DEBUG_PLUGINS); g_return_if_fail (plugin->window != NULL); model= eog_window_get_gear_menu_section (plugin->window, "plugins-section"); g_return_if_fail (G_IS_MENU (model)); /* Setup and inject action */ action = g_simple_action_new (EOG_POSTR_PLUGIN_ACTION, NULL); g_signal_connect(action, "activate", G_CALLBACK (postr_cb), plugin->window); g_action_map_add_action (G_ACTION_MAP (plugin->window), G_ACTION (action)); g_object_unref (action); /* Append entry to the window's gear menu */ menu = g_menu_new (); g_menu_append (menu, _("Upload to Flickr"), "win." EOG_POSTR_PLUGIN_ACTION); item = g_menu_item_new_section (NULL, G_MENU_MODEL (menu)); g_menu_item_set_attribute (item, "id", "s", EOG_POSTR_PLUGIN_MENU_ID); g_menu_item_set_attribute (item, G_MENU_ATTRIBUTE_ICON, "s", "postr"); g_menu_append_item (model, item); g_object_unref (item); g_object_unref (menu); }
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 void impl_activate (EogWindowActivatable *activatable) { EogMapPlugin *plugin = EOG_MAP_PLUGIN (activatable); GtkWidget *sidebar, *vbox, *bbox, *button, *viewport; GtkWidget *embed; ClutterActor *scale; eog_debug (DEBUG_PLUGINS); /* This is a workaround until bug 590692 is fixed. */ viewport = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (viewport), GTK_SHADOW_ETCHED_IN); /*viewport = gtk_viewport_new (NULL, NULL); gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_ETCHED_IN);*/ embed = gtk_champlain_embed_new (); plugin->map = gtk_champlain_embed_get_view (GTK_CHAMPLAIN_EMBED (embed)); g_object_set (G_OBJECT (plugin->map), "zoom-level", 3, "kinetic-mode", TRUE, NULL); scale = champlain_scale_new (); champlain_scale_connect_view (CHAMPLAIN_SCALE (scale), plugin->map); /* align to the bottom left */ champlain_view_bin_layout_add (plugin->map, scale, CLUTTER_BIN_ALIGNMENT_START, CLUTTER_BIN_ALIGNMENT_END); gtk_container_add (GTK_CONTAINER (viewport), embed); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); bbox = gtk_toolbar_new (); button = GTK_WIDGET (gtk_tool_button_new (NULL, NULL)); gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (button), "go-jump-symbolic"); gtk_widget_set_tooltip_text (button, _("Jump to current image's location")); g_signal_connect (button, "clicked", G_CALLBACK (jump_to), plugin); gtk_container_add (GTK_CONTAINER (bbox), button); plugin->jump_to_button = button; button = GTK_WIDGET (gtk_separator_tool_item_new ()); gtk_container_add (GTK_CONTAINER (bbox), button); button = GTK_WIDGET (gtk_tool_button_new (NULL, NULL)); gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (button), "zoom-in-symbolic"); gtk_widget_set_tooltip_text (button, _("Zoom in")); g_signal_connect (button, "clicked", G_CALLBACK (zoom_in), plugin->map); gtk_container_add (GTK_CONTAINER (bbox), button); button = GTK_WIDGET (gtk_tool_button_new (NULL, NULL)); gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (button), "zoom-out-symbolic"); gtk_widget_set_tooltip_text (button, _("Zoom out")); g_signal_connect (button, "clicked", G_CALLBACK (zoom_out), plugin->map); gtk_container_add (GTK_CONTAINER (bbox), button); plugin->layer = champlain_marker_layer_new_full (CHAMPLAIN_SELECTION_SINGLE); champlain_view_add_layer (CHAMPLAIN_VIEW (plugin->map), CHAMPLAIN_LAYER (plugin->layer)); sidebar = eog_window_get_sidebar (plugin->window); plugin->viewport = vbox; gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0); gtk_widget_set_vexpand (viewport, TRUE); gtk_container_add (GTK_CONTAINER (vbox), viewport); eog_sidebar_add_page (EOG_SIDEBAR (sidebar), _("Map"), vbox); gtk_widget_show_all (vbox); plugin->win_prepared_id = g_signal_connect (G_OBJECT (plugin->window), "prepared", G_CALLBACK (prepared_cb), plugin); /* Call the callback once in case the window is already ready */ prepared_cb (plugin->window, plugin); }