[gtk+/wip/csoriano/pathbar-bin-view-window] using gtkpathbarbox
- From: Carlos Soriano Sánchez <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/csoriano/pathbar-bin-view-window] using gtkpathbarbox
- Date: Fri, 24 Jun 2016 13:20:33 +0000 (UTC)
commit 6b2ad24fceca2a005b1cfb9253d7e0b1050dd461
Author: Carlos Soriano <csoriano gnome org>
Date: Fri Jun 24 15:19:56 2016 +0200
using gtkpathbarbox
gtk/gtkpathbar.c | 19 +++++++++++++++
gtk/gtkpathbarbox.c | 14 ++++++++---
gtk/gtkpathbarcontainer.c | 24 ++++++++-----------
gtk/ui/gtkpathbar.ui | 51 +-----------------------------------------
tests/testpathbarcontainer.c | 15 ++++++++++--
5 files changed, 52 insertions(+), 71 deletions(-)
---
diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c
index ec58bfb..8742b7a 100644
--- a/gtk/gtkpathbar.c
+++ b/gtk/gtkpathbar.c
@@ -571,6 +571,16 @@ update_selected_path (GtkPathBar *self)
}
static void
+on_overflow_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ GtkPathBar *self = GTK_PATH_BAR (user_data);
+
+ gtk_path_bar_set_inverted (self, !gtk_path_bar_get_inverted (self));
+
+}
+
+static void
gtk_path_bar_finalize (GObject *object)
{
GtkPathBar *self = (GtkPathBar *)object;
@@ -729,6 +739,15 @@ gtk_path_bar_init (GtkPathBar *self)
g_type_ensure (GTK_TYPE_PATH_BAR_CONTAINER);
gtk_widget_init_template (GTK_WIDGET (self));
+ g_signal_connect (priv->path_bar_overflow_root_1, "clicked",
+ (GCallback) on_overflow_clicked, self);
+ g_signal_connect (priv->path_bar_overflow_root_2, "clicked",
+ (GCallback) on_overflow_clicked, self);
+ g_signal_connect (priv->path_bar_overflow_tail_1, "clicked",
+ (GCallback) on_overflow_clicked, self);
+ g_signal_connect (priv->path_bar_overflow_tail_2, "clicked",
+ (GCallback) on_overflow_clicked, self);
+
priv->inverted = FALSE;
}
diff --git a/gtk/gtkpathbarbox.c b/gtk/gtkpathbarbox.c
index 324931a..fb0d745 100644
--- a/gtk/gtkpathbarbox.c
+++ b/gtk/gtkpathbarbox.c
@@ -68,6 +68,7 @@ gtk_path_bar_box_add (GtkContainer *container,
GtkPathBarBoxPrivate *priv = gtk_path_bar_box_get_instance_private (self);
priv->children = g_list_append (priv->children, widget);
+ gtk_widget_set_parent (widget, GTK_WIDGET (self));
gtk_widget_queue_resize (GTK_WIDGET (self));
}
@@ -80,6 +81,7 @@ gtk_path_bar_box_remove (GtkContainer *container,
GtkPathBarBoxPrivate *priv = gtk_path_bar_box_get_instance_private (self);
priv->children = g_list_remove (priv->children, widget);
+ gtk_widget_unparent (widget);
gtk_widget_queue_resize (GTK_WIDGET (self));
}
@@ -137,14 +139,14 @@ gtk_path_bar_box_size_allocate (GtkWidget *widget,
sizes[i].data = child->data;
available_size -= sizes[i].minimum_size;
n_visible_children++;
+ if (GTK_IS_PATH_BAR_CONTAINER (child->data))
+ g_print ("child sizing pathbar %d %d\n", sizes[i].minimum_size, sizes[i].natural_size);
+
}
- g_print ("child sizing pathbar %d %d\n", sizes[2].minimum_size, sizes[2].natural_size);
gtk_distribute_natural_allocation (MAX (0, available_size),
n_visible_children, sizes);
- g_print ("child sizing pathbar %d %d\n", sizes[2].minimum_size, sizes[2].natural_size);
-
for (child = children, i = 0; child != NULL; child = g_list_next (child), i++)
{
if (!gtk_widget_get_visible (child->data))
@@ -153,7 +155,9 @@ gtk_path_bar_box_size_allocate (GtkWidget *widget,
child_available_size.width = sizes[i].minimum_size;
child_available_size.height = allocation->height;
- g_print ("child sizing 1 %d %d\n", child_available_size.width, sizes[i].minimum_size);
+ if (GTK_IS_PATH_BAR_CONTAINER (child->data))
+ g_print ("child sizing pathbar 1 %d %d %d\n", sizes[i].minimum_size, sizes[i].natural_size,
child_available_size.width);
+
if (GTK_IS_PATH_BAR_CONTAINER (child->data))
{
gtk_path_bar_container_adapt_to_size (GTK_PATH_BAR_CONTAINER (child->data),
@@ -163,6 +167,7 @@ gtk_path_bar_box_size_allocate (GtkWidget *widget,
&minimum_size,
&natural_size);
+ g_print ("what %d %d\n", child_available_size.width, sizes[i].minimum_size);
sizes[i].minimum_size = MIN (child_available_size.width, natural_size.width);
}
g_print ("child sizing after %d %d\n", child_available_size.width, sizes[i].minimum_size);
@@ -242,6 +247,7 @@ static void
gtk_path_bar_box_init (GtkPathBarBox *self)
{
gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);
+ gtk_widget_set_redraw_on_allocate (GTK_WIDGET (self), TRUE);
}
static void
diff --git a/gtk/gtkpathbarcontainer.c b/gtk/gtkpathbarcontainer.c
index 0de53df..1249838 100644
--- a/gtk/gtkpathbarcontainer.c
+++ b/gtk/gtkpathbarcontainer.c
@@ -129,9 +129,13 @@ gtk_path_bar_container_add (GtkPathBarContainer *self,
gtk_container_add (GTK_CONTAINER (revealer), widget);
gtk_container_add (GTK_CONTAINER (priv->children_box), revealer);
gtk_revealer_set_transition_duration (GTK_REVEALER (revealer),
- REVEALER_ANIMATION_TIME);
+ REVEALER_ANIMATION_TIME);
priv->children = g_list_append (priv->children, widget);
gtk_widget_show_all (revealer);
+
+ gtk_revealer_set_reveal_child (GTK_REVEALER (revealer), TRUE);
+
+ gtk_widget_queue_allocate (GTK_WIDGET (self));
}
static void
@@ -243,8 +247,8 @@ get_children_preferred_size_for_requisition (GtkPathBarContainer *self,
/* If we are in the middle of a revealer animation, get the revealer
* allocation */
- current_child_min_width = revealer_width.minimum_size;
- current_child_nat_width = revealer_width.natural_size;
+ current_child_min_width = revealer_width.minimum_size;
+ current_child_nat_width = revealer_width.natural_size;
current_children_min_height = MAX (current_children_min_height, child_height.minimum_size);
current_children_nat_height = MAX (current_children_nat_height, child_height.natural_size);
@@ -252,24 +256,16 @@ get_children_preferred_size_for_requisition (GtkPathBarContainer *self,
current_children_nat_width += current_child_nat_width;
full_children_current_width += current_child_min_width;
- g_print ("children container i: %d reversed: %i current width %d available %d\n", i, inverted,
child_width.natural_size, available_size->width);
- if (!gtk_revealer_get_reveal_child (revealer))
- {
- break;
- }
+ g_print ("children container i: %d reversed: %i current width %d available %d\n", i, inverted,
current_child_nat_width, available_size->width);
+ if (!gtk_revealer_get_reveal_child (GTK_REVEALER (revealer)))
+ break;
}
- if (minimum_size)
- {
minimum_size->width = current_children_min_width;
minimum_size->height = current_children_min_height;
- }
- if (natural_size)
- {
natural_size->width = current_children_nat_width;
natural_size->height = current_children_nat_height;
- }
g_list_free (children);
diff --git a/gtk/ui/gtkpathbar.ui b/gtk/ui/gtkpathbar.ui
index 679e772..18f10e7 100644
--- a/gtk/ui/gtkpathbar.ui
+++ b/gtk/ui/gtkpathbar.ui
@@ -4,6 +4,7 @@
<template class="GtkPathBar" parent="GtkStack">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="hexpand">True</property>
<child>
<object class="GtkPathBarBox" id="path_bar_1">
<property name="visible">True</property>
@@ -18,11 +19,6 @@
<class name="flat"/>
</style>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
<child>
<object class="GtkButton" id="path_bar_overflow_root_1">
@@ -35,22 +31,12 @@
<class name="overflow"/>
</style>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
</child>
<child>
<object class="GtkPathBarContainer" id="path_bar_container_1">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
</child>
<child>
<object class="GtkButton" id="path_bar_overflow_tail_1">
@@ -63,11 +49,6 @@
<class name="overflow"/>
</style>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
</child>
<child>
<object class="GtkButton" id="path_bar_tail_1">
@@ -79,11 +60,6 @@
<class name="flat"/>
</style>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">4</property>
- </packing>
</child>
</object>
<packing>
@@ -104,11 +80,6 @@
<class name="flat"/>
</style>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
<child>
<object class="GtkButton" id="path_bar_overflow_root_2">
@@ -121,22 +92,12 @@
<class name="overflow"/>
</style>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
</child>
<child>
<object class="GtkPathBarContainer" id="path_bar_container_2">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
</child>
<child>
<object class="GtkButton" id="path_bar_overflow_tail_2">
@@ -149,11 +110,6 @@
<class name="overflow"/>
</style>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
</child>
<child>
<object class="GtkButton" id="path_bar_tail_2">
@@ -165,11 +121,6 @@
<class name="flat"/>
</style>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">4</property>
- </packing>
</child>
</object>
<packing>
diff --git a/tests/testpathbarcontainer.c b/tests/testpathbarcontainer.c
index caf9733..35cb9d7 100644
--- a/tests/testpathbarcontainer.c
+++ b/tests/testpathbarcontainer.c
@@ -1,10 +1,16 @@
#include "config.h"
#include "glib.h"
#include <gtk/gtk.h>
+#define GTK_COMPILATION
+#include <gtk/gtkpathbarcontainer.h>
+#include <gtk/gtkpathbarcontainer.c>
+#include <gtk/gtkpathbarboxprivate.h>
+#include <gtk/gtkpathbarbox.c>
#define N_BUTTONS 10
static GtkWidget *path_bar_container;
+static GtkWidget *path_bar_box;
static char *lorem_ipsum = "Loremipsumdolorsitamet, consecteturadipisicingelit,";
static char*
@@ -104,20 +110,23 @@ main (int argc, char *argv[])
grid = gtk_grid_new ();
g_type_ensure (GTK_TYPE_PATH_BAR_CONTAINER);
+ g_type_ensure (GTK_TYPE_PATH_BAR_BOX);
label = gtk_label_new ("Generic GtkPathBar tests");
gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 2, 1);
/* ----------------------------------------------------------------------- */
path_bar_container = gtk_path_bar_container_new ();
- gtk_grid_attach (GTK_GRID (grid), path_bar_container, 0, 1, 1, 1);
- gtk_widget_show_all (path_bar_container);
+ path_bar_box = gtk_path_bar_box_new ();
+ gtk_container_add (GTK_CONTAINER (path_bar_box), path_bar_container);
+ gtk_grid_attach (GTK_GRID (grid), path_bar_box, 0, 1, 1, 1);
+ gtk_widget_show_all (path_bar_box);
/* Add/Remove buttons */
add_button = gtk_button_new_with_label ("Add");
gtk_widget_set_halign (add_button, GTK_ALIGN_END);
remove_button = gtk_button_new_with_label ("Remove");
gtk_widget_set_halign (remove_button, GTK_ALIGN_END);
- gtk_grid_attach_next_to (GTK_GRID (grid), add_button, path_bar_container, GTK_POS_RIGHT, 1, 1);
+ gtk_grid_attach_next_to (GTK_GRID (grid), add_button, path_bar_box, GTK_POS_RIGHT, 1, 1);
g_signal_connect_swapped (add_button, "clicked", (GCallback) on_add_button, GINT_TO_POINTER (0));
gtk_grid_attach_next_to (GTK_GRID (grid), remove_button, add_button, GTK_POS_RIGHT, 1, 1);
g_signal_connect_swapped (remove_button, "clicked", (GCallback) on_remove_button, GINT_TO_POINTER (0));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]