X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtkpathbar.c;h=03ac4c9479728bde5d6c8751115fdfdf16fce991;hb=e1edc998a2e9c557030d207533932b3120e13fe5;hp=35dc8bf249aaa6634b044c4966685328d48071c9;hpb=6ce48345ce50f95d684d60a46b449ce79c199281;p=~andy%2Fgtk diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c index 35dc8bf24..03ac4c947 100644 --- a/gtk/gtkpathbar.c +++ b/gtk/gtkpathbar.c @@ -13,9 +13,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * License along with this library. If not, see . */ #include "config.h" @@ -24,17 +22,20 @@ #include -#include "gtktogglebutton.h" #include "gtkarrow.h" +#include "gtkbox.h" #include "gtkdnd.h" +#include "gtkiconfactory.h" +#include "gtkicontheme.h" #include "gtkimage.h" #include "gtkintl.h" -#include "gtkicontheme.h" -#include "gtkiconfactory.h" #include "gtklabel.h" -#include "gtkbox.h" #include "gtkmain.h" #include "gtkmarshalers.h" +#include "gtksettings.h" +#include "gtktogglebutton.h" +#include "gtkwidgetpath.h" +#include "gtkwidgetprivate.h" enum { @@ -160,6 +161,7 @@ get_slider_button (GtkPathBar *path_bar, atk_object_set_name (atk_obj, _("Down Path")); gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE); + gtk_widget_add_events (button, GDK_SCROLL_MASK); gtk_container_add (GTK_CONTAINER (button), gtk_arrow_new (arrow_type, GTK_SHADOW_OUT)); gtk_container_add (GTK_CONTAINER (path_bar), button); @@ -470,7 +472,7 @@ gtk_path_bar_realize (GtkWidget *widget) path_bar->event_window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); - gdk_window_set_user_data (path_bar->event_window, widget); + gtk_widget_register_window (widget, path_bar->event_window); } static void @@ -480,7 +482,7 @@ gtk_path_bar_unrealize (GtkWidget *widget) path_bar = GTK_PATH_BAR (widget); - gdk_window_set_user_data (path_bar->event_window, NULL); + gtk_widget_unregister_window (widget, path_bar->event_window); gdk_window_destroy (path_bar->event_window); path_bar->event_window = NULL; @@ -493,15 +495,18 @@ child_ordering_changed (GtkPathBar *path_bar) GList *l; if (path_bar->up_slider_button) - gtk_widget_reset_style (path_bar->up_slider_button); + _gtk_widget_invalidate_style_context (path_bar->up_slider_button, + GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_SIBLING_POSITION); if (path_bar->down_slider_button) - gtk_widget_reset_style (path_bar->down_slider_button); + _gtk_widget_invalidate_style_context (path_bar->down_slider_button, + GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_SIBLING_POSITION); for (l = path_bar->button_list; l; l = l->next) { ButtonData *data = l->data; - gtk_widget_reset_style (data->button); + _gtk_widget_invalidate_style_context (data->button, + GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_SIBLING_POSITION); } } @@ -521,6 +526,7 @@ gtk_path_bar_size_allocate (GtkWidget *widget, gboolean need_sliders = FALSE; gint up_slider_offset = 0; GtkRequisition child_requisition; + gboolean needs_reorder = FALSE; gtk_widget_set_allocation (widget, allocation); @@ -682,6 +688,7 @@ gtk_path_bar_size_allocate (GtkWidget *widget, else if (gtk_widget_get_has_tooltip (child)) gtk_widget_set_tooltip_text (child, NULL); + needs_reorder |= gtk_widget_get_child_visible (child) == FALSE; gtk_widget_set_child_visible (child, TRUE); gtk_widget_size_allocate (child, &child_allocation); @@ -693,12 +700,16 @@ gtk_path_bar_size_allocate (GtkWidget *widget, /* Now we go hide all the widgets that don't fit */ while (list) { - gtk_widget_set_child_visible (BUTTON_DATA (list->data)->button, FALSE); + child = BUTTON_DATA (list->data)->button; + needs_reorder |= gtk_widget_get_child_visible (child) == TRUE; + gtk_widget_set_child_visible (child, FALSE); list = list->prev; } for (list = first_button->next; list; list = list->next) { - gtk_widget_set_child_visible (BUTTON_DATA (list->data)->button, FALSE); + child = BUTTON_DATA (list->data)->button; + needs_reorder |= gtk_widget_get_child_visible (child) == TRUE; + gtk_widget_set_child_visible (child, FALSE); } if (need_sliders || path_bar->fake_root) @@ -707,11 +718,15 @@ gtk_path_bar_size_allocate (GtkWidget *widget, child_allocation.x = up_slider_offset + allocation->x; gtk_widget_size_allocate (path_bar->up_slider_button, &child_allocation); + needs_reorder |= gtk_widget_get_child_visible (path_bar->up_slider_button) == FALSE; gtk_widget_set_child_visible (path_bar->up_slider_button, TRUE); gtk_widget_show_all (path_bar->up_slider_button); } else - gtk_widget_set_child_visible (path_bar->up_slider_button, FALSE); + { + needs_reorder |= gtk_widget_get_child_visible (path_bar->up_slider_button) == TRUE; + gtk_widget_set_child_visible (path_bar->up_slider_button, FALSE); + } if (need_sliders) { @@ -726,14 +741,19 @@ gtk_path_bar_size_allocate (GtkWidget *widget, gtk_widget_size_allocate (path_bar->down_slider_button, &child_allocation); + needs_reorder |= gtk_widget_get_child_visible (path_bar->down_slider_button) == FALSE; gtk_widget_set_child_visible (path_bar->down_slider_button, TRUE); gtk_widget_show_all (path_bar->down_slider_button); gtk_path_bar_update_slider_buttons (path_bar); } else - gtk_widget_set_child_visible (path_bar->down_slider_button, FALSE); + { + needs_reorder |= gtk_widget_get_child_visible (path_bar->down_slider_button) == TRUE; + gtk_widget_set_child_visible (path_bar->down_slider_button, FALSE); + } - child_ordering_changed (path_bar); + if (needs_reorder) + child_ordering_changed (path_bar); } static void @@ -772,6 +792,8 @@ gtk_path_bar_scroll (GtkWidget *widget, case GDK_SCROLL_UP: gtk_path_bar_scroll_up (GTK_PATH_BAR (widget)); break; + case GDK_SCROLL_SMOOTH: + break; } return TRUE; @@ -869,7 +891,7 @@ gtk_path_bar_get_path_for_child (GtkContainer *container, GtkPathBar *path_bar = GTK_PATH_BAR (container); GtkWidgetPath *path; - path = gtk_widget_path_copy (gtk_widget_get_path (GTK_WIDGET (path_bar))); + path = _gtk_widget_create_path (GTK_WIDGET (path_bar)); if (gtk_widget_get_visible (child) && gtk_widget_get_child_visible (child)) @@ -1130,7 +1152,7 @@ gtk_path_bar_slider_button_press (GtkWidget *widget, GdkEventButton *event, GtkPathBar *path_bar) { - if (event->type != GDK_BUTTON_PRESS || event->button != 1) + if (event->type != GDK_BUTTON_PRESS || event->button != GDK_BUTTON_PRIMARY) return FALSE; path_bar->ignore_click = FALSE; @@ -1611,6 +1633,7 @@ make_directory_button (GtkPathBar *path_bar, button_data->button = gtk_toggle_button_new (); atk_obj = gtk_widget_get_accessible (button_data->button); gtk_button_set_focus_on_click (GTK_BUTTON (button_data->button), FALSE); + gtk_widget_add_events (button_data->button, GDK_SCROLL_MASK); switch (button_data->type) { @@ -1824,17 +1847,23 @@ gtk_path_bar_get_info_callback (GCancellable *cancellable, if (BUTTON_IS_FAKE_ROOT (button_data)) file_info->fake_root = file_info->new_buttons; + /* We have assigned the info for the innermost button, i.e. the deepest directory. + * Now, go on to fetch the info for this directory's parent. + */ + file_info->file = file_info->parent_file; file_info->first_directory = FALSE; if (!file_info->file) { + /* No parent? Okay, we are done. */ gtk_path_bar_set_file_finish (file_info, TRUE); return; } file_info->parent_file = g_file_get_parent (file_info->file); + /* Recurse asynchronously */ file_info->path_bar->get_info_cancellable = _gtk_file_system_get_info (file_info->path_bar->file_system, file_info->file, @@ -1843,22 +1872,21 @@ gtk_path_bar_get_info_callback (GCancellable *cancellable, file_info); } -gboolean +void _gtk_path_bar_set_file (GtkPathBar *path_bar, GFile *file, - const gboolean keep_trail, - GError **error) + const gboolean keep_trail) { struct SetFileInfo *info; - g_return_val_if_fail (GTK_IS_PATH_BAR (path_bar), FALSE); - g_return_val_if_fail (G_IS_FILE (file), FALSE); + g_return_if_fail (GTK_IS_PATH_BAR (path_bar)); + g_return_if_fail (G_IS_FILE (file)); /* 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 (keep_trail && gtk_path_bar_check_parent_path (path_bar, file)) - return TRUE; + return; info = g_new0 (struct SetFileInfo, 1); info->file = g_object_ref (file); @@ -1875,8 +1903,6 @@ _gtk_path_bar_set_file (GtkPathBar *path_bar, "standard::display-name,standard::is-hidden,standard::is-backup", gtk_path_bar_get_info_callback, info); - - return TRUE; } /* FIXME: This should be a construct-only property */