void ip__gth_browser_construct_cb (GthBrowser *browser) { BrowserData *data; GError *error = NULL; g_return_if_fail (GTH_IS_BROWSER (browser)); data = g_new0 (BrowserData, 1); data->action_group = gtk_action_group_new ("Image Print Actions"); gtk_action_group_set_translation_domain (data->action_group, NULL); _gtk_action_group_add_actions_with_flags (data->action_group, action_entries, G_N_ELEMENTS (action_entries), browser); gtk_ui_manager_insert_action_group (gth_browser_get_ui_manager (browser), data->action_group, 0); data->fixed_merge_id = gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), fixed_ui_info, -1, &error); if (data->fixed_merge_id == 0) { g_warning ("building ui failed: %s", error->message); g_error_free (error); } g_object_set_data_full (G_OBJECT (browser), BROWSER_DATA_KEY, data, (GDestroyNotify) browser_data_free); }
void fm__gth_browser_folder_tree_popup_before_cb (GthBrowser *browser, GthFileSource *file_source, GthFileData *folder) { BrowserData *data; data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY); g_return_if_fail (data != NULL); if (GTH_IS_FILE_SOURCE_VFS (file_source)) { if (data->folder_popup_merge_id == 0) { GError *error = NULL; data->folder_popup_merge_id = gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), folder_popup_ui_info, -1, &error); if (data->folder_popup_merge_id == 0) { g_message ("building menus failed: %s", error->message); g_error_free (error); } } fm__gth_browser_update_sensitivity_cb (browser); } else { if (data->folder_popup_merge_id != 0) { gtk_ui_manager_remove_ui (gth_browser_get_ui_manager (browser), data->folder_popup_merge_id); data->folder_popup_merge_id = 0; } } }
void edit_metadata__gth_browser_set_current_page_cb (GthBrowser *browser) { BrowserData *data; GError *error = NULL; data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY); g_return_if_fail (data != NULL); switch (gth_window_get_current_page (GTH_WINDOW (browser))) { case GTH_BROWSER_PAGE_BROWSER: if (data->viewer_ui_merge_id != 0) { gtk_ui_manager_remove_ui (gth_browser_get_ui_manager (browser), data->viewer_ui_merge_id); data->viewer_ui_merge_id = 0; } break; case GTH_BROWSER_PAGE_VIEWER: if (data->viewer_ui_merge_id != 0) return; data->viewer_ui_merge_id = gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), viewer_ui_info, -1, &error); if (data->viewer_ui_merge_id == 0) { g_warning ("ui building failed: %s", error->message); g_clear_error (&error); } break; default: break; } }
void edit_metadata__gth_browser_construct_cb (GthBrowser *browser) { BrowserData *data; GError *error = NULL; g_return_if_fail (GTH_IS_BROWSER (browser)); data = g_new0 (BrowserData, 1); data->browser = browser; data->actions = gtk_action_group_new ("Edit Metadata Actions"); gtk_action_group_set_translation_domain (data->actions, NULL); _gtk_action_group_add_actions_with_flags (data->actions, edit_metadata_action_entries, G_N_ELEMENTS (edit_metadata_action_entries), browser); gtk_ui_manager_insert_action_group (gth_browser_get_ui_manager (browser), data->actions, 0); if (! gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), fixed_ui_info, -1, &error)) { g_message ("building menus failed: %s", error->message); g_error_free (error); } if (gth_main_extension_is_active ("list_tools") && ! gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), fixed_ui_file_tools_info, -1, &error)) { g_message ("building menus failed: %s", error->message); g_error_free (error); } g_object_set_data_full (G_OBJECT (browser), BROWSER_DATA_KEY, data, (GDestroyNotify) browser_data_free); }
void db__gth_browser_construct_cb (GthBrowser *browser) { BrowserData *data; GError *error = NULL; g_return_if_fail (GTH_IS_BROWSER (browser)); data = g_new0 (BrowserData, 1); data->action_group = gtk_action_group_new ("Desktop Background Actions"); gtk_action_group_set_translation_domain (data->action_group, NULL); gtk_action_group_add_actions (data->action_group, action_entries, G_N_ELEMENTS (action_entries), browser); gtk_ui_manager_insert_action_group (gth_browser_get_ui_manager (browser), data->action_group, 0); if (! gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), fixed_ui_info, -1, &error)) { g_message ("building menus failed: %s", error->message); g_clear_error (&error); } gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (gtk_ui_manager_get_widget (gth_browser_get_ui_manager (browser), "/FileListPopup/Screen_Actions/DesktopBackground")), TRUE); gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (gtk_ui_manager_get_widget (gth_browser_get_ui_manager (browser), "/FilePopup/Screen_Actions/DesktopBackground")), TRUE); g_object_set_data_full (G_OBJECT (browser), BROWSER_DATA_KEY, data, (GDestroyNotify) browser_data_free); }
void edit_metadata__gth_browser_construct_cb (GthBrowser *browser) { BrowserData *data; GError *error = NULL; g_return_if_fail (GTH_IS_BROWSER (browser)); data = g_new0 (BrowserData, 1); data->browser = browser; data->actions = gtk_action_group_new ("Edit Metadata Actions"); gtk_action_group_set_translation_domain (data->actions, NULL); gtk_action_group_add_actions (data->actions, edit_metadata_action_entries, G_N_ELEMENTS (edit_metadata_action_entries), browser); gtk_ui_manager_insert_action_group (gth_browser_get_ui_manager (browser), data->actions, 0); if (! gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), fixed_ui_info, -1, &error)) { g_message ("building menus failed: %s", error->message); g_error_free (error); } gtk_tool_item_set_is_important (GTK_TOOL_ITEM (gtk_ui_manager_get_widget (gth_browser_get_ui_manager (browser), "/Fullscreen_ToolBar/Edit_Actions/Edit_Metadata")), TRUE); g_object_set_data_full (G_OBJECT (browser), BROWSER_DATA_KEY, data, (GDestroyNotify) browser_data_free); }
void export_tools__gth_browser_construct_cb (GthBrowser *browser) { BrowserData *data; GtkAction *action; GError *error = NULL; guint merge_id; g_return_if_fail (GTH_IS_BROWSER (browser)); data = g_new0 (BrowserData, 1); data->browser = browser; data->action_group = gtk_action_group_new ("Export Tools Actions"); gtk_action_group_set_translation_domain (data->action_group, NULL); /* tools menu action */ action = g_object_new (GTH_TYPE_TOGGLE_MENU_ACTION, "name", "ExportTools", "icon-name", "share", "label", _("Share"), /*"tooltip", _("Export files"),*/ "is-important", TRUE, NULL); gth_toggle_menu_action_set_show_menu_func (GTH_TOGGLE_MENU_ACTION (action), export_tools_show_menu_func, data, NULL); gtk_action_group_add_action (data->action_group, action); g_object_unref (action); gtk_ui_manager_insert_action_group (gth_browser_get_ui_manager (browser), data->action_group, 0); merge_id = gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), ui_info, -1, &error); if (merge_id == 0) { g_warning ("building ui failed: %s", error->message); g_clear_error (&error); } g_object_set_data_full (G_OBJECT (browser), BROWSER_DATA_KEY, data, (GDestroyNotify) browser_data_free); }
static void gth_media_viewer_page_real_hide (GthViewerPage *base) { GthMediaViewerPage *self; self = (GthMediaViewerPage*) base; if (self->priv->merge_id != 0) { gtk_ui_manager_remove_ui (gth_browser_get_ui_manager (self->priv->browser), self->priv->merge_id); self->priv->merge_id = 0; } if ((self->priv->playbin != NULL) && self->priv->playing) gst_element_set_state (self->priv->playbin, GST_STATE_PAUSED); }
static void export_tools_show_menu_func (GtkAction *action, gpointer user_data) { BrowserData *data = user_data; GtkWidget *menu; if (data->menu_initialized) return; data->menu_initialized = TRUE; menu = gtk_ui_manager_get_widget (gth_browser_get_ui_manager (data->browser), "/ExportPopup"); g_object_set (action, "menu", menu, NULL); }
static void file_manager_update_ui (BrowserData *data, GthBrowser *browser) { if (GTH_IS_FILE_SOURCE_VFS (gth_browser_get_location_source (browser))) { if (data->vfs_merge_id == 0) { GError *local_error = NULL; data->vfs_merge_id = gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), vfs_ui_info, -1, &local_error); if (data->vfs_merge_id == 0) { g_warning ("building ui failed: %s", local_error->message); g_error_free (local_error); } } } else if (data->vfs_merge_id != 0) { gtk_ui_manager_remove_ui (gth_browser_get_ui_manager (browser), data->vfs_merge_id); data->vfs_merge_id = 0; } if (gth_window_get_current_page (GTH_WINDOW (browser)) == GTH_BROWSER_PAGE_BROWSER) { if (data->browser_merge_id == 0) { GError *local_error = NULL; data->browser_merge_id = gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), browser_ui_info, -1, &local_error); if (data->browser_merge_id == 0) { g_warning ("building ui failed: %s", local_error->message); g_error_free (local_error); } } } else if (data->browser_merge_id != 0) { gtk_ui_manager_remove_ui (gth_browser_get_ui_manager (browser), data->browser_merge_id); data->browser_merge_id = 0; } if (GTH_IS_FILE_SOURCE_VFS (gth_browser_get_location_source (browser)) && (gth_window_get_current_page (GTH_WINDOW (browser)) == GTH_BROWSER_PAGE_BROWSER)) { if (data->browser_vfs_merge_id == 0) { GError *local_error = NULL; data->browser_vfs_merge_id = gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), browser_vfs_ui_info, -1, &local_error); if (data->browser_vfs_merge_id == 0) { g_warning ("building ui failed: %s", local_error->message); g_error_free (local_error); } } } else if (data->browser_vfs_merge_id != 0) { gtk_ui_manager_remove_ui (gth_browser_get_ui_manager (browser), data->browser_vfs_merge_id); data->browser_vfs_merge_id = 0; } }
static void gth_media_viewer_page_real_show (GthViewerPage *base) { GthMediaViewerPage *self; GError *error = NULL; GstBus *bus; char *uri; self = (GthMediaViewerPage*) base; if (self->priv->merge_id != 0) return; self->priv->merge_id = gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (self->priv->browser), media_viewer_ui_info, -1, &error); if (self->priv->merge_id == 0) { g_warning ("ui building failed: %s", error->message); g_error_free (error); } gth_viewer_page_focus (GTH_VIEWER_PAGE (self)); if (self->priv->playbin != NULL) return; self->priv->playbin = gst_element_factory_make ("playbin", "playbin"); g_signal_connect (self->priv->playbin, "notify::volume", G_CALLBACK (playbin_notify_volume_cb), self); bus = gst_pipeline_get_bus (GST_PIPELINE (self->priv->playbin)); gst_bus_enable_sync_message_emission (bus); gst_bus_set_sync_handler (bus, (GstBusSyncHandler) set_playbin_window, self); gst_bus_add_signal_watch (bus); g_signal_connect (bus, "message", G_CALLBACK (bus_message_cb), self); if (self->priv->file_data == NULL) return; uri = g_file_get_uri (self->priv->file_data->file); g_object_set (G_OBJECT (self->priv->playbin), "uri", uri, NULL); gst_element_set_state (self->priv->playbin, GST_STATE_PAUSED); g_free (uri); }
static void gth_media_viewer_page_real_activate (GthViewerPage *base, GthBrowser *browser) { GthMediaViewerPage *self; if (! gstreamer_init ()) return; self = (GthMediaViewerPage*) base; self->priv->browser = browser; self->priv->actions = gtk_action_group_new ("Video Viewer Actions"); gtk_action_group_set_translation_domain (self->priv->actions, NULL); gtk_action_group_add_actions (self->priv->actions, media_viewer_action_entries, G_N_ELEMENTS (media_viewer_action_entries), self); gtk_ui_manager_insert_action_group (gth_browser_get_ui_manager (browser), self->priv->actions, 0); self->priv->area_box = gtk_vbox_new (FALSE, 0); /* video area */ self->priv->area = gtk_drawing_area_new (); gtk_widget_set_double_buffered (self->priv->area, FALSE); gtk_widget_add_events (self->priv->area, (gtk_widget_get_events (self->priv->area) | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK)); GTK_WIDGET_SET_FLAGS (self->priv->area, GTK_CAN_FOCUS); gtk_widget_show (self->priv->area); gtk_box_pack_start (GTK_BOX (self->priv->area_box), self->priv->area, TRUE, TRUE, 0); g_signal_connect (G_OBJECT (self->priv->area), "realize", G_CALLBACK (video_area_realize_cb), self); g_signal_connect (G_OBJECT (self->priv->area), "unrealize", G_CALLBACK (video_area_unrealize_cb), self); g_signal_connect (G_OBJECT (self->priv->area), "expose_event", G_CALLBACK (video_area_expose_event_cb), self); g_signal_connect (G_OBJECT (self->priv->area), "button_press_event", G_CALLBACK (video_area_button_press_cb), self); g_signal_connect (G_OBJECT (self->priv->area), "scroll_event", G_CALLBACK (video_area_scroll_event_cb), self); g_signal_connect (G_OBJECT (self->priv->area), "key_press_event", G_CALLBACK (video_area_key_press_cb), self); /* mediabar */ self->priv->builder = _gtk_builder_new_from_file ("mediabar.ui", "gstreamer_tools"); self->priv->mediabar = GET_WIDGET ("mediabar"); gtk_widget_show (self->priv->mediabar); gtk_box_pack_start (GTK_BOX (self->priv->area_box), self->priv->mediabar, FALSE, FALSE, 0); g_signal_connect (GET_WIDGET ("adjustment_volume"), "value-changed", G_CALLBACK (volume_value_changed_cb), self); g_signal_connect (GET_WIDGET ("adjustment_position"), "value-changed", G_CALLBACK (position_value_changed_cb), self); g_signal_connect (GET_WIDGET ("hscale_volume"), "format-value", G_CALLBACK (hscale_volume_format_value_cb), self); g_signal_connect (GET_WIDGET ("hscale_position"), "change-value", G_CALLBACK (hscale_position_change_value_cb), self); g_signal_connect (GET_WIDGET ("hscale_position"), "button-release-event", G_CALLBACK (hscale_position_button_release_event_cb), self); g_signal_connect (GET_WIDGET ("button_play"), "clicked", G_CALLBACK (button_play_clicked_cb), self); g_signal_connect (GET_WIDGET ("togglebutton_volume"), "toggled", G_CALLBACK (togglebutton_volume_toggled_cb), self); g_signal_connect (GET_WIDGET ("button_play_slower"), "clicked", G_CALLBACK (button_play_slower_clicked_cb), self); g_signal_connect (GET_WIDGET ("button_play_faster"), "clicked", G_CALLBACK (button_play_faster_clicked_cb), self); gtk_widget_show (self->priv->area_box); gth_browser_set_viewer_widget (browser, self->priv->area_box); gtk_widget_realize (self->priv->area); gdk_window_ensure_native (gtk_widget_get_window (self->priv->area)); gth_viewer_page_focus (GTH_VIEWER_PAGE (self)); }
void fm__gth_browser_construct_cb (GthBrowser *browser) { BrowserData *data; GError *error = NULL; GtkWidget *file_view; g_return_if_fail (GTH_IS_BROWSER (browser)); data = g_new0 (BrowserData, 1); data->action_group = gtk_action_group_new ("File Manager Actions"); gtk_action_group_set_translation_domain (data->action_group, NULL); gtk_action_group_add_actions (data->action_group, action_entries, G_N_ELEMENTS (action_entries), browser); gtk_ui_manager_insert_action_group (gth_browser_get_ui_manager (browser), data->action_group, 0); set_action_sensitive (data, "Edit_PasteInFolder", FALSE); data->fixed_merge_id = gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), fixed_ui_info, -1, &error); if (data->fixed_merge_id == 0) { g_warning ("building ui failed: %s", error->message); g_error_free (error); } file_view = gth_file_list_get_view (GTH_FILE_LIST (gth_browser_get_file_list (browser))); g_signal_connect (file_view, "drag_data_received", G_CALLBACK (gth_file_list_drag_data_received), browser); g_signal_connect (file_view, "drag_drop", G_CALLBACK (gth_file_list_drag_drop), browser); g_signal_connect (file_view, "drag_motion", G_CALLBACK (gth_file_list_drag_motion), browser); g_signal_connect (file_view, "drag_leave", G_CALLBACK (gth_file_list_drag_leave), browser); g_signal_connect (file_view, "drag_end", G_CALLBACK (gth_file_list_drag_end), browser); file_view = gth_file_list_get_empty_view (GTH_FILE_LIST (gth_browser_get_file_list (browser))); g_signal_connect (file_view, "drag_data_received", G_CALLBACK (gth_file_list_drag_data_received), browser); g_signal_connect (file_view, "drag_drop", G_CALLBACK (gth_file_list_drag_drop), browser); g_signal_connect (file_view, "drag_motion", G_CALLBACK (gth_file_list_drag_motion), browser); g_signal_connect (file_view, "drag_leave", G_CALLBACK (gth_file_list_drag_leave), browser); g_signal_connect (file_view, "drag_end", G_CALLBACK (gth_file_list_drag_end), browser); g_object_set_data_full (G_OBJECT (browser), BROWSER_DATA_KEY, data, (GDestroyNotify) browser_data_free); }
static void _gth_browser_update_open_menu (GthBrowser *browser, const char *path) { GtkWidget *openwith_item; GtkWidget *menu; GList *items; GList *file_list; GList *scan; GList *appinfo_list; GHashTable *used_mime_types; GthIconCache *icon_cache; GHashTable *used_apps; openwith_item = gtk_ui_manager_get_widget (gth_browser_get_ui_manager (browser), path); menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (openwith_item)); _gtk_container_remove_children (GTK_CONTAINER (menu), NULL, NULL); items = gth_file_selection_get_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser))); file_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (browser)), items); appinfo_list = NULL; used_mime_types = g_hash_table_new (g_str_hash, g_str_equal); for (scan = file_list; scan; scan = scan->next) { GthFileData *file_data = scan->data; const char *mime_type; mime_type = gth_file_data_get_mime_type (file_data); if ((mime_type == NULL) || g_content_type_is_unknown (mime_type)) continue; if (g_hash_table_lookup (used_mime_types, mime_type) != NULL) continue; appinfo_list = g_list_concat (appinfo_list, g_app_info_get_all_for_type (mime_type)); g_hash_table_insert (used_mime_types, (gpointer) mime_type, GINT_TO_POINTER (1)); } g_hash_table_destroy (used_mime_types); icon_cache = gth_browser_get_menu_icon_cache (browser); used_apps = g_hash_table_new (g_str_hash, g_str_equal); for (scan = appinfo_list; scan; scan = scan->next) { GAppInfo *appinfo = scan->data; char *label; GtkWidget *menu_item; GIcon *icon; if (strcmp (g_app_info_get_executable (appinfo), "pix") == 0) continue; if (g_hash_table_lookup (used_apps, g_app_info_get_id (appinfo)) != NULL) continue; g_hash_table_insert (used_apps, (gpointer) g_app_info_get_id (appinfo), GINT_TO_POINTER (1)); label = g_strdup_printf ("%s", g_app_info_get_name (appinfo)); menu_item = gtk_image_menu_item_new_with_label (label); icon = g_app_info_get_icon (appinfo); if (icon != NULL) { GdkPixbuf *pixbuf; pixbuf = gth_icon_cache_get_pixbuf (icon_cache, icon); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), gtk_image_new_from_pixbuf (pixbuf)); gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menu_item), TRUE); g_object_unref (pixbuf); } gtk_widget_show (menu_item); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); g_object_set_data_full (G_OBJECT (menu_item), "appinfo", g_object_ref (appinfo), g_object_unref); g_signal_connect (menu_item, "activate", G_CALLBACK (activate_open_with_application_item), browser); g_free (label); } /* if (appinfo_list == NULL) { GtkWidget *menu_item; menu_item = gtk_image_menu_item_new_with_label (_("No application available")); gtk_widget_set_sensitive (menu_item, FALSE); gtk_widget_show (menu_item); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); }*/ gtk_widget_set_sensitive (openwith_item, appinfo_list != NULL); gtk_widget_show (openwith_item); g_hash_table_destroy (used_apps); _g_object_list_unref (appinfo_list); _g_object_list_unref (file_list); _gtk_tree_path_list_free (items); }