[nautilus/wip/csoriano/flow: 537/537] zooms working
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/csoriano/flow: 537/537] zooms working
- Date: Sun, 27 Nov 2016 16:30:54 +0000 (UTC)
commit 9853b57f2990450f9f6dac2dbc270cd2b8ee8509
Author: Carlos Soriano <csoriano gnome org>
Date: Sun Nov 27 17:29:37 2016 +0100
zooms working
src/nautilus-file.c | 2 +-
src/nautilus-files-view.c | 4 +
src/nautilus-icon-info.h | 4 +-
src/nautilus-icon-view.c | 262 ++++++++++++++++++++++++++++----------------
4 files changed, 174 insertions(+), 98 deletions(-)
---
diff --git a/src/nautilus-file.c b/src/nautilus-file.c
index 26a7672..e5fde42 100644
--- a/src/nautilus-file.c
+++ b/src/nautilus-file.c
@@ -5334,7 +5334,7 @@ nautilus_file_get_thumbnail_icon (NautilusFile *file,
{
if (nautilus_is_video_file (file))
{
- nautilus_ui_frame_video (&pixbuf);
+ //nautilus_ui_frame_video (&pixbuf);
}
else
{
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index bcf64d2..8435c4b 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -750,8 +750,10 @@ nautilus_files_view_can_zoom_in (NautilusFilesView *view)
{
g_return_val_if_fail (NAUTILUS_IS_FILES_VIEW (view), FALSE);
+ g_print ("eeo supports zooming %d\n", view->details->supports_zooming);
if (!nautilus_files_view_supports_zooming (view))
{
+ g_print ("wooow\n");
return FALSE;
}
@@ -785,6 +787,7 @@ nautilus_files_view_supports_zooming (NautilusFilesView *view)
{
g_return_val_if_fail (NAUTILUS_IS_FILES_VIEW (view), FALSE);
+ g_print ("supports zooming %d\n", view->details->supports_zooming);
return view->details->supports_zooming;
}
@@ -7391,6 +7394,7 @@ real_update_actions_state (NautilusFilesView *view)
"zoom-in");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
nautilus_files_view_can_zoom_in (view));
+ g_print ("enabling zoom in!!!!! %d\n", nautilus_files_view_can_zoom_in (view));
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
"zoom-out");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
diff --git a/src/nautilus-icon-info.h b/src/nautilus-icon-info.h
index f034ba8..65e3abb 100644
--- a/src/nautilus-icon-info.h
+++ b/src/nautilus-icon-info.h
@@ -38,10 +38,10 @@ typedef enum {
#define NAUTILUS_LIST_ICON_SIZE_LARGE 48
#define NAUTILUS_LIST_ICON_SIZE_LARGER 64
-#define NAUTILUS_CANVAS_ICON_SIZE_SMALL 48
+#define NAUTILUS_CANVAS_ICON_SIZE_SMALL 32
#define NAUTILUS_CANVAS_ICON_SIZE_STANDARD 64
#define NAUTILUS_CANVAS_ICON_SIZE_LARGE 96
-#define NAUTILUS_CANVAS_ICON_SIZE_LARGER 128
+#define NAUTILUS_CANVAS_ICON_SIZE_LARGER 256
/* Maximum size of an icon that the icon factory will ever produce */
#define NAUTILUS_ICON_MAXIMUM_SIZE 320
diff --git a/src/nautilus-icon-view.c b/src/nautilus-icon-view.c
index 264bc47..b0f585f 100644
--- a/src/nautilus-icon-view.c
+++ b/src/nautilus-icon-view.c
@@ -32,8 +32,9 @@ typedef struct
{
GtkWidget *flow_box;
GtkWidget *view_icon;
- guint icon_size;
GListModel *model;
+ GActionGroup *view_action_group;
+ gint zoom_level;
} NautilusIconViewPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (NautilusIconView, nautilus_icon_view, NAUTILUS_TYPE_FILES_VIEW)
@@ -46,7 +47,7 @@ get_default_zoom_level ()
default_zoom_level = g_settings_get_enum (nautilus_icon_view_preferences,
NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL);
- return 96;
+ return NAUTILUS_CANVAS_ZOOM_LEVEL_LARGE;
}
static void
@@ -148,6 +149,18 @@ static void
real_bump_zoom_level (NautilusFilesView *self,
int zoom_increment)
{
+ NautilusIconViewPrivate *priv = nautilus_icon_view_get_instance_private (self);
+ NautilusCanvasZoomLevel new_level;
+
+ new_level = priv->zoom_level + zoom_increment;
+
+ if (new_level >= NAUTILUS_CANVAS_ZOOM_LEVEL_SMALL &&
+ new_level <= NAUTILUS_CANVAS_ZOOM_LEVEL_LARGER)
+ {
+ g_action_group_change_action_state (priv->view_action_group,
+ "zoom-to-level",
+ g_variant_new_int32 (new_level));
+ }
}
static guint
@@ -155,12 +168,137 @@ real_get_zoom_level (NautilusFilesView *self)
{
NautilusIconViewPrivate *priv = nautilus_icon_view_get_instance_private (self);
- return priv->icon_size;
+ return priv->zoom_level;
+}
+
+static guint
+get_icon_size_for_zoom_level (NautilusCanvasZoomLevel zoom_level)
+{
+ g_print ("get icon size for zoom level %d\n", zoom_level);
+ switch (zoom_level)
+ {
+ case NAUTILUS_CANVAS_ZOOM_LEVEL_SMALL:
+ {
+ return NAUTILUS_CANVAS_ICON_SIZE_SMALL;
+ }
+ break;
+
+ case NAUTILUS_CANVAS_ZOOM_LEVEL_STANDARD:
+ {
+ return NAUTILUS_CANVAS_ICON_SIZE_STANDARD;
+ }
+ break;
+
+ case NAUTILUS_CANVAS_ZOOM_LEVEL_LARGE:
+ {
+ return NAUTILUS_CANVAS_ICON_SIZE_LARGE;
+ }
+ break;
+
+ case NAUTILUS_CANVAS_ZOOM_LEVEL_LARGER:
+ {
+ return NAUTILUS_CANVAS_ICON_SIZE_LARGER;
+ }
+ break;
+ }
+ g_return_val_if_reached (NAUTILUS_CANVAS_ICON_SIZE_STANDARD);
+}
+
+static GtkWidget*
+create_icon (NautilusIconView *self,
+ NautilusFile *file)
+{
+ NautilusIconViewPrivate *priv = nautilus_icon_view_get_instance_private (self);
+ NautilusFileIconFlags flags;
+ g_autoptr (GdkPixbuf) icon_pixbuf;
+ GtkImage *icon;
+ GtkWidget *fixed_height_box;
+
+ flags = NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS |
+ NAUTILUS_FILE_ICON_FLAGS_FORCE_THUMBNAIL_SIZE |
+ NAUTILUS_FILE_ICON_FLAGS_USE_EMBLEMS |
+ NAUTILUS_FILE_ICON_FLAGS_USE_ONE_EMBLEM;
+
+ icon_pixbuf = nautilus_file_get_icon_pixbuf (file, get_icon_size_for_zoom_level (priv->zoom_level),
+ TRUE, 1, flags);
+ icon = gtk_image_new_from_pixbuf (icon_pixbuf);
+ gtk_widget_set_hexpand (icon_pixbuf, TRUE);
+ gtk_widget_set_vexpand (icon_pixbuf, TRUE);
+ gtk_widget_set_valign (icon, GTK_ALIGN_END);
+ gtk_widget_set_halign (icon, GTK_ALIGN_FILL);
+ fixed_height_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ gtk_widget_set_size_request (fixed_height_box, 96,
+ get_icon_size_for_zoom_level (priv->zoom_level));
+ GtkStyleContext *style_contet = gtk_widget_get_style_context (icon);
+ //.icon-background {background-color:#fbfbfb; box-shadow: 0px 0px 4px #DDD; margin-bottom:4px}
+ gtk_style_context_add_class (style_contet, "icon-background");
+#if 0
+ gtk_widget_set_size_request (fixed_height_box, 130,
+ -1);
+#endif
+ gtk_box_pack_start (fixed_height_box, icon, TRUE, TRUE, 0);
+
+ gtk_widget_show_all (fixed_height_box);
+
+ return fixed_height_box;
+}
+
+static void
+replace_icon (NautilusIconView *self,
+ GtkWidget *flow_box_item)
+{
+ GtkWidget *new_icon;
+ GtkWidget *old_icon;
+ GtkWidget *box;
+ NautilusFile *file;
+
+ file = g_object_get_data (flow_box_item, "file");
+ old_icon = g_object_get_data (flow_box_item, "icon");
+
+ box = gtk_bin_get_child (GTK_BIN (flow_box_item));
+ gtk_container_remove (GTK_CONTAINER (box), old_icon);
+ new_icon = create_icon (self, file);
+ gtk_box_pack_start (box, new_icon, FALSE, FALSE, 0);
+ g_object_set_data (flow_box_item, "icon", new_icon);
+}
+
+static void
+set_icon_size (NautilusIconView *self,
+ gint icon_size)
+{
+ NautilusIconViewPrivate *priv = nautilus_icon_view_get_instance_private (self);
+ g_autoptr (GList) items;
+ GList *l;
+ g_autoptr (GList) box_children;
+ GtkWidget *flow_box_item;
+
+ g_print ("new size %d\n", icon_size);
+ items = gtk_container_get_children (priv->flow_box);
+
+ for (l = items; l; l = l->next)
+ {
+ flow_box_item = GTK_WIDGET (l->data);
+ replace_icon (self, flow_box_item);
+ }
}
static void
-real_zoom_to_level (NautilusFilesView *self,
- guint icon_size)
+set_zoom_level (NautilusIconView *self,
+ guint new_level)
+{
+ NautilusIconViewPrivate *priv;
+ guint icon_size;
+
+ priv = nautilus_icon_view_get_instance_private (self);
+
+ priv->zoom_level = new_level;
+
+ icon_size = get_icon_size_for_zoom_level (new_level);
+ set_icon_size (self, icon_size);
+}
+static void
+real_zoom_to_level (NautilusFilesView *files_view,
+ guint new_level)
{
}
@@ -172,27 +310,26 @@ real_restore_standard_zoom_level (NautilusFilesView *self)
static gfloat
real_get_zoom_level_percentage (NautilusFilesView *files_view)
{
- guint icon_size;
NautilusIconView *self;
- NautilusCanvasZoomLevel zoom_level;
NautilusIconViewPrivate *priv;
self = NAUTILUS_ICON_VIEW (files_view);
priv = nautilus_icon_view_get_instance_private (self);
- return (gfloat) priv->icon_size / NAUTILUS_CANVAS_ICON_SIZE_LARGE;
+ return (gfloat) get_icon_size_for_zoom_level (priv->zoom_level) /
+ NAUTILUS_CANVAS_ICON_SIZE_LARGE;
}
static gboolean
real_can_zoom_in (NautilusFilesView *self)
{
- return FALSE;
+ return TRUE;
}
static gboolean
real_can_zoom_out (NautilusFilesView *self)
{
- return FALSE;
+ return TRUE;
}
static void
@@ -311,83 +448,16 @@ real_select_first (NautilusFilesView *self)
}
-static GtkWidget*
-create_icon (NautilusIconView *self,
- NautilusFile *file)
-{
- NautilusIconViewPrivate *priv = nautilus_icon_view_get_instance_private (self);
- NautilusFileIconFlags flags;
- g_autoptr (GdkPixbuf) icon_pixbuf;
- GtkImage *icon;
- GtkWidget *fixed_height_box;
-
- flags = NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS |
- NAUTILUS_FILE_ICON_FLAGS_FORCE_THUMBNAIL_SIZE |
- NAUTILUS_FILE_ICON_FLAGS_USE_EMBLEMS |
- NAUTILUS_FILE_ICON_FLAGS_USE_ONE_EMBLEM;
-
- icon_pixbuf = nautilus_file_get_icon_pixbuf (file, priv->icon_size, TRUE, 1, flags);
- icon = gtk_image_new_from_pixbuf (icon_pixbuf);
- gtk_widget_set_valign (icon, GTK_ALIGN_CENTER);
- fixed_height_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_widget_set_size_request (fixed_height_box, -1, priv->icon_size);
- gtk_box_pack_start (fixed_height_box, icon, TRUE, TRUE, 0);
-
- gtk_widget_show_all (fixed_height_box);
-
- return fixed_height_box;
-}
-
-static void
-replace_icon (NautilusIconView *self,
- GtkWidget *flow_box_item)
-{
- GtkWidget *new_icon;
- GtkWidget *old_icon;
- GtkWidget *box;
- NautilusFile *file;
-
- file = g_object_get_data (flow_box_item, "file");
- old_icon = g_object_get_data (flow_box_item, "icon");
-
- box = gtk_bin_get_child (GTK_BIN (flow_box_item));
- gtk_container_remove (GTK_CONTAINER (box), old_icon);
- new_icon = create_icon (self, file);
- gtk_box_pack_start (box, new_icon, FALSE, FALSE, 0);
- g_object_set_data (flow_box_item, "icon", new_icon);
-}
-
-static void
-set_icon_size (NautilusIconView *self,
- gint icon_size)
-{
- NautilusIconViewPrivate *priv = nautilus_icon_view_get_instance_private (self);
- g_autoptr (GList) items;
- GList *l;
- g_autoptr (GList) box_children;
- GtkWidget *flow_box_item;
-
- g_print ("new size %d\n", icon_size);
- priv->icon_size = icon_size;
- items = gtk_container_get_children (priv->flow_box);
-
- for (l = items; l; l = l->next)
- {
- flow_box_item = GTK_WIDGET (l->data);
- replace_icon (self, flow_box_item);
- }
-}
-
static void
action_zoom_to_level (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
- NautilusIconView *self = NAUTILUS_ICON_VIEW (user_data);
- NautilusIconViewPrivate *priv = nautilus_icon_view_get_instance_private (self);
+ NautilusIconView *self = NAUTILUS_ICON_VIEW (user_data);
+ guint icon_size;
- set_icon_size (self, g_variant_get_int32 (state));
- g_simple_action_set_state (G_SIMPLE_ACTION (action), state);
+ set_zoom_level (self, g_variant_get_int32 (state));
+ g_simple_action_set_state (G_SIMPLE_ACTION (action), state);
}
static GtkWidget*
@@ -412,7 +482,7 @@ create_widget_func (gpointer item,
gtk_label_set_max_width_chars (label, 0);
gtk_label_set_line_wrap (label, TRUE);
gtk_label_set_line_wrap_mode (label, PANGO_WRAP_WORD_CHAR);
- gtk_label_set_lines (label, 2);
+ gtk_label_set_lines (label, 4);
gtk_label_set_justify (label, GTK_JUSTIFY_CENTER);
gtk_widget_set_valign (label, GTK_ALIGN_START);
gtk_box_pack_end (container, label, TRUE, TRUE, 0);
@@ -463,7 +533,7 @@ nautilus_icon_view_finalize (GObject *object)
}
const GActionEntry icon_view_entries[] = {
- { "zoom-to-level", NULL, NULL, "96", action_zoom_to_level }
+ { "zoom-to-level", NULL, NULL, "3", action_zoom_to_level }
};
static void
@@ -508,23 +578,24 @@ static void
nautilus_icon_view_init (NautilusIconView *self)
{
NautilusIconViewPrivate *priv;
- GActionGroup *view_action_group;
GtkWidget *content_widget;
priv = nautilus_icon_view_get_instance_private (self);
priv->view_icon = g_themed_icon_new ("view-grid-symbolic");
priv->model = g_list_store_new (NAUTILUS_TYPE_FILE);
priv->flow_box = gtk_flow_box_new ();
+ gtk_flow_box_set_activate_on_single_click (priv->flow_box, FALSE);
+ gtk_flow_box_set_max_children_per_line (priv->flow_box, 20);
gtk_flow_box_bind_model (GTK_FLOW_BOX (priv->flow_box), priv->model,
create_widget_func, self, NULL);
- gtk_flow_box_set_homogeneous (priv->flow_box, TRUE);
- gtk_flow_box_set_row_spacing (priv->flow_box, 6);
- gtk_flow_box_set_column_spacing (priv->flow_box, 6);
+ gtk_flow_box_set_homogeneous (priv->flow_box, FALSE);
+ gtk_flow_box_set_row_spacing (priv->flow_box, 4);
+ gtk_flow_box_set_column_spacing (priv->flow_box, 8);
gtk_widget_set_valign (priv->flow_box, GTK_ALIGN_START);
- gtk_widget_set_margin_top (priv->flow_box, 20);
- gtk_widget_set_margin_right (priv->flow_box, 20);
- gtk_widget_set_margin_bottom (priv->flow_box, 20);
- gtk_widget_set_margin_left (priv->flow_box, 20);
+ gtk_widget_set_margin_top (priv->flow_box, 10);
+ gtk_widget_set_margin_right (priv->flow_box, 10);
+ gtk_widget_set_margin_bottom (priv->flow_box, 10);
+ gtk_widget_set_margin_left (priv->flow_box, 10);
g_signal_connect (priv->flow_box, "child-activated", (GCallback) on_child_activated, self);
@@ -534,12 +605,13 @@ nautilus_icon_view_init (NautilusIconView *self)
gtk_container_add (GTK_CONTAINER (content_widget), priv->flow_box);
- view_action_group = nautilus_files_view_get_action_group (NAUTILUS_FILES_VIEW (self));
- g_action_map_add_action_entries (G_ACTION_MAP (view_action_group),
+ priv->view_action_group = nautilus_files_view_get_action_group (NAUTILUS_FILES_VIEW (self));
+ g_action_map_add_action_entries (G_ACTION_MAP (priv->view_action_group),
icon_view_entries,
G_N_ELEMENTS (icon_view_entries),
self);
- g_action_group_change_action_state (view_action_group,
+ priv->zoom_level = get_default_zoom_level ();
+ g_action_group_change_action_state (priv->view_action_group,
"zoom-to-level",
- g_variant_new_int32 (get_default_zoom_level ()));
+ g_variant_new_int32 (priv->zoom_level));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]