summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/caja-view-as-action.c7
-rw-r--r--src/caja-window-manage-views.c8
-rw-r--r--src/file-manager/fm-widget-view.c90
3 files changed, 88 insertions, 17 deletions
diff --git a/src/caja-view-as-action.c b/src/caja-view-as-action.c
index 4c1a7d4b..27e70be2 100644
--- a/src/caja-view-as-action.c
+++ b/src/caja-view-as-action.c
@@ -145,6 +145,12 @@ view_as_changed_callback (CajaWindow *window,
}
}
g_object_set_data (G_OBJECT (combo_box), "num viewers", GINT_TO_POINTER (index));
+
+ if (g_list_length (window->details->short_list_viewers) == 1)
+ {
+ selected_index = 0;
+ }
+
if (selected_index == -1)
{
const char *id;
@@ -156,7 +162,6 @@ view_as_changed_callback (CajaWindow *window,
_(info->view_combo_label));
selected_index = index;
}
-
gtk_combo_box_set_active (combo_box, selected_index);
if (g_list_length (window->details->short_list_viewers) == 1) {
gtk_widget_hide(GTK_WIDGET(combo_box));
diff --git a/src/caja-window-manage-views.c b/src/caja-window-manage-views.c
index caaa858b..200fa791 100644
--- a/src/caja-window-manage-views.c
+++ b/src/caja-window-manage-views.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Caja
@@ -1309,9 +1309,9 @@ got_file_info_for_view_selection_callback (CajaFile *file,
}
else
{
- if (!report_callback (slot, error)) {
- display_view_selection_failure (window, file,
- location, error);
+ if (!report_callback (slot, error)) {
+ display_view_selection_failure (window, file,
+ location, error);
}
if (!gtk_widget_get_visible (GTK_WIDGET (window)))
diff --git a/src/file-manager/fm-widget-view.c b/src/file-manager/fm-widget-view.c
index c22643a8..4edf473e 100644
--- a/src/file-manager/fm-widget-view.c
+++ b/src/file-manager/fm-widget-view.c
@@ -34,14 +34,16 @@
#include <libcaja-private/caja-view-factory.h>
#include <libcaja-private/caja-extensions.h>
#include <libcaja-private/caja-module.h>
+#include <libcaja-private/caja-metadata.h>
#include <libcaja-extension/caja-widget-view-provider.h>
#include "fm-widget-view.h"
struct _FMWidgetView
{
- FMDirectoryView object;
- int number_of_files;
+ FMDirectoryView object;
+ int number_of_files;
+ CajaWidgetViewProvider *provider;
};
static GList *fm_widget_view_get_selection (FMDirectoryView *view);
@@ -50,11 +52,12 @@ static void fm_widget_view_scroll_to_file (CajaView *view, co
static void fm_widget_view_iface_init (CajaViewIface *iface);
G_DEFINE_TYPE_WITH_CODE (FMWidgetView, fm_widget_view, FM_TYPE_DIRECTORY_VIEW,
- G_IMPLEMENT_INTERFACE (CAJA_TYPE_VIEW, fm_widget_view_iface_init));
+ G_IMPLEMENT_INTERFACE (CAJA_TYPE_VIEW, fm_widget_view_iface_init));
static void
fm_widget_view_add_file (FMDirectoryView *view, CajaFile *file, CajaDirectory *directory)
{
+ CajaFile *file_dir;
static GTimer *timer = NULL;
static gdouble cumu = 0, elaps;
FM_WIDGET_VIEW (view)->number_of_files++;
@@ -64,7 +67,7 @@ fm_widget_view_add_file (FMDirectoryView *view, CajaFile *file, CajaDirectory *d
g_timer_start (timer);
icon = caja_file_get_icon_surface (file, caja_get_icon_size_for_zoom_level (CAJA_ZOOM_LEVEL_STANDARD),
- TRUE, gtk_widget_get_scale_factor (GTK_WIDGET(view)), 0);
+ TRUE, gtk_widget_get_scale_factor (GTK_WIDGET(view)), 0);
elaps = g_timer_elapsed (timer, NULL);
g_timer_stop (timer);
@@ -73,12 +76,63 @@ fm_widget_view_add_file (FMDirectoryView *view, CajaFile *file, CajaDirectory *d
cumu += elaps;
g_message ("entire loading: %.3f, cumulative %.3f", elaps, cumu);
+
+ FMWidgetView *widget_view;
+
+ widget_view = FM_WIDGET_VIEW (view);
+ file_dir = caja_directory_get_corresponding_file (directory);
+ caja_widget_view_provider_add_file (widget_view->provider, file, file_dir);
}
static void
fm_widget_view_begin_loading (FMDirectoryView *view)
{
+ GtkWindow *window;
+ CajaFile *file;
+ gchar *uri;
+ GList *providers, *l;
+ char *mimetype;
+ GtkWidget *widget;
+ FMWidgetView *widget_view;
+
+ widget_view = FM_WIDGET_VIEW (view);
+
+ uri = fm_directory_view_get_uri (view);
+ file = caja_file_get_by_uri (uri);
+ mimetype = caja_file_get_mime_type (file);
+
+ providers = caja_extensions_get_for_type (CAJA_TYPE_WIDGET_VIEW_PROVIDER);
+ for (l = providers; l != NULL; l = l->next)
+ {
+ CajaWidgetViewProvider *provider;
+
+ provider = CAJA_WIDGET_VIEW_PROVIDER (l->data);
+ if (caja_widget_view_provider_supports_uri (provider, uri,
+ caja_file_get_file_type (file),
+ mimetype)) {
+ widget_view->provider = provider;
+ break;
+ }
+ }
+
+ caja_module_extension_list_free (providers);
+
+ if (widget_view->provider == NULL) {
+ return;
+ }
+
+ caja_widget_view_provider_set_location (widget_view->provider, uri);
+
+ widget = caja_widget_view_provider_get_widget (widget_view->provider);
+ gtk_container_add (GTK_CONTAINER(widget_view), widget);
+
+ window = fm_directory_view_get_containing_window (view);
+ caja_widget_view_provider_set_window (widget_view->provider, window);
+
+ g_print("uri in widget_view = %s, window=%p\n", uri, window);
+
+ g_free (mimetype);
}
static void
@@ -183,7 +237,7 @@ fm_widget_view_get_zoom_level (FMDirectoryView *view)
static void
fm_widget_view_zoom_to_level (FMDirectoryView *view,
- CajaZoomLevel zoom_level)
+ CajaZoomLevel zoom_level)
{
}
@@ -206,8 +260,8 @@ fm_widget_view_can_zoom_out (FMDirectoryView *view)
static void
fm_widget_view_start_renaming_file (FMDirectoryView *view,
- CajaFile *file,
- gboolean select_all)
+ CajaFile *file,
+ gboolean select_all)
{
}
@@ -263,6 +317,8 @@ fm_widget_view_emblems_changed (FMDirectoryView *directory_view)
static char *
fm_widget_view_get_first_visible_file (CajaView *view)
{
+ //FIXME: return string to tell caja we are ready.
+ return g_strdup("file:///tmp/a.txt");
return NULL;
}
@@ -347,8 +403,15 @@ fm_widget_view_iface_init (CajaViewIface *iface)
static void
fm_widget_view_init (FMWidgetView *widget_view)
{
- GtkWindow *window;
- window = fm_directory_view_get_containing_window (FM_DIRECTORY_VIEW(widget_view));
+ //GtkWidget *widget;
+
+ //widget = gtk_app_chooser_widget_new ("text/plain");
+ //gtk_app_chooser_widget_set_show_all (GTK_APP_CHOOSER_WIDGET(widget), TRUE);
+
+ //gtk_container_add (GTK_CONTAINER(widget_view), widget);
+ //gtk_widget_show(widget);
+
+ widget_view->provider = NULL;
}
static CajaView *
@@ -379,11 +442,16 @@ fm_widget_view_supports_uri (const char *uri,
CajaWidgetViewProvider *provider;
provider = CAJA_WIDGET_VIEW_PROVIDER (l->data);
- if (caja_widget_view_supports_uri (provider, uri, file_type, mime_type)) {
+ if (caja_widget_view_provider_supports_uri (provider, uri, file_type, mime_type)) {
+ //CajaFile *file;
+ //file = caja_file_get_by_uri (uri);
+ //caja_file_set_metadata (file, CAJA_METADATA_KEY_DEFAULT_VIEW, NULL, FM_WIDGET_VIEW_ID);
+ //caja_file_unref (file);
result = TRUE;
}
}
caja_module_extension_list_free (providers);
+
return result;
}
@@ -391,7 +459,6 @@ static CajaViewInfo fm_widget_view =
{
.id = FM_WIDGET_VIEW_ID,
.view_combo_label = N_("Widget View"),
- /* translators: this is used in the view menu */
.view_menu_label_with_mnemonic = N_("_Widget View"),
.error_label = N_("The widget view encountered an error."),
.startup_error_label = N_("The widget view encountered an error while starting up."),
@@ -410,6 +477,5 @@ fm_widget_view_register (void)
fm_widget_view.startup_error_label = _(fm_widget_view.startup_error_label);
fm_widget_view.display_location_label = _(fm_widget_view.display_location_label);
fm_widget_view.single_view = TRUE;
-
caja_view_factory_register (&fm_widget_view);
}