mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
conditional compile for GtkPathBar
Fri Feb 20 18:20:22 2004 Jonathan Blandford <jrb@gnome.org> * gtk/gtkfilechooserdefault.c: conditional compile for GtkPathBar * gtk/gtkpathbar.c (gtk_path_bar_size_allocate): Clean up allocation code. Works fully in RTL languages, I think. (gtk_path_bar_scroll_up): Scroll up. (gtk_path_bar_scroll_down): Scroll down.
This commit is contained in:
parent
0f21069915
commit
b379bc580e
@ -1,3 +1,12 @@
|
||||
Fri Feb 20 18:20:22 2004 Jonathan Blandford <jrb@gnome.org>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c: conditional compile for GtkPathBar
|
||||
|
||||
* gtk/gtkpathbar.c (gtk_path_bar_size_allocate): Clean up
|
||||
allocation code. Works fully in RTL languages, I think.
|
||||
(gtk_path_bar_scroll_up): Scroll up.
|
||||
(gtk_path_bar_scroll_down): Scroll down.
|
||||
|
||||
2004-02-20 Christian Rose <menthos@menthos.com>
|
||||
|
||||
* configure.in: Added "en_CA" to ALL_LINGUAS.
|
||||
|
@ -1,3 +1,12 @@
|
||||
Fri Feb 20 18:20:22 2004 Jonathan Blandford <jrb@gnome.org>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c: conditional compile for GtkPathBar
|
||||
|
||||
* gtk/gtkpathbar.c (gtk_path_bar_size_allocate): Clean up
|
||||
allocation code. Works fully in RTL languages, I think.
|
||||
(gtk_path_bar_scroll_up): Scroll up.
|
||||
(gtk_path_bar_scroll_down): Scroll down.
|
||||
|
||||
2004-02-20 Christian Rose <menthos@menthos.com>
|
||||
|
||||
* configure.in: Added "en_CA" to ALL_LINGUAS.
|
||||
|
@ -1,3 +1,12 @@
|
||||
Fri Feb 20 18:20:22 2004 Jonathan Blandford <jrb@gnome.org>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c: conditional compile for GtkPathBar
|
||||
|
||||
* gtk/gtkpathbar.c (gtk_path_bar_size_allocate): Clean up
|
||||
allocation code. Works fully in RTL languages, I think.
|
||||
(gtk_path_bar_scroll_up): Scroll up.
|
||||
(gtk_path_bar_scroll_down): Scroll down.
|
||||
|
||||
2004-02-20 Christian Rose <menthos@menthos.com>
|
||||
|
||||
* configure.in: Added "en_CA" to ALL_LINGUAS.
|
||||
|
@ -1,3 +1,12 @@
|
||||
Fri Feb 20 18:20:22 2004 Jonathan Blandford <jrb@gnome.org>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c: conditional compile for GtkPathBar
|
||||
|
||||
* gtk/gtkpathbar.c (gtk_path_bar_size_allocate): Clean up
|
||||
allocation code. Works fully in RTL languages, I think.
|
||||
(gtk_path_bar_scroll_up): Scroll up.
|
||||
(gtk_path_bar_scroll_down): Scroll down.
|
||||
|
||||
2004-02-20 Christian Rose <menthos@menthos.com>
|
||||
|
||||
* configure.in: Added "en_CA" to ALL_LINGUAS.
|
||||
|
@ -1,3 +1,12 @@
|
||||
Fri Feb 20 18:20:22 2004 Jonathan Blandford <jrb@gnome.org>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c: conditional compile for GtkPathBar
|
||||
|
||||
* gtk/gtkpathbar.c (gtk_path_bar_size_allocate): Clean up
|
||||
allocation code. Works fully in RTL languages, I think.
|
||||
(gtk_path_bar_scroll_up): Scroll up.
|
||||
(gtk_path_bar_scroll_down): Scroll down.
|
||||
|
||||
2004-02-20 Christian Rose <menthos@menthos.com>
|
||||
|
||||
* configure.in: Added "en_CA" to ALL_LINGUAS.
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "gtklabel.h"
|
||||
#include "gtkmenuitem.h"
|
||||
#include "gtkmessagedialog.h"
|
||||
#include "gtkpathbar.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkscrolledwindow.h"
|
||||
#include "gtksizegroup.h"
|
||||
@ -119,6 +120,7 @@ struct _GtkFileChooserDefault
|
||||
GtkWidget *entry;
|
||||
GtkWidget *preview_widget;
|
||||
GtkWidget *extra_widget;
|
||||
GtkWidget *path_bar;
|
||||
|
||||
GtkTreeViewColumn *list_name_column;
|
||||
GtkCellRenderer *list_name_renderer;
|
||||
@ -1556,7 +1558,13 @@ file_pane_create (GtkFileChooserDefault *impl)
|
||||
/* Current folder indicator */
|
||||
|
||||
widget = current_folder_create (impl);
|
||||
impl->path_bar = g_object_new (gtk_path_bar_get_type (), NULL);
|
||||
gtk_widget_show_all (impl->path_bar);
|
||||
#ifdef USE_PATH_BAR
|
||||
gtk_box_pack_start (GTK_BOX (vbox), impl->path_bar, FALSE, FALSE, 0);
|
||||
#else
|
||||
gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
|
||||
#endif
|
||||
|
||||
/* Box for lists and preview */
|
||||
|
||||
@ -2215,6 +2223,9 @@ gtk_file_chooser_default_set_current_folder (GtkFileChooser *chooser,
|
||||
|
||||
str = g_strdup_printf (_("Current folder: %s"), gtk_file_path_get_string (path));
|
||||
gtk_label_set_text (GTK_LABEL (impl->folder_label), str);
|
||||
#ifdef USE_PATH_BAR
|
||||
gtk_path_bar_set_path (GTK_PATH_BAR (impl->path_bar), gtk_file_path_get_string (path));
|
||||
#endif
|
||||
g_free (str);
|
||||
|
||||
/* Update the folder tree */
|
||||
|
@ -41,6 +41,8 @@ static void gtk_path_bar_forall (GtkContainer *container,
|
||||
gboolean include_internals,
|
||||
GtkCallback callback,
|
||||
gpointer callback_data);
|
||||
static void gtk_path_bar_scroll_up (GtkWidget *button, GtkPathBar *path_bar);
|
||||
static void gtk_path_bar_scroll_down (GtkWidget *button, GtkPathBar *path_bar);
|
||||
|
||||
static GtkWidget *
|
||||
get_slider_button (GtkPathBar *path_bar)
|
||||
@ -64,6 +66,9 @@ gtk_path_bar_init (GtkPathBar *path_bar)
|
||||
path_bar->spacing = 3;
|
||||
path_bar->up_slider_button = get_slider_button (path_bar);
|
||||
path_bar->down_slider_button = get_slider_button (path_bar);
|
||||
|
||||
g_signal_connect (path_bar->up_slider_button, "clicked", G_CALLBACK (gtk_path_bar_scroll_up), path_bar);
|
||||
g_signal_connect (path_bar->down_slider_button, "clicked", G_CALLBACK (gtk_path_bar_scroll_down), path_bar);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -88,7 +93,8 @@ gtk_path_bar_class_init (GtkPathBarClass *path_bar_class)
|
||||
container_class->add = gtk_path_bar_add;
|
||||
container_class->forall = gtk_path_bar_forall;
|
||||
container_class->remove = gtk_path_bar_remove;
|
||||
// container_class->child_type = gtk_path_bar_child_type;
|
||||
/* FIXME: */
|
||||
/* container_class->child_type = gtk_path_bar_child_type;*/
|
||||
}
|
||||
|
||||
|
||||
@ -236,9 +242,10 @@ gtk_path_bar_size_allocate (GtkWidget *widget,
|
||||
gboolean reached_end = FALSE;
|
||||
gint slider_space = 2 * (path_bar->spacing + path_bar->slider_width);
|
||||
|
||||
/* FIXME: first_button will be something else if we've scrolled
|
||||
*/
|
||||
first_button = path_bar->button_list;
|
||||
if (path_bar->first_scrolled_button)
|
||||
first_button = path_bar->first_scrolled_button;
|
||||
else
|
||||
first_button = path_bar->button_list;
|
||||
need_sliders = TRUE;
|
||||
|
||||
/* To see how much space we have, and how many buttons we can display.
|
||||
@ -301,30 +308,27 @@ gtk_path_bar_size_allocate (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (list = first_button; list; list = list->prev)
|
||||
{
|
||||
child = GTK_WIDGET (list->data);
|
||||
|
||||
child_allocation.width = child->requisition.width;
|
||||
if (direction == GTK_TEXT_DIR_RTL)
|
||||
child_allocation.x -= child_allocation.width;
|
||||
|
||||
/* Check to see if we've don't have any more space to allocate buttons */
|
||||
if (need_sliders && direction == GTK_TEXT_DIR_RTL)
|
||||
{
|
||||
if (child_allocation.x - child_allocation.width - 2 * path_bar->spacing - path_bar->spacing <
|
||||
widget->allocation.x + border_width)
|
||||
if (child_allocation.x - path_bar->spacing - path_bar->slider_width < widget->allocation.x + border_width)
|
||||
break;
|
||||
}
|
||||
else if (need_sliders && direction == GTK_TEXT_DIR_LTR)
|
||||
{
|
||||
if (child_allocation.x + child_allocation.width + 2 * path_bar->spacing + path_bar->spacing >
|
||||
if (child_allocation.x + child_allocation.width + path_bar->spacing + path_bar->slider_width >
|
||||
widget->allocation.x + border_width + allocation_width)
|
||||
break;
|
||||
}
|
||||
|
||||
if (direction == GTK_TEXT_DIR_RTL)
|
||||
child_allocation.x -= child_allocation.width;
|
||||
|
||||
gtk_widget_set_child_visible (list->data, TRUE);
|
||||
gtk_widget_size_allocate (child, &child_allocation);
|
||||
|
||||
@ -447,6 +451,75 @@ gtk_path_bar_forall (GtkContainer *container,
|
||||
(* callback) (path_bar->down_slider_button, callback_data);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_bar_scroll_down (GtkWidget *button, GtkPathBar *path_bar)
|
||||
{
|
||||
GList *list;
|
||||
GList *down_button, *up_button;
|
||||
gint space_available;
|
||||
gint space_needed;
|
||||
gint border_width;
|
||||
GtkTextDirection direction;
|
||||
|
||||
border_width = GTK_CONTAINER (path_bar)->border_width;
|
||||
direction = gtk_widget_get_direction (GTK_WIDGET (path_bar));
|
||||
|
||||
/* We find the button at the 'down' end that we have to make
|
||||
* visible */
|
||||
for (list = path_bar->button_list; list; list = list->next)
|
||||
{
|
||||
if (list->next && gtk_widget_get_child_visible (GTK_WIDGET (list->next->data)))
|
||||
{
|
||||
down_button = list;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Find the last visible button on the 'up' end
|
||||
*/
|
||||
for (list = g_list_last (path_bar->button_list); list; list = list->prev)
|
||||
{
|
||||
if (gtk_widget_get_child_visible (GTK_WIDGET (list->data)))
|
||||
{
|
||||
up_button = list;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
space_needed = GTK_WIDGET (down_button->data)->allocation.width + path_bar->spacing;
|
||||
if (direction == GTK_TEXT_DIR_RTL)
|
||||
space_available = GTK_WIDGET (path_bar)->allocation.x + GTK_WIDGET (path_bar)->allocation.width;
|
||||
else
|
||||
space_available = (GTK_WIDGET (path_bar)->allocation.x + GTK_WIDGET (path_bar)->allocation.width - border_width) -
|
||||
(path_bar->down_slider_button->allocation.x + path_bar->down_slider_button->allocation.width);
|
||||
|
||||
/* We have space_available extra space that's not being used. We
|
||||
* need space_needed space to make the button fit. So we walk down
|
||||
* from the end, removing buttons until we get all the space we
|
||||
* need. */
|
||||
while (space_available < space_needed)
|
||||
{
|
||||
space_available += GTK_WIDGET (up_button->data)->allocation.width + path_bar->spacing;
|
||||
up_button = up_button->prev;
|
||||
path_bar->first_scrolled_button = up_button;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_bar_scroll_up (GtkWidget *button, GtkPathBar *path_bar)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
for (list = g_list_last (path_bar->button_list); list; list = list->prev)
|
||||
{
|
||||
if (list->prev && gtk_widget_get_child_visible (GTK_WIDGET (list->prev->data)))
|
||||
{
|
||||
path_bar->first_scrolled_button = list;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Public functions. */
|
||||
@ -526,12 +599,13 @@ gtk_path_bar_set_path (GtkPathBar *path_bar,
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label), label_str);
|
||||
gtk_container_add (GTK_CONTAINER (button), label);
|
||||
// gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
|
||||
button_list = g_list_prepend (button_list, button);
|
||||
gtk_container_add (GTK_CONTAINER (path_bar), button);
|
||||
gtk_widget_show_all (button);
|
||||
}
|
||||
|
||||
path_bar->button_list = g_list_reverse (button_list);
|
||||
gtk_widget_queue_resize (GTK_WIDGET (path_bar));
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,6 +41,7 @@ struct _GtkPathBar
|
||||
|
||||
const char *path;
|
||||
GList *button_list;
|
||||
GList *first_scrolled_button;
|
||||
gint16 slider_width;
|
||||
gint16 spacing;
|
||||
gint16 button_offset;
|
||||
|
Loading…
Reference in New Issue
Block a user