[gtk+/wip/csoriano/bookmarks] jimmac style for reordering
- From: Carlos Soriano Sánchez <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/csoriano/bookmarks] jimmac style for reordering
- Date: Thu, 4 Jun 2015 17:48:17 +0000 (UTC)
commit 9993e915e29beb549f859569cff3da42c8ab8e2e
Author: Carlos Soriano <csoriano gnome org>
Date: Thu Jun 4 19:47:54 2015 +0200
jimmac style for reordering
gtk/gtkplacessidebar.c | 80 ++++++++++++++++++++++++------
gtk/theme/Adwaita/_common.scss | 7 ++-
gtk/theme/Adwaita/gtk-contained-dark.css | 2 +
gtk/theme/Adwaita/gtk-contained.css | 2 +
4 files changed, 75 insertions(+), 16 deletions(-)
---
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index cc1cdc7..71f92b1 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -221,6 +221,7 @@ typedef enum {
PLACES_CONNECT_TO_SERVER,
PLACES_ENTER_LOCATION,
PLACES_DROP_FEEDBACK,
+ PLACES_BOOKMARK_PLACEHOLDER,
N_PLACES
} PlaceType;
@@ -319,6 +320,7 @@ struct _SidebarRow
GVolume *volume;
GMount *mount;
gboolean sensitive;
+ gboolean placeholder;
GtkPlacesSidebar *sidebar;
GtkWidget *event_box;
GtkWidget *revealer;
@@ -358,6 +360,7 @@ enum
PROP_VOLUME,
PROP_MOUNT,
PROP_SENSITIVE,
+ PROP_PLACEHOLDER,
LAST_PROP
};
@@ -445,6 +448,12 @@ sidebar_row_get_property (GObject *object,
break;
}
+ case PROP_PLACEHOLDER:
+ {
+ g_value_set_boolean (value, self->placeholder);
+ break;
+ }
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -582,6 +591,30 @@ sidebar_row_set_property (GObject *object,
break;
}
+ case PROP_PLACEHOLDER:
+ {
+ self->placeholder = g_value_get_boolean (value);
+ if (self->placeholder)
+ {
+ g_clear_object (&self->icon);
+ g_free (self->label);
+ self->label = NULL;
+ self->ejectable = FALSE;
+ self->section_type = SECTION_BOOKMARKS;
+ self->place_type = PLACES_BOOKMARK_PLACEHOLDER;
+ g_free (self->uri);
+ g_clear_object (&self->drive);
+ g_clear_object (&self->volume);
+ g_clear_object (&self->mount);
+
+ gtk_container_foreach (GTK_CONTAINER (self),
+ (GtkCallback) gtk_widget_destroy,
+ NULL);
+ }
+
+ break;
+ }
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -766,6 +799,17 @@ sidebar_row_class_init (SidebarRowClass *klass)
g_object_class_install_property (object_class, PROP_SENSITIVE,
gParamSpecs [PROP_SENSITIVE]);
+ gParamSpecs [PROP_PLACEHOLDER] =
+ g_param_spec_boolean ("placeholder",
+ _("Placeholder"),
+ _("Placeholder"),
+ FALSE,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_PLACEHOLDER,
+ gParamSpecs [PROP_PLACEHOLDER]);
+
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gtk/libgtk/ui/sidebarrow.ui");
@@ -1919,8 +1963,12 @@ start_drop_feedback (GtkPlacesSidebar *sidebar,
sidebar->drop_state = DROP_STATE_NEW_BOOKMARK_ARMED;
}
- if (check_valid_drop_target (sidebar, row))
- gtk_list_box_drag_highlight_row (GTK_LIST_BOX (sidebar->list_box), GTK_LIST_BOX_ROW (row));
+ if (!(sidebar->drag_data_received &&
+ sidebar->drag_data_info == DND_SIDEBAR_ROW))
+ {
+ if (check_valid_drop_target (sidebar, row))
+ gtk_list_box_drag_highlight_row (GTK_LIST_BOX (sidebar->list_box), GTK_LIST_BOX_ROW (row));
+ }
update_possible_drop_targets (sidebar, TRUE);
}
@@ -2028,15 +2076,11 @@ create_placeholder_row (GtkPlacesSidebar *sidebar)
GtkStyleContext *context;
GtkWidget *placeholder_row = g_object_new (SIDEBAR_TYPE_ROW,
- "section-type", SECTION_BOOKMARKS,
- "place-type", PLACES_DROP_FEEDBACK,
- "ejectable", FALSE,
- NULL);
+ "placeholder", TRUE,
+ NULL);
context = gtk_widget_get_style_context (placeholder_row);
- gtk_style_context_add_class (context, "sidebar-placeholder-row");
-
- gtk_widget_set_size_request (placeholder_row, -1, sidebar->drag_row_height);
+ gtk_style_context_add_class (context, "sidebar-placeholder-row");
return placeholder_row;
}
@@ -2102,6 +2146,8 @@ drag_motion_callback (GtkWidget *widget,
if (row != NULL)
{
+ gint dest_y, dest_x;
+
g_object_get (row, "order-index", &row_index, NULL);
g_object_get (sidebar->row_placeholder, "order-index", &row_placeholder_index, NULL);
/* We order the bookmarks sections based on the bookmark index that we
@@ -2117,10 +2163,13 @@ drag_motion_callback (GtkWidget *widget,
* (that now is before the placeholder) it will just set the index-order
* of that row, and go again to be positioned before.
*/
- if (row_index >= row_placeholder_index)
- row_placeholder_index = row_index + 1;
- else
row_placeholder_index = row_index;
+ gtk_widget_translate_coordinates (widget, GTK_WIDGET (row),
+ x, y,
+ &dest_x, &dest_y);
+
+ if (dest_y > sidebar->drag_row_height / 2 && row_index > 0)
+ row_placeholder_index++;
}
else
{
@@ -4017,7 +4066,8 @@ list_box_sort_func (GtkListBoxRow *row1,
{
retval = g_utf8_collate (label_1, label_2);
}
- else if (place_type_1 == PLACES_BOOKMARK && place_type_2 == PLACES_BOOKMARK)
+ else if ((place_type_1 == PLACES_BOOKMARK || place_type_2 == PLACES_DROP_FEEDBACK) &&
+ (place_type_1 == PLACES_DROP_FEEDBACK || place_type_2 == PLACES_BOOKMARK))
{
retval = index_1 - index_2;
}
@@ -4034,14 +4084,14 @@ list_box_sort_func (GtkListBoxRow *row1,
* (that now is before the placeholder) it will just set the index-order
* of that row, and go again to be positioned before.
*/
- else if (place_type_1 == PLACES_DROP_FEEDBACK && place_type_2 == PLACES_BOOKMARK)
+ else if (place_type_1 == PLACES_BOOKMARK_PLACEHOLDER && place_type_2 == PLACES_BOOKMARK)
{
if (index_1 == index_2)
retval = index_1 - index_2 - 1;
else
retval = index_1 - index_2;
}
- else if (place_type_1 == PLACES_BOOKMARK && place_type_2 == PLACES_DROP_FEEDBACK)
+ else if (place_type_1 == PLACES_BOOKMARK && place_type_2 == PLACES_BOOKMARK_PLACEHOLDER)
{
if (index_1 == index_2)
retval = index_1 - index_2 + 1;
diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss
index 123d71f..1302b9c 100644
--- a/gtk/theme/Adwaita/_common.scss
+++ b/gtk/theme/Adwaita/_common.scss
@@ -2887,12 +2887,17 @@ GtkPlacesSidebar.sidebar {
SidebarRow { padding: 0px 8px; }
+ // Preserve everything else of the list-row class
@at-root .list-row.button {
// Popover menuitem color
&:hover {
background-color: mix($fg_color, $bg_color, 10%);
}
-}
+ }
+
+ .sidebar-placeholder-row {
+ border: solid 1px $selected_bg_color;
+ }
.dnd {
box-shadow: inset 0px 0px 0px 1px mix($fg_color, $selected_bg_color, 50%);
diff --git a/gtk/theme/Adwaita/gtk-contained-dark.css b/gtk/theme/Adwaita/gtk-contained-dark.css
index 5026d96..cc64476 100644
--- a/gtk/theme/Adwaita/gtk-contained-dark.css
+++ b/gtk/theme/Adwaita/gtk-contained-dark.css
@@ -3992,6 +3992,8 @@ GtkPlacesSidebar.sidebar SidebarRow {
padding: 0px 8px; }
.list-row.button:hover {
background-color: #4b5150; }
+GtkPlacesSidebar.sidebar .sidebar-placeholder-row {
+ border: solid 1px #215d9c; }
GtkPlacesSidebar.sidebar .dnd {
box-shadow: inset 0px 0px 0px 1px #88a6c4; }
GtkPlacesSidebar.sidebar .sidebar-revealer {
diff --git a/gtk/theme/Adwaita/gtk-contained.css b/gtk/theme/Adwaita/gtk-contained.css
index ade4143..f548c54 100644
--- a/gtk/theme/Adwaita/gtk-contained.css
+++ b/gtk/theme/Adwaita/gtk-contained.css
@@ -4164,6 +4164,8 @@ GtkPlacesSidebar.sidebar SidebarRow {
padding: 0px 8px; }
.list-row.button:hover {
background-color: #dadbdb; }
+GtkPlacesSidebar.sidebar .sidebar-placeholder-row {
+ border: solid 1px #4a90d9; }
GtkPlacesSidebar.sidebar .dnd {
box-shadow: inset 0px 0px 0px 1px #3c6288; }
GtkPlacesSidebar.sidebar .sidebar-revealer {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]