[nautilus] pathbar: use a private struct
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] pathbar: use a private struct
- Date: Sun, 29 Apr 2012 21:44:35 +0000 (UTC)
commit 74f748e6b2cf43fd8e90bb073c78df159a6a424d
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Thu Apr 26 16:33:41 2012 -0400
pathbar: use a private struct
src/nautilus-pathbar.c | 404 ++++++++++++++++++++++++++----------------------
src/nautilus-pathbar.h | 31 +----
2 files changed, 220 insertions(+), 215 deletions(-)
---
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
index 019e1ed..c545c98 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -63,10 +63,7 @@ static guint path_bar_signals [LAST_SIGNAL] = { 0 };
#define NAUTILUS_PATH_BAR_ICON_SIZE 16
-typedef struct _ButtonData ButtonData;
-
-struct _ButtonData
-{
+typedef struct {
GtkWidget *button;
ButtonType type;
char *dir_name;
@@ -85,8 +82,38 @@ struct _ButtonData
GtkWidget *alignment;
guint ignore_changes : 1;
guint fake_root : 1;
+} ButtonData;
+
+struct _NautilusPathBarDetails {
+ GdkWindow *event_window;
+
+ GFile *root_path;
+ GFile *home_path;
+ GFile *desktop_path;
+
+ GFile *current_path;
+ gpointer current_button_data;
+
+ GList *button_list;
+ GList *first_scrolled_button;
+ GList *fake_root;
+ GtkWidget *up_slider_button;
+ GtkWidget *down_slider_button;
+ guint settings_signal_id;
+ gint icon_size;
+ gint16 slider_width;
+ gint16 spacing;
+ gint16 button_offset;
+ guint timer;
+ guint slider_visible : 1;
+ guint need_timer : 1;
+ guint ignore_click : 1;
+
+ unsigned int drag_slider_timeout;
+ gboolean drag_slider_timeout_for_up_button;
};
+
G_DEFINE_TYPE (NautilusPathBar, nautilus_path_bar,
GTK_TYPE_CONTAINER);
@@ -136,7 +163,7 @@ trash_state_changed_cb (NautilusTrashMonitor *monitor,
GList *list;
file = g_file_new_for_uri ("trash:///");
- for (list = path_bar->button_list; list; list = list->next) {
+ for (list = path_bar->priv->button_list; list; list = list->next) {
ButtonData *button_data;
button_data = BUTTON_DATA (list->data);
if (g_file_equal (file, button_data->path)) {
@@ -160,10 +187,10 @@ slider_timeout (gpointer user_data)
path_bar = NAUTILUS_PATH_BAR (user_data);
- path_bar->drag_slider_timeout = 0;
+ path_bar->priv->drag_slider_timeout = 0;
if (gtk_widget_get_visible (GTK_WIDGET (path_bar))) {
- if (path_bar->drag_slider_timeout_for_up_button) {
+ if (path_bar->priv->drag_slider_timeout_for_up_button) {
nautilus_path_bar_scroll_up (path_bar);
} else {
nautilus_path_bar_scroll_down (path_bar);
@@ -187,17 +214,17 @@ nautilus_path_bar_slider_drag_motion (GtkWidget *widget,
path_bar = NAUTILUS_PATH_BAR (user_data);
- if (path_bar->drag_slider_timeout == 0) {
+ if (path_bar->priv->drag_slider_timeout == 0) {
settings = gtk_widget_get_settings (widget);
g_object_get (settings, "gtk-timeout-expand", &timeout, NULL);
- path_bar->drag_slider_timeout =
+ path_bar->priv->drag_slider_timeout =
g_timeout_add (timeout,
slider_timeout,
path_bar);
- path_bar->drag_slider_timeout_for_up_button =
- widget == path_bar->up_slider_button;
+ path_bar->priv->drag_slider_timeout_for_up_button =
+ widget == path_bar->priv->up_slider_button;
}
}
@@ -211,9 +238,9 @@ nautilus_path_bar_slider_drag_leave (GtkWidget *widget,
path_bar = NAUTILUS_PATH_BAR (user_data);
- if (path_bar->drag_slider_timeout != 0) {
- g_source_remove (path_bar->drag_slider_timeout);
- path_bar->drag_slider_timeout = 0;
+ if (path_bar->priv->drag_slider_timeout != 0) {
+ g_source_remove (path_bar->priv->drag_slider_timeout);
+ path_bar->priv->drag_slider_timeout = 0;
}
}
@@ -222,48 +249,50 @@ nautilus_path_bar_init (NautilusPathBar *path_bar)
{
char *p;
+ path_bar->priv = G_TYPE_INSTANCE_GET_PRIVATE (path_bar, NAUTILUS_TYPE_PATH_BAR, NautilusPathBarDetails);
+
gtk_widget_set_has_window (GTK_WIDGET (path_bar), FALSE);
gtk_widget_set_redraw_on_allocate (GTK_WIDGET (path_bar), FALSE);
- path_bar->spacing = 3;
- path_bar->up_slider_button = get_slider_button (path_bar, GTK_ARROW_LEFT);
- path_bar->down_slider_button = get_slider_button (path_bar, GTK_ARROW_RIGHT);
- path_bar->icon_size = NAUTILUS_PATH_BAR_ICON_SIZE;
+ path_bar->priv->spacing = 3;
+ path_bar->priv->up_slider_button = get_slider_button (path_bar, GTK_ARROW_LEFT);
+ path_bar->priv->down_slider_button = get_slider_button (path_bar, GTK_ARROW_RIGHT);
+ path_bar->priv->icon_size = NAUTILUS_PATH_BAR_ICON_SIZE;
p = nautilus_get_desktop_directory ();
- path_bar->desktop_path = g_file_new_for_path (p);
+ path_bar->priv->desktop_path = g_file_new_for_path (p);
g_free (p);
- path_bar->home_path = g_file_new_for_path (g_get_home_dir ());
- path_bar->root_path = g_file_new_for_path ("/");
+ path_bar->priv->home_path = g_file_new_for_path (g_get_home_dir ());
+ path_bar->priv->root_path = g_file_new_for_path ("/");
- g_signal_connect_swapped (path_bar->up_slider_button, "clicked", G_CALLBACK (nautilus_path_bar_scroll_up), path_bar);
- g_signal_connect_swapped (path_bar->down_slider_button, "clicked", G_CALLBACK (nautilus_path_bar_scroll_down), path_bar);
+ g_signal_connect_swapped (path_bar->priv->up_slider_button, "clicked", G_CALLBACK (nautilus_path_bar_scroll_up), path_bar);
+ g_signal_connect_swapped (path_bar->priv->down_slider_button, "clicked", G_CALLBACK (nautilus_path_bar_scroll_down), path_bar);
- g_signal_connect (path_bar->up_slider_button, "button_press_event", G_CALLBACK (nautilus_path_bar_slider_button_press), path_bar);
- g_signal_connect (path_bar->up_slider_button, "button_release_event", G_CALLBACK (nautilus_path_bar_slider_button_release), path_bar);
- g_signal_connect (path_bar->down_slider_button, "button_press_event", G_CALLBACK (nautilus_path_bar_slider_button_press), path_bar);
- g_signal_connect (path_bar->down_slider_button, "button_release_event", G_CALLBACK (nautilus_path_bar_slider_button_release), path_bar);
+ g_signal_connect (path_bar->priv->up_slider_button, "button_press_event", G_CALLBACK (nautilus_path_bar_slider_button_press), path_bar);
+ g_signal_connect (path_bar->priv->up_slider_button, "button_release_event", G_CALLBACK (nautilus_path_bar_slider_button_release), path_bar);
+ g_signal_connect (path_bar->priv->down_slider_button, "button_press_event", G_CALLBACK (nautilus_path_bar_slider_button_press), path_bar);
+ g_signal_connect (path_bar->priv->down_slider_button, "button_release_event", G_CALLBACK (nautilus_path_bar_slider_button_release), path_bar);
- gtk_drag_dest_set (GTK_WIDGET (path_bar->up_slider_button),
+ gtk_drag_dest_set (GTK_WIDGET (path_bar->priv->up_slider_button),
0, NULL, 0, 0);
- gtk_drag_dest_set_track_motion (GTK_WIDGET (path_bar->up_slider_button), TRUE);
- g_signal_connect (path_bar->up_slider_button,
+ gtk_drag_dest_set_track_motion (GTK_WIDGET (path_bar->priv->up_slider_button), TRUE);
+ g_signal_connect (path_bar->priv->up_slider_button,
"drag-motion",
G_CALLBACK (nautilus_path_bar_slider_drag_motion),
path_bar);
- g_signal_connect (path_bar->up_slider_button,
+ g_signal_connect (path_bar->priv->up_slider_button,
"drag-leave",
G_CALLBACK (nautilus_path_bar_slider_drag_leave),
path_bar);
- gtk_drag_dest_set (GTK_WIDGET (path_bar->down_slider_button),
+ gtk_drag_dest_set (GTK_WIDGET (path_bar->priv->down_slider_button),
0, NULL, 0, 0);
- gtk_drag_dest_set_track_motion (GTK_WIDGET (path_bar->up_slider_button), TRUE);
- g_signal_connect (path_bar->down_slider_button,
+ gtk_drag_dest_set_track_motion (GTK_WIDGET (path_bar->priv->up_slider_button), TRUE);
+ g_signal_connect (path_bar->priv->down_slider_button,
"drag-motion",
G_CALLBACK (nautilus_path_bar_slider_drag_motion),
path_bar);
- g_signal_connect (path_bar->down_slider_button,
+ g_signal_connect (path_bar->priv->down_slider_button,
"drag-leave",
G_CALLBACK (nautilus_path_bar_slider_drag_leave),
path_bar);
@@ -283,15 +312,15 @@ nautilus_path_bar_finalize (GObject *object)
nautilus_path_bar_stop_scrolling (path_bar);
- if (path_bar->drag_slider_timeout != 0) {
- g_source_remove (path_bar->drag_slider_timeout);
- path_bar->drag_slider_timeout = 0;
+ if (path_bar->priv->drag_slider_timeout != 0) {
+ g_source_remove (path_bar->priv->drag_slider_timeout);
+ path_bar->priv->drag_slider_timeout = 0;
}
- g_list_free (path_bar->button_list);
- g_clear_object (&path_bar->root_path);
- g_clear_object (&path_bar->home_path);
- g_clear_object (&path_bar->desktop_path);
+ g_list_free (path_bar->priv->button_list);
+ g_clear_object (&path_bar->priv->root_path);
+ g_clear_object (&path_bar->priv->home_path);
+ g_clear_object (&path_bar->priv->desktop_path);
g_signal_handlers_disconnect_by_func (nautilus_trash_monitor_get (),
trash_state_changed_cb, path_bar);
@@ -304,13 +333,13 @@ static void
remove_settings_signal (NautilusPathBar *path_bar,
GdkScreen *screen)
{
- if (path_bar->settings_signal_id) {
+ if (path_bar->priv->settings_signal_id) {
GtkSettings *settings;
settings = gtk_settings_get_for_screen (screen);
g_signal_handler_disconnect (settings,
- path_bar->settings_signal_id);
- path_bar->settings_signal_id = 0;
+ path_bar->priv->settings_signal_id);
+ path_bar->priv->settings_signal_id = 0;
}
}
@@ -344,7 +373,7 @@ nautilus_path_bar_get_preferred_width (GtkWidget *widget,
*minimum = *natural = 0;
height = 0;
- for (list = path_bar->button_list; list; list = list->next) {
+ for (list = path_bar->priv->button_list; list; list = list->next) {
button_data = BUTTON_DATA (list->data);
gtk_widget_get_preferred_width (button_data->button, &child_min, &child_nat);
gtk_widget_get_preferred_height (button_data->button, &child_height, NULL);
@@ -364,11 +393,11 @@ nautilus_path_bar_get_preferred_width (GtkWidget *widget,
/* Theoretically, the slider could be bigger than the other button. But we're
* not going to worry about that now.
*/
- path_bar->slider_width = MIN (height * 2 / 3 + 5, height);
+ path_bar->priv->slider_width = MIN (height * 2 / 3 + 5, height);
- if (path_bar->button_list && path_bar->button_list->next != NULL) {
- *minimum += (path_bar->spacing + path_bar->slider_width) * 2;
- *natural += (path_bar->spacing + path_bar->slider_width) * 2;
+ if (path_bar->priv->button_list && path_bar->priv->button_list->next != NULL) {
+ *minimum += (path_bar->priv->spacing + path_bar->priv->slider_width) * 2;
+ *natural += (path_bar->priv->spacing + path_bar->priv->slider_width) * 2;
}
}
@@ -386,7 +415,7 @@ nautilus_path_bar_get_preferred_height (GtkWidget *widget,
*minimum = *natural = 0;
- for (list = path_bar->button_list; list; list = list->next) {
+ for (list = path_bar->priv->button_list; list; list = list->next) {
button_data = BUTTON_DATA (list->data);
gtk_widget_get_preferred_height (button_data->button, &child_min, &child_nat);
@@ -398,21 +427,21 @@ nautilus_path_bar_get_preferred_height (GtkWidget *widget,
static void
nautilus_path_bar_update_slider_buttons (NautilusPathBar *path_bar)
{
- if (path_bar->button_list) {
+ if (path_bar->priv->button_list) {
GtkWidget *button;
- button = BUTTON_DATA (path_bar->button_list->data)->button;
+ button = BUTTON_DATA (path_bar->priv->button_list->data)->button;
if (gtk_widget_get_child_visible (button)) {
- gtk_widget_set_sensitive (path_bar->down_slider_button, FALSE);
+ gtk_widget_set_sensitive (path_bar->priv->down_slider_button, FALSE);
} else {
- gtk_widget_set_sensitive (path_bar->down_slider_button, TRUE);
+ gtk_widget_set_sensitive (path_bar->priv->down_slider_button, TRUE);
}
- button = BUTTON_DATA (g_list_last (path_bar->button_list)->data)->button;
+ button = BUTTON_DATA (g_list_last (path_bar->priv->button_list)->data)->button;
if (gtk_widget_get_child_visible (button)) {
- gtk_widget_set_sensitive (path_bar->up_slider_button, FALSE);
+ gtk_widget_set_sensitive (path_bar->priv->up_slider_button, FALSE);
} else {
- gtk_widget_set_sensitive (path_bar->up_slider_button, TRUE);
+ gtk_widget_set_sensitive (path_bar->priv->up_slider_button, TRUE);
}
}
}
@@ -421,7 +450,7 @@ static void
nautilus_path_bar_unmap (GtkWidget *widget)
{
nautilus_path_bar_stop_scrolling (NAUTILUS_PATH_BAR (widget));
- gdk_window_hide (NAUTILUS_PATH_BAR (widget)->event_window);
+ gdk_window_hide (NAUTILUS_PATH_BAR (widget)->priv->event_window);
GTK_WIDGET_CLASS (nautilus_path_bar_parent_class)->unmap (widget);
}
@@ -429,7 +458,7 @@ nautilus_path_bar_unmap (GtkWidget *widget)
static void
nautilus_path_bar_map (GtkWidget *widget)
{
- gdk_window_show (NAUTILUS_PATH_BAR (widget)->event_window);
+ gdk_window_show (NAUTILUS_PATH_BAR (widget)->priv->event_window);
GTK_WIDGET_CLASS (nautilus_path_bar_parent_class)->map (widget);
}
@@ -460,56 +489,56 @@ nautilus_path_bar_size_allocate (GtkWidget *widget,
gtk_widget_set_allocation (widget, allocation);
if (gtk_widget_get_realized (widget)) {
- gdk_window_move_resize (path_bar->event_window,
+ gdk_window_move_resize (path_bar->priv->event_window,
allocation->x, allocation->y,
allocation->width, allocation->height);
}
/* No path is set so we don't have to allocate anything. */
- if (path_bar->button_list == NULL) {
+ if (path_bar->priv->button_list == NULL) {
return;
}
direction = gtk_widget_get_direction (widget);
allocation_width = allocation->width;
/* First, we check to see if we need the scrollbars. */
- if (path_bar->fake_root) {
- width = path_bar->spacing + path_bar->slider_width;
+ if (path_bar->priv->fake_root) {
+ width = path_bar->priv->spacing + path_bar->priv->slider_width;
} else {
width = 0;
}
- gtk_widget_get_preferred_size (BUTTON_DATA (path_bar->button_list->data)->button,
+ gtk_widget_get_preferred_size (BUTTON_DATA (path_bar->priv->button_list->data)->button,
&child_requisition, NULL);
width += child_requisition.width;
- for (list = path_bar->button_list->next; list; list = list->next) {
+ for (list = path_bar->priv->button_list->next; list; list = list->next) {
child = BUTTON_DATA (list->data)->button;
gtk_widget_get_preferred_size (child,
&child_requisition, NULL);
- width += child_requisition.width + path_bar->spacing;
+ width += child_requisition.width + path_bar->priv->spacing;
- if (list == path_bar->fake_root) {
+ if (list == path_bar->priv->fake_root) {
break;
}
}
if (width <= allocation_width) {
- if (path_bar->fake_root) {
- first_button = path_bar->fake_root;
+ if (path_bar->priv->fake_root) {
+ first_button = path_bar->priv->fake_root;
} else {
- first_button = g_list_last (path_bar->button_list);
+ first_button = g_list_last (path_bar->priv->button_list);
}
} else {
gboolean reached_end;
gint slider_space;
reached_end = FALSE;
- slider_space = 2 * (path_bar->spacing + path_bar->slider_width);
+ slider_space = 2 * (path_bar->priv->spacing + path_bar->priv->slider_width);
- if (path_bar->first_scrolled_button) {
- first_button = path_bar->first_scrolled_button;
+ if (path_bar->priv->first_scrolled_button) {
+ first_button = path_bar->priv->first_scrolled_button;
} else {
- first_button = path_bar->button_list;
+ first_button = path_bar->priv->button_list;
}
need_sliders = TRUE;
@@ -527,13 +556,13 @@ nautilus_path_bar_size_allocate (GtkWidget *widget,
gtk_widget_get_preferred_size (child,
&child_requisition, NULL);
- if (width + child_requisition.width + path_bar->spacing + slider_space > allocation_width) {
+ if (width + child_requisition.width + path_bar->priv->spacing + slider_space > allocation_width) {
reached_end = TRUE;
} else {
- if (list == path_bar->fake_root) {
+ if (list == path_bar->priv->fake_root) {
break;
} else {
- width += child_requisition.width + path_bar->spacing;
+ width += child_requisition.width + path_bar->priv->spacing;
}
}
@@ -547,11 +576,11 @@ nautilus_path_bar_size_allocate (GtkWidget *widget,
gtk_widget_get_preferred_size (child,
&child_requisition, NULL);
- if (width + child_requisition.width + path_bar->spacing + slider_space > allocation_width) {
+ if (width + child_requisition.width + path_bar->priv->spacing + slider_space > allocation_width) {
reached_end = TRUE;
} else {
- width += child_requisition.width + path_bar->spacing;
- if (first_button == path_bar->fake_root) {
+ width += child_requisition.width + path_bar->priv->spacing;
+ if (first_button == path_bar->priv->fake_root) {
break;
}
first_button = first_button->next;
@@ -565,15 +594,15 @@ nautilus_path_bar_size_allocate (GtkWidget *widget,
if (direction == GTK_TEXT_DIR_RTL) {
child_allocation.x = allocation->x + allocation->width;
- if (need_sliders || path_bar->fake_root) {
- child_allocation.x -= (path_bar->spacing + path_bar->slider_width);
- up_slider_offset = allocation->width - path_bar->slider_width;
+ if (need_sliders || path_bar->priv->fake_root) {
+ child_allocation.x -= (path_bar->priv->spacing + path_bar->priv->slider_width);
+ up_slider_offset = allocation->width - path_bar->priv->slider_width;
}
} else {
child_allocation.x = allocation->x;
- if (need_sliders || path_bar->fake_root) {
+ if (need_sliders || path_bar->priv->fake_root) {
up_slider_offset = 0;
- child_allocation.x += (path_bar->spacing + path_bar->slider_width);
+ child_allocation.x += (path_bar->priv->spacing + path_bar->priv->slider_width);
}
}
@@ -590,12 +619,12 @@ nautilus_path_bar_size_allocate (GtkWidget *widget,
}
/* 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 - path_bar->spacing - path_bar->slider_width < widget_allocation.x) {
+ if (child_allocation.x - path_bar->priv->spacing - path_bar->priv->slider_width < widget_allocation.x) {
break;
}
} else {
if (need_sliders && direction == GTK_TEXT_DIR_LTR) {
- if (child_allocation.x + child_allocation.width + path_bar->spacing + path_bar->slider_width > widget_allocation.x + allocation_width) {
+ if (child_allocation.x + child_allocation.width + path_bar->priv->spacing + path_bar->priv->slider_width > widget_allocation.x + allocation_width) {
break;
}
}
@@ -605,11 +634,11 @@ nautilus_path_bar_size_allocate (GtkWidget *widget,
gtk_widget_size_allocate (child, &child_allocation);
if (direction == GTK_TEXT_DIR_RTL) {
- child_allocation.x -= path_bar->spacing;
+ child_allocation.x -= path_bar->priv->spacing;
down_slider_offset = 0;
} else {
- down_slider_offset = allocation->width - path_bar->slider_width;
- child_allocation.x += child_allocation.width + path_bar->spacing;
+ down_slider_offset = allocation->width - path_bar->priv->slider_width;
+ child_allocation.x += child_allocation.width + path_bar->priv->spacing;
}
}
/* Now we go hide all the widgets that don't fit */
@@ -621,28 +650,28 @@ nautilus_path_bar_size_allocate (GtkWidget *widget,
gtk_widget_set_child_visible (BUTTON_DATA (list->data)->button, FALSE);
}
- if (need_sliders || path_bar->fake_root) {
- child_allocation.width = path_bar->slider_width;
+ if (need_sliders || path_bar->priv->fake_root) {
+ child_allocation.width = path_bar->priv->slider_width;
child_allocation.x = up_slider_offset + allocation->x;
- gtk_widget_size_allocate (path_bar->up_slider_button, &child_allocation);
+ gtk_widget_size_allocate (path_bar->priv->up_slider_button, &child_allocation);
- gtk_widget_set_child_visible (path_bar->up_slider_button, TRUE);
- gtk_widget_show_all (path_bar->up_slider_button);
+ gtk_widget_set_child_visible (path_bar->priv->up_slider_button, TRUE);
+ gtk_widget_show_all (path_bar->priv->up_slider_button);
} else {
- gtk_widget_set_child_visible (path_bar->up_slider_button, FALSE);
+ gtk_widget_set_child_visible (path_bar->priv->up_slider_button, FALSE);
}
if (need_sliders) {
- child_allocation.width = path_bar->slider_width;
+ child_allocation.width = path_bar->priv->slider_width;
child_allocation.x = down_slider_offset + allocation->x;
- gtk_widget_size_allocate (path_bar->down_slider_button, &child_allocation);
+ gtk_widget_size_allocate (path_bar->priv->down_slider_button, &child_allocation);
- gtk_widget_set_child_visible (path_bar->down_slider_button, TRUE);
- gtk_widget_show_all (path_bar->down_slider_button);
+ gtk_widget_set_child_visible (path_bar->priv->down_slider_button, TRUE);
+ gtk_widget_show_all (path_bar->priv->down_slider_button);
nautilus_path_bar_update_slider_buttons (path_bar);
} else {
- gtk_widget_set_child_visible (path_bar->down_slider_button, FALSE);
+ gtk_widget_set_child_visible (path_bar->priv->down_slider_button, FALSE);
}
}
@@ -724,9 +753,9 @@ nautilus_path_bar_realize (GtkWidget *widget)
GDK_BUTTON_RELEASE_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y;
- path_bar->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ path_bar->priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
- gdk_window_set_user_data (path_bar->event_window, widget);
+ gdk_window_set_user_data (path_bar->priv->event_window, widget);
}
static void
@@ -736,9 +765,9 @@ nautilus_path_bar_unrealize (GtkWidget *widget)
path_bar = NAUTILUS_PATH_BAR (widget);
- gdk_window_set_user_data (path_bar->event_window, NULL);
- gdk_window_destroy (path_bar->event_window);
- path_bar->event_window = NULL;
+ gdk_window_set_user_data (path_bar->priv->event_window, NULL);
+ gdk_window_destroy (path_bar->priv->event_window);
+ path_bar->priv->event_window = NULL;
GTK_WIDGET_CLASS (nautilus_path_bar_parent_class)->unrealize (widget);
}
@@ -770,23 +799,23 @@ nautilus_path_bar_remove (GtkContainer *container,
path_bar = NAUTILUS_PATH_BAR (container);
- if (widget == path_bar->up_slider_button) {
+ if (widget == path_bar->priv->up_slider_button) {
nautilus_path_bar_remove_1 (container, widget);
- path_bar->up_slider_button = NULL;
+ path_bar->priv->up_slider_button = NULL;
return;
}
- if (widget == path_bar->down_slider_button) {
+ if (widget == path_bar->priv->down_slider_button) {
nautilus_path_bar_remove_1 (container, widget);
- path_bar->down_slider_button = NULL;
+ path_bar->priv->down_slider_button = NULL;
return;
}
- children = path_bar->button_list;
+ children = path_bar->priv->button_list;
while (children) {
if (widget == BUTTON_DATA (children->data)->button) {
nautilus_path_bar_remove_1 (container, widget);
- path_bar->button_list = g_list_remove_link (path_bar->button_list, children);
+ path_bar->priv->button_list = g_list_remove_link (path_bar->priv->button_list, children);
g_list_free_1 (children);
return;
}
@@ -806,7 +835,7 @@ nautilus_path_bar_forall (GtkContainer *container,
g_return_if_fail (callback != NULL);
path_bar = NAUTILUS_PATH_BAR (container);
- children = path_bar->button_list;
+ children = path_bar->priv->button_list;
while (children) {
GtkWidget *child;
child = BUTTON_DATA (children->data)->button;
@@ -814,12 +843,12 @@ nautilus_path_bar_forall (GtkContainer *container,
(* callback) (child, callback_data);
}
- if (path_bar->up_slider_button) {
- (* callback) (path_bar->up_slider_button, callback_data);
+ if (path_bar->priv->up_slider_button) {
+ (* callback) (path_bar->priv->up_slider_button, callback_data);
}
- if (path_bar->down_slider_button) {
- (* callback) (path_bar->down_slider_button, callback_data);
+ if (path_bar->priv->down_slider_button) {
+ (* callback) (path_bar->priv->down_slider_button, callback_data);
}
}
@@ -892,6 +921,7 @@ nautilus_path_bar_class_init (NautilusPathBarClass *path_bar_class)
G_TYPE_FILE);
gtk_container_class_handle_border_width (container_class);
+ g_type_class_add_private (path_bar_class, sizeof (NautilusPathBarDetails));
}
static void
@@ -908,8 +938,8 @@ nautilus_path_bar_scroll_down (NautilusPathBar *path_bar)
down_button = NULL;
up_button = NULL;
- if (path_bar->ignore_click) {
- path_bar->ignore_click = FALSE;
+ if (path_bar->priv->ignore_click) {
+ path_bar->priv->ignore_click = FALSE;
return;
}
@@ -919,7 +949,7 @@ nautilus_path_bar_scroll_down (NautilusPathBar *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) {
+ for (list = path_bar->priv->button_list; list; list = list->next) {
if (list->next && gtk_widget_get_child_visible (BUTTON_DATA (list->next->data)->button)) {
down_button = list;
break;
@@ -931,7 +961,7 @@ nautilus_path_bar_scroll_down (NautilusPathBar *path_bar)
}
/* Find the last visible button on the 'up' end */
- for (list = g_list_last (path_bar->button_list); list; list = list->prev) {
+ for (list = g_list_last (path_bar->priv->button_list); list; list = list->prev) {
if (gtk_widget_get_child_visible (BUTTON_DATA (list->data)->button)) {
up_button = list;
break;
@@ -940,9 +970,9 @@ nautilus_path_bar_scroll_down (NautilusPathBar *path_bar)
gtk_widget_get_allocation (BUTTON_DATA (down_button->data)->button, &button_allocation);
gtk_widget_get_allocation (GTK_WIDGET (path_bar), &allocation);
- gtk_widget_get_allocation (path_bar->down_slider_button, &slider_allocation);
+ gtk_widget_get_allocation (path_bar->priv->down_slider_button, &slider_allocation);
- space_needed = button_allocation.width + path_bar->spacing;
+ space_needed = button_allocation.width + path_bar->priv->spacing;
if (direction == GTK_TEXT_DIR_RTL) {
space_available = slider_allocation.x - allocation.x;
} else {
@@ -957,9 +987,9 @@ nautilus_path_bar_scroll_down (NautilusPathBar *path_bar)
gtk_widget_get_allocation (BUTTON_DATA (up_button->data)->button, &button_allocation);
while ((space_available < space_needed) &&
(up_button != NULL)) {
- space_available += button_allocation.width + path_bar->spacing;
+ space_available += button_allocation.width + path_bar->priv->spacing;
up_button = up_button->prev;
- path_bar->first_scrolled_button = up_button;
+ path_bar->priv->first_scrolled_button = up_button;
}
}
@@ -968,19 +998,19 @@ nautilus_path_bar_scroll_up (NautilusPathBar *path_bar)
{
GList *list;
- if (path_bar->ignore_click) {
- path_bar->ignore_click = FALSE;
+ if (path_bar->priv->ignore_click) {
+ path_bar->priv->ignore_click = FALSE;
return;
}
gtk_widget_queue_resize (GTK_WIDGET (path_bar));
- for (list = g_list_last (path_bar->button_list); list; list = list->prev) {
+ for (list = g_list_last (path_bar->priv->button_list); list; list = list->prev) {
if (list->prev && gtk_widget_get_child_visible (BUTTON_DATA (list->prev->data)->button)) {
- if (list->prev == path_bar->fake_root) {
- path_bar->fake_root = NULL;
+ if (list->prev == path_bar->priv->fake_root) {
+ path_bar->priv->fake_root = NULL;
}
- path_bar->first_scrolled_button = list;
+ path_bar->priv->first_scrolled_button = list;
return;
}
}
@@ -993,18 +1023,18 @@ nautilus_path_bar_scroll_timeout (NautilusPathBar *path_bar)
GDK_THREADS_ENTER ();
- if (path_bar->timer) {
- if (gtk_widget_has_focus (path_bar->up_slider_button)) {
+ if (path_bar->priv->timer) {
+ if (gtk_widget_has_focus (path_bar->priv->up_slider_button)) {
nautilus_path_bar_scroll_up (path_bar);
} else {
- if (gtk_widget_has_focus (path_bar->down_slider_button)) {
+ if (gtk_widget_has_focus (path_bar->priv->down_slider_button)) {
nautilus_path_bar_scroll_down (path_bar);
}
}
- if (path_bar->need_timer) {
- path_bar->need_timer = FALSE;
+ if (path_bar->priv->need_timer) {
+ path_bar->priv->need_timer = FALSE;
- path_bar->timer = g_timeout_add (SCROLL_TIMEOUT,
+ path_bar->priv->timer = g_timeout_add (SCROLL_TIMEOUT,
(GSourceFunc)nautilus_path_bar_scroll_timeout,
path_bar);
@@ -1022,10 +1052,10 @@ nautilus_path_bar_scroll_timeout (NautilusPathBar *path_bar)
static void
nautilus_path_bar_stop_scrolling (NautilusPathBar *path_bar)
{
- if (path_bar->timer) {
- g_source_remove (path_bar->timer);
- path_bar->timer = 0;
- path_bar->need_timer = FALSE;
+ if (path_bar->priv->timer) {
+ g_source_remove (path_bar->priv->timer);
+ path_bar->priv->timer = 0;
+ path_bar->priv->need_timer = FALSE;
}
}
@@ -1042,19 +1072,19 @@ nautilus_path_bar_slider_button_press (GtkWidget *widget,
return FALSE;
}
- path_bar->ignore_click = FALSE;
+ path_bar->priv->ignore_click = FALSE;
- if (widget == path_bar->up_slider_button) {
+ if (widget == path_bar->priv->up_slider_button) {
nautilus_path_bar_scroll_up (path_bar);
} else {
- if (widget == path_bar->down_slider_button) {
+ if (widget == path_bar->priv->down_slider_button) {
nautilus_path_bar_scroll_down (path_bar);
}
}
- if (!path_bar->timer) {
- path_bar->need_timer = TRUE;
- path_bar->timer = g_timeout_add (INITIAL_SCROLL_TIMEOUT,
+ if (!path_bar->priv->timer) {
+ path_bar->priv->need_timer = TRUE;
+ path_bar->priv->timer = g_timeout_add (INITIAL_SCROLL_TIMEOUT,
(GSourceFunc)nautilus_path_bar_scroll_timeout,
path_bar);
}
@@ -1071,7 +1101,7 @@ nautilus_path_bar_slider_button_release (GtkWidget *widget,
return FALSE;
}
- path_bar->ignore_click = TRUE;
+ path_bar->priv->ignore_click = TRUE;
nautilus_path_bar_stop_scrolling (path_bar);
return FALSE;
@@ -1084,7 +1114,7 @@ reload_icons (NautilusPathBar *path_bar)
{
GList *list;
- for (list = path_bar->button_list; list; list = list->next) {
+ for (list = path_bar->priv->button_list; list; list = list->next) {
ButtonData *button_data;
button_data = BUTTON_DATA (list->data);
@@ -1098,7 +1128,7 @@ reload_icons (NautilusPathBar *path_bar)
static void
change_icon_theme (NautilusPathBar *path_bar)
{
- path_bar->icon_size = NAUTILUS_PATH_BAR_ICON_SIZE;
+ path_bar->priv->icon_size = NAUTILUS_PATH_BAR_ICON_SIZE;
reload_icons (path_bar);
}
@@ -1122,12 +1152,12 @@ nautilus_path_bar_check_icon_theme (NautilusPathBar *path_bar)
{
GtkSettings *settings;
- if (path_bar->settings_signal_id) {
+ if (path_bar->priv->settings_signal_id) {
return;
}
settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (path_bar)));
- path_bar->settings_signal_id = g_signal_connect (settings, "notify", G_CALLBACK (settings_notify_cb), path_bar);
+ path_bar->priv->settings_signal_id = g_signal_connect (settings, "notify", G_CALLBACK (settings_notify_cb), path_bar);
change_icon_theme (path_bar);
}
@@ -1136,11 +1166,11 @@ nautilus_path_bar_check_icon_theme (NautilusPathBar *path_bar)
void
nautilus_path_bar_clear_buttons (NautilusPathBar *path_bar)
{
- while (path_bar->button_list != NULL) {
- gtk_container_remove (GTK_CONTAINER (path_bar), BUTTON_DATA (path_bar->button_list->data)->button);
+ while (path_bar->priv->button_list != NULL) {
+ gtk_container_remove (GTK_CONTAINER (path_bar), BUTTON_DATA (path_bar->priv->button_list->data)->button);
}
- path_bar->first_scrolled_button = NULL;
- path_bar->fake_root = NULL;
+ path_bar->priv->first_scrolled_button = NULL;
+ path_bar->priv->fake_root = NULL;
}
static void
@@ -1158,7 +1188,7 @@ button_clicked_cb (GtkWidget *button,
path_bar = NAUTILUS_PATH_BAR (gtk_widget_get_parent (button));
- button_list = g_list_find (path_bar->button_list, button_data);
+ button_list = g_list_find (path_bar->priv->button_list, button_data);
g_assert (button_list != NULL);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
@@ -1400,12 +1430,12 @@ setup_button_type (ButtonData *button_data,
NautilusPathBar *path_bar,
GFile *location)
{
- if (path_bar->root_path != NULL && g_file_equal (location, path_bar->root_path)) {
+ if (path_bar->priv->root_path != NULL && g_file_equal (location, path_bar->priv->root_path)) {
button_data->type = ROOT_BUTTON;
- } else if (path_bar->home_path != NULL && g_file_equal (location, path_bar->home_path)) {
+ } else if (path_bar->priv->home_path != NULL && g_file_equal (location, path_bar->priv->home_path)) {
button_data->type = HOME_BUTTON;
button_data->fake_root = TRUE;
- } else if (path_bar->desktop_path != NULL && g_file_equal (location, path_bar->desktop_path)) {
+ } else if (path_bar->priv->desktop_path != NULL && g_file_equal (location, path_bar->priv->desktop_path)) {
button_data->type = DESKTOP_BUTTON;
} else if (setup_file_path_mounted_mount (location, button_data)) {
/* already setup */
@@ -1486,10 +1516,10 @@ button_data_file_changed (NautilusFile *file,
return;
}
- g_assert (path_bar->current_path != NULL);
- g_assert (path_bar->current_button_data != NULL);
+ g_assert (path_bar->priv->current_path != NULL);
+ g_assert (path_bar->priv->current_button_data != NULL);
- current_button_data = path_bar->current_button_data;
+ current_button_data = path_bar->priv->current_button_data;
location = nautilus_file_get_location (file);
if (!g_file_equal (button_data->path, location)) {
@@ -1514,13 +1544,13 @@ button_data_file_changed (NautilusFile *file,
* If it was not below the currently displayed location, update the path bar
*/
child = g_file_has_prefix (button_data->path,
- path_bar->current_path);
+ path_bar->priv->current_path);
if (child) {
/* moved file inside current path hierarchy */
g_object_unref (location);
location = g_file_get_parent (button_data->path);
- current_location = g_object_ref (path_bar->current_path);
+ current_location = g_object_ref (path_bar->priv->current_path);
} else {
/* moved current path, or file outside current path hierarchy.
* Update path bar to new locations.
@@ -1544,13 +1574,13 @@ button_data_file_changed (NautilusFile *file,
if (g_file_has_prefix (location, current_location)) {
/* remove this and the following buttons */
- position = g_list_position (path_bar->button_list,
- g_list_find (path_bar->button_list, button_data));
+ position = g_list_position (path_bar->priv->button_list,
+ g_list_find (path_bar->priv->button_list, button_data));
if (position != -1) {
for (idx = 0; idx <= position; idx++) {
gtk_container_remove (GTK_CONTAINER (path_bar),
- BUTTON_DATA (path_bar->button_list->data)->button);
+ BUTTON_DATA (path_bar->priv->button_list->data)->button);
}
}
}
@@ -1674,7 +1704,7 @@ nautilus_path_bar_check_parent_path (NautilusPathBar *path_bar,
*current_button_data = NULL;
}
- for (list = path_bar->button_list; list; list = list->next) {
+ for (list = path_bar->priv->button_list; list; list = list->next) {
ButtonData *button_data;
button_data = list->data;
@@ -1686,7 +1716,7 @@ nautilus_path_bar_check_parent_path (NautilusPathBar *path_bar,
}
break;
}
- if (list == path_bar->fake_root) {
+ if (list == path_bar->priv->fake_root) {
need_new_fake_root = TRUE;
}
}
@@ -1694,27 +1724,27 @@ nautilus_path_bar_check_parent_path (NautilusPathBar *path_bar,
if (current_path) {
if (need_new_fake_root) {
- path_bar->fake_root = NULL;
+ path_bar->priv->fake_root = NULL;
for (list = current_path; list; list = list->next) {
ButtonData *button_data;
button_data = list->data;
if (list->prev != NULL &&
button_data->fake_root) {
- path_bar->fake_root = list;
+ path_bar->priv->fake_root = list;
break;
}
}
}
- for (list = path_bar->button_list; list; list = list->next) {
+ for (list = path_bar->priv->button_list; list; list = list->next) {
nautilus_path_bar_update_button_state (BUTTON_DATA (list->data),
(list == current_path) ? TRUE : FALSE);
}
if (!gtk_widget_get_child_visible (BUTTON_DATA (current_path->data)->button)) {
- path_bar->first_scrolled_button = current_path;
+ path_bar->priv->first_scrolled_button = current_path;
gtk_widget_queue_resize (GTK_WIDGET (path_bar));
}
return TRUE;
@@ -1768,10 +1798,10 @@ nautilus_path_bar_update_path (NautilusPathBar *path_bar,
}
nautilus_path_bar_clear_buttons (path_bar);
- path_bar->button_list = g_list_reverse (new_buttons);
- path_bar->fake_root = fake_root;
+ path_bar->priv->button_list = g_list_reverse (new_buttons);
+ path_bar->priv->fake_root = fake_root;
- for (l = path_bar->button_list; l; l = l->next) {
+ for (l = path_bar->priv->button_list; l; l = l->next) {
GtkWidget *button;
button = BUTTON_DATA (l->data)->button;
gtk_container_add (GTK_CONTAINER (path_bar), button);
@@ -1779,12 +1809,12 @@ nautilus_path_bar_update_path (NautilusPathBar *path_bar,
gtk_widget_pop_composite_child ();
- if (path_bar->current_path != NULL) {
- g_object_unref (path_bar->current_path);
+ if (path_bar->priv->current_path != NULL) {
+ g_object_unref (path_bar->priv->current_path);
}
- path_bar->current_path = g_object_ref (file_path);
- path_bar->current_button_data = current_button_data;
+ path_bar->priv->current_path = g_object_ref (file_path);
+ path_bar->priv->current_button_data = current_button_data;
g_signal_emit (path_bar, path_bar_signals [PATH_SET], 0, file_path);
@@ -1802,12 +1832,12 @@ nautilus_path_bar_set_path (NautilusPathBar *path_bar, GFile *file_path)
/* Check whether the new path is already present in the pathbar as buttons.
* This could be a parent directory or a previous selected subdirectory. */
if (nautilus_path_bar_check_parent_path (path_bar, file_path, &button_data)) {
- if (path_bar->current_path != NULL) {
- g_object_unref (path_bar->current_path);
+ if (path_bar->priv->current_path != NULL) {
+ g_object_unref (path_bar->priv->current_path);
}
- path_bar->current_path = g_object_ref (file_path);
- path_bar->current_button_data = button_data;
+ path_bar->priv->current_path = g_object_ref (file_path);
+ path_bar->priv->current_button_data = button_data;
return TRUE;
}
@@ -1824,7 +1854,7 @@ nautilus_path_bar_get_path_for_button (NautilusPathBar *path_bar,
g_return_val_if_fail (NAUTILUS_IS_PATH_BAR (path_bar), NULL);
g_return_val_if_fail (GTK_IS_BUTTON (button), NULL);
- for (list = path_bar->button_list; list; list = list->next) {
+ for (list = path_bar->priv->button_list; list; list = list->next) {
ButtonData *button_data;
button_data = BUTTON_DATA (list->data);
if (button_data->button == button) {
diff --git a/src/nautilus-pathbar.h b/src/nautilus-pathbar.h
index bb96b9c..f0f9cbd 100644
--- a/src/nautilus-pathbar.h
+++ b/src/nautilus-pathbar.h
@@ -26,7 +26,7 @@
typedef struct _NautilusPathBar NautilusPathBar;
typedef struct _NautilusPathBarClass NautilusPathBarClass;
-
+typedef struct _NautilusPathBarDetails NautilusPathBarDetails;
#define NAUTILUS_TYPE_PATH_BAR (nautilus_path_bar_get_type ())
#define NAUTILUS_PATH_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_PATH_BAR, NautilusPathBar))
@@ -38,33 +38,8 @@ typedef struct _NautilusPathBarClass NautilusPathBarClass;
struct _NautilusPathBar
{
GtkContainer parent;
-
- GdkWindow *event_window;
-
- GFile *root_path;
- GFile *home_path;
- GFile *desktop_path;
-
- GFile *current_path;
- gpointer current_button_data;
-
- GList *button_list;
- GList *first_scrolled_button;
- GList *fake_root;
- GtkWidget *up_slider_button;
- GtkWidget *down_slider_button;
- guint settings_signal_id;
- gint icon_size;
- gint16 slider_width;
- gint16 spacing;
- gint16 button_offset;
- guint timer;
- guint slider_visible : 1;
- guint need_timer : 1;
- guint ignore_click : 1;
-
- unsigned int drag_slider_timeout;
- gboolean drag_slider_timeout_for_up_button;
+
+ NautilusPathBarDetails *priv;
};
struct _NautilusPathBarClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]