[nautilus/wip/csoriano/flow] f
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/csoriano/flow] f
- Date: Fri, 2 Dec 2016 09:55:33 +0000 (UTC)
commit 18e963d52f66c01ec8db6897a228d7614c8416da
Author: Carlos Soriano <csoriano gnome org>
Date: Fri Dec 2 10:55:03 2016 +0100
f
src/Makefile.am | 4 +-
...-view-item.c => nautilus-container-max-width.c} | 58 ++++++++++----------
src/nautilus-container-max-width.h | 22 ++++++++
src/nautilus-icon-view-item.h | 24 --------
src/nautilus-icon-view.c | 19 +++----
5 files changed, 60 insertions(+), 67 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 3e2dd1a..0d38617 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -150,6 +150,8 @@ nautilus_no_main_sources = \
nautilus-canvas-view.h \
nautilus-canvas-view-container.c \
nautilus-canvas-view-container.h \
+ nautilus-container-max-width.c \
+ nautilus-container-max-width.h \
nautilus-dbus-manager.c \
nautilus-dbus-manager.h \
nautilus-desktop-item-properties.c \
@@ -168,8 +170,6 @@ nautilus_no_main_sources = \
nautilus-freedesktop-dbus.h \
nautilus-icon-view.c \
nautilus-icon-view.h \
- nautilus-icon-view-item.c \
- nautilus-icon-view-item.h \
nautilus-image-properties-page.c \
nautilus-image-properties-page.h \
nautilus-list-model.c \
diff --git a/src/nautilus-icon-view-item.c b/src/nautilus-container-max-width.c
similarity index 71%
rename from src/nautilus-icon-view-item.c
rename to src/nautilus-container-max-width.c
index 0e9ef0d..4a5762e 100644
--- a/src/nautilus-icon-view-item.c
+++ b/src/nautilus-container-max-width.c
@@ -1,17 +1,16 @@
-#include "nautilus-icon-view-item.h"
+#include "nautilus-container-max-width.h"
-struct _NautilusIconViewItem
+struct _NautilusContainerMaxWidth
{
GtkBin parent_instance;
guint max_width;
};
-G_DEFINE_TYPE (NautilusIconViewItem, nautilus_icon_view_item, GTK_TYPE_BIN)
+G_DEFINE_TYPE (NautilusContainerMaxWidth, nautilus_container_max_width, GTK_TYPE_BIN)
enum
{
PROP_0,
- PROP_FILE,
PROP_MAX_WIDTH,
N_PROPS
};
@@ -19,7 +18,7 @@ enum
static GParamSpec *properties [N_PROPS];
void
-nautilus_icon_view_item_set_max_width (NautilusIconViewItem *self,
+nautilus_container_max_width_set_max_width (NautilusContainerMaxWidth *self,
guint max_width)
{
self->max_width = max_width;
@@ -27,32 +26,32 @@ nautilus_icon_view_item_set_max_width (NautilusIconViewItem *self,
}
guint
-nautilus_icon_view_item_get_max_width (NautilusIconViewItem *self)
+nautilus_container_max_width_get_max_width (NautilusContainerMaxWidth *self)
{
return self->max_width;
}
-NautilusIconViewItem *
-nautilus_icon_view_item_new (void)
+NautilusContainerMaxWidth *
+nautilus_container_max_width_new (void)
{
- return g_object_new (NAUTILUS_TYPE_ICON_VIEW_ITEM, NULL);
+ return g_object_new (NAUTILUS_TYPE_CONTAINER_MAX_WIDTH, NULL);
}
static void
-nautilus_icon_view_item_finalize (GObject *object)
+nautilus_container_max_width_finalize (GObject *object)
{
- NautilusIconViewItem *self = (NautilusIconViewItem *) object;
+ NautilusContainerMaxWidth *self = (NautilusContainerMaxWidth *) object;
- G_OBJECT_CLASS (nautilus_icon_view_item_parent_class)->finalize (object);
+ G_OBJECT_CLASS (nautilus_container_max_width_parent_class)->finalize (object);
}
static void
-nautilus_icon_view_item_get_property (GObject *object,
+nautilus_container_max_width_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
- NautilusIconViewItem *self = NAUTILUS_ICON_VIEW_ITEM (object);
+ NautilusContainerMaxWidth *self = NAUTILUS_CONTAINER_MAX_WIDTH (object);
switch (prop_id)
{
@@ -70,18 +69,18 @@ nautilus_icon_view_item_get_property (GObject *object,
}
static void
-nautilus_icon_view_item_set_property (GObject *object,
+nautilus_container_max_width_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
- NautilusIconViewItem *self = NAUTILUS_ICON_VIEW_ITEM (object);
+ NautilusContainerMaxWidth *self = NAUTILUS_CONTAINER_MAX_WIDTH (object);
switch (prop_id)
{
case PROP_MAX_WIDTH:
{
- nautilus_icon_view_item_set_max_width (self, g_value_get_int (value));
+ nautilus_container_max_width_set_max_width (self, g_value_get_int (value));
}
break;
@@ -99,11 +98,11 @@ get_preferred_width (GtkWidget *widget,
gint *natural_size)
{
GtkWidget *child;
- NautilusIconViewItem *self;
+ NautilusContainerMaxWidth *self;
GtkStyleContext *style_context;
GtkBorder padding;
- self = NAUTILUS_ICON_VIEW_ITEM (widget);
+ self = NAUTILUS_CONTAINER_MAX_WIDTH (widget);
child = gtk_bin_get_child (GTK_BIN (self));
*natural_size = 0;
@@ -128,13 +127,13 @@ get_preferred_height (GtkWidget *widget,
gint *natural_size)
{
GtkWidget *child;
- NautilusIconViewItem *self;
+ NautilusContainerMaxWidth *self;
gint minimum_width = 0;
gint natural_width = 0;
GtkStyleContext *style_context;
GtkBorder padding;
- self = NAUTILUS_ICON_VIEW_ITEM (widget);
+ self = NAUTILUS_CONTAINER_MAX_WIDTH (widget);
child = gtk_bin_get_child (GTK_BIN (self));
get_preferred_width (widget, &minimum_width, &natural_width);
@@ -165,7 +164,7 @@ static void
size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
- GTK_WIDGET_CLASS (nautilus_icon_view_item_parent_class)->size_allocate (widget, allocation);
+ GTK_WIDGET_CLASS (nautilus_container_max_width_parent_class)->size_allocate (widget, allocation);
}
static void
@@ -175,15 +174,14 @@ get_preferred_width_for_height (GtkWidget *widget,
gint *natural_size)
{
get_preferred_width (widget, minimum_size, natural_size);
- g_print ("get preffered width for height %d\n", *natural_size);
}
static void
constructed (GObject *obj)
{
- NautilusIconViewItem *self = NAUTILUS_ICON_VIEW_ITEM (obj);
+ NautilusContainerMaxWidth *self = NAUTILUS_CONTAINER_MAX_WIDTH (obj);
- G_OBJECT_CLASS (nautilus_icon_view_item_parent_class)->constructed (obj);
+ G_OBJECT_CLASS (nautilus_container_max_width_parent_class)->constructed (obj);
/* We want our parent to gives our preferred width */
gtk_widget_set_halign (GTK_WIDGET (self), GTK_ALIGN_CENTER);
@@ -191,14 +189,14 @@ constructed (GObject *obj)
}
static void
-nautilus_icon_view_item_class_init (NautilusIconViewItemClass *klass)
+nautilus_container_max_width_class_init (NautilusContainerMaxWidthClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = nautilus_icon_view_item_finalize;
- object_class->get_property = nautilus_icon_view_item_get_property;
- object_class->set_property = nautilus_icon_view_item_set_property;
+ object_class->finalize = nautilus_container_max_width_finalize;
+ object_class->get_property = nautilus_container_max_width_get_property;
+ object_class->set_property = nautilus_container_max_width_set_property;
object_class->constructed = constructed;
widget_class->get_preferred_width = get_preferred_width;
@@ -209,6 +207,6 @@ nautilus_icon_view_item_class_init (NautilusIconViewItemClass *klass)
}
static void
-nautilus_icon_view_item_init (NautilusIconViewItem *self)
+nautilus_container_max_width_init (NautilusContainerMaxWidth *self)
{
}
diff --git a/src/nautilus-container-max-width.h b/src/nautilus-container-max-width.h
new file mode 100644
index 0000000..935721d
--- /dev/null
+++ b/src/nautilus-container-max-width.h
@@ -0,0 +1,22 @@
+#ifndef NAUTILUS_CONTAINER_MAX_WIDTH_H
+#define NAUTILUS_CONTAINER_MAX_WIDTH_H
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define NAUTILUS_TYPE_CONTAINER_MAX_WIDTH (nautilus_container_max_width_get_type())
+
+G_DECLARE_FINAL_TYPE (NautilusContainerMaxWidth, nautilus_container_max_width, NAUTILUS,
CONTAINER_MAX_WIDTH, GtkBin)
+
+NautilusContainerMaxWidth *nautilus_container_max_width_new (void);
+
+void nautilus_container_max_width_set_max_width (NautilusContainerMaxWidth *self,
+ guint max_width);
+guint nautilus_container_max_width_get_max_width (NautilusContainerMaxWidth *self);
+
+G_END_DECLS
+
+#endif /* NAUTILUS_CONTAINER_MAX_WIDTH_H */
+
diff --git a/src/nautilus-icon-view.c b/src/nautilus-icon-view.c
index ddee020..09d3aa8 100644
--- a/src/nautilus-icon-view.c
+++ b/src/nautilus-icon-view.c
@@ -24,12 +24,10 @@
#include "nautilus-directory.h"
#include "nautilus-global-preferences.h"
-#include "nautilus-icon-view-item.h"
+#include "nautilus-container-max-width.h"
#include <glib.h>
-static int n_files = 0;
-
typedef struct
{
GtkWidget *flow_box;
@@ -63,7 +61,6 @@ real_clear (NautilusFilesView *self)
NautilusIconViewPrivate *priv = nautilus_icon_view_get_instance_private (self);
g_list_store_remove_all (G_LIST_STORE (priv->model));
- n_files = 0;
}
@@ -263,8 +260,8 @@ replace_icon (NautilusIconView *self,
label = g_object_get_data (flow_box_item, "label");
icon_item = gtk_bin_get_child (GTK_BIN (flow_box_item));
- nautilus_icon_view_item_set_max_width (NAUTILUS_ICON_VIEW_ITEM (icon_item),
- get_icon_size_for_zoom_level (priv->zoom_level));
+ nautilus_container_max_width_set_max_width (NAUTILUS_CONTAINER_MAX_WIDTH (icon_item),
+ get_icon_size_for_zoom_level (priv->zoom_level));
box = gtk_bin_get_child (GTK_BIN (icon_item));
gtk_container_remove (GTK_CONTAINER (box), old_icon);
new_icon = create_icon (self, file);
@@ -476,7 +473,7 @@ create_widget_func (gpointer item,
NautilusIconViewPrivate *priv = nautilus_icon_view_get_instance_private (self);
GtkFlowBoxChild *child;
GtkBox *container;
- NautilusIconViewItem *icon_item;
+ NautilusContainerMaxWidth *item_container;
gint label_nat_size;
gint icon_nat_size;
GtkLabel *label;
@@ -484,7 +481,7 @@ create_widget_func (gpointer item,
GtkStyleContext *style_context;
container = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- icon_item = nautilus_icon_view_item_new ();
+ item_container = nautilus_container_max_width_new ();
icon = create_icon (self, file);
gtk_box_pack_start (container, icon, FALSE, FALSE, 0);
@@ -505,12 +502,12 @@ create_widget_func (gpointer item,
gtk_widget_set_valign (container, GTK_ALIGN_START);
gtk_widget_set_halign (container, GTK_ALIGN_CENTER);
- gtk_container_add (icon_item, container);
- nautilus_icon_view_item_set_max_width (NAUTILUS_ICON_VIEW_ITEM (icon_item),
+ gtk_container_add (item_container, container);
+ nautilus_icon_view_item_set_max_width (NAUTILUS_ICON_VIEW_ITEM (item_container),
get_icon_size_for_zoom_level (priv->zoom_level));
child = gtk_flow_box_child_new ();
- gtk_container_add (child, icon_item);
+ gtk_container_add (child, item_container);
g_object_set_data (child, "file", file);
g_object_set_data (child, "icon", icon);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]