static void view_as_changed_callback (CajaWindow *window, GtkComboBox *combo_box) { CajaWindowSlot *slot; GList *node; int index; int selected_index = -1; GtkTreeModel *model; GtkListStore *store; const CajaViewInfo *info; /* Clear the contents of ComboBox in a wacky way because there * is no function to clear all items and also no function to obtain * the number of items in a combobox. */ model = gtk_combo_box_get_model (combo_box); g_return_if_fail (GTK_IS_LIST_STORE (model)); store = GTK_LIST_STORE (model); gtk_list_store_clear (store); slot = caja_window_get_active_slot (window); /* Add a menu item for each view in the preferred list for this location. */ for (node = window->details->short_list_viewers, index = 0; node != NULL; node = node->next, ++index) { info = caja_view_factory_lookup (node->data); gtk_combo_box_append_text (combo_box, _(info->view_combo_label)); if (caja_window_slot_content_view_matches_iid (slot, (char *)node->data)) { selected_index = index; } } g_object_set_data (G_OBJECT (combo_box), "num viewers", GINT_TO_POINTER (index)); if (selected_index == -1) { const char *id; /* We're using an extra viewer, add a menu item for it */ id = caja_window_slot_get_content_view_id (slot); info = caja_view_factory_lookup (id); gtk_combo_box_append_text (combo_box, _(info->view_combo_label)); selected_index = index; } gtk_combo_box_set_active (combo_box, selected_index); }
void caja_view_factory_register (CajaViewInfo *view_info) { g_return_if_fail (view_info != NULL); g_return_if_fail (view_info->id != NULL); g_return_if_fail (caja_view_factory_lookup (view_info->id) == NULL); registered_views = g_list_append (registered_views, view_info); }
CajaView * caja_view_factory_create (const char *id, CajaWindowSlotInfo *slot) { const CajaViewInfo *view_info; CajaView *view; view_info = caja_view_factory_lookup (id); if (view_info == NULL) { return NULL; } view = view_info->create (slot); if (g_object_is_floating (view)) { g_object_ref_sink (view); } return view; }
gboolean caja_view_factory_view_supports_uri (const char *id, GFile *location, GFileType file_type, const char *mime_type) { const CajaViewInfo *view_info; char *uri; gboolean res; view_info = caja_view_factory_lookup (id); if (view_info == NULL) { return FALSE; } uri = g_file_get_uri (location); res = view_info->supports_uri (uri, file_type, mime_type); g_free (uri); return res; }