[gnome-flashback] desktop: remove GfIconSelectedFlags
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] desktop: remove GfIconSelectedFlags
- Date: Wed, 13 Nov 2019 22:33:41 +0000 (UTC)
commit 117cbc124f761677f8e911413b9826290267cf59
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Wed Nov 13 22:57:05 2019 +0200
desktop: remove GfIconSelectedFlags
gnome-flashback/libdesktop/Makefile.am | 1 -
gnome-flashback/libdesktop/gf-icon-view.c | 36 +++++++++++++-----------------
gnome-flashback/libdesktop/gf-icon-view.h | 2 ++
gnome-flashback/libdesktop/gf-icon.c | 37 ++++++++-----------------------
gnome-flashback/libdesktop/gf-icon.h | 27 ++++++++--------------
5 files changed, 36 insertions(+), 67 deletions(-)
---
diff --git a/gnome-flashback/libdesktop/Makefile.am b/gnome-flashback/libdesktop/Makefile.am
index e48461e..93077a0 100644
--- a/gnome-flashback/libdesktop/Makefile.am
+++ b/gnome-flashback/libdesktop/Makefile.am
@@ -49,7 +49,6 @@ libdesktop_la_LIBADD = \
ENUM_TYPES = \
$(srcdir)/gf-desktop-enums.h \
- $(srcdir)/gf-icon.h \
$(NULL)
gf-desktop-enum-types.c: gf-desktop-enum-types.c.in gf-desktop-enum-types.h $(ENUM_TYPES)
diff --git a/gnome-flashback/libdesktop/gf-icon-view.c b/gnome-flashback/libdesktop/gf-icon-view.c
index bce0106..a3cfe7f 100644
--- a/gnome-flashback/libdesktop/gf-icon-view.c
+++ b/gnome-flashback/libdesktop/gf-icon-view.c
@@ -249,7 +249,7 @@ static void
unselect_cb (gpointer data,
gpointer user_data)
{
- gf_icon_set_selected (data, FALSE, GF_ICON_SELECTED_NONE);
+ gf_icon_set_selected (data, FALSE);
}
static void
@@ -263,17 +263,12 @@ unselect_icons (GfIconView *self)
}
static void
-icon_selected_cb (GfIcon *icon,
- GfIconSelectedFlags flags,
- GfIconView *self)
+icon_selected_cb (GfIcon *icon,
+ GfIconView *self)
{
- if ((flags & GF_ICON_SELECTED_CLEAR) == GF_ICON_SELECTED_CLEAR)
- unselect_icons (self);
-
- if ((flags & GF_ICON_SELECTED_ADD) == GF_ICON_SELECTED_ADD)
+ if (gf_icon_get_selected (icon))
self->selected_icons = g_list_append (self->selected_icons, icon);
-
- if ((flags & GF_ICON_SELECTED_REMOVE) == GF_ICON_SELECTED_REMOVE)
+ else
self->selected_icons = g_list_remove (self->selected_icons, icon);
}
@@ -736,9 +731,9 @@ drag_update_cb (GtkGestureDrag *gesture,
NULL))
{
if (gf_icon_get_selected (icon))
- gf_icon_set_selected (icon, FALSE, GF_ICON_SELECTED_REMOVE);
+ gf_icon_set_selected (icon, FALSE);
else
- gf_icon_set_selected (icon, TRUE, GF_ICON_SELECTED_ADD);
+ gf_icon_set_selected (icon, TRUE);
self->rubberband_icons = g_list_remove (self->rubberband_icons,
icon);
@@ -798,9 +793,9 @@ drag_update_cb (GtkGestureDrag *gesture,
icon);
if (gf_icon_get_selected (icon))
- gf_icon_set_selected (icon, FALSE, GF_ICON_SELECTED_REMOVE);
+ gf_icon_set_selected (icon, FALSE);
else
- gf_icon_set_selected (icon, TRUE, GF_ICON_SELECTED_ADD);
+ gf_icon_set_selected (icon, TRUE);
}
g_list_free (rubberband_icons);
@@ -1157,15 +1152,10 @@ select_cb (gpointer data,
gpointer user_data)
{
GfIconInfo *info;
- GfIcon *icon;
info = data;
- icon = GF_ICON (info->icon);
- if (gf_icon_get_selected (icon))
- return;
-
- gf_icon_set_selected (icon, TRUE, GF_ICON_SELECTED_ADD);
+ gf_icon_set_selected (GF_ICON (info->icon), TRUE);
}
static void
@@ -1526,6 +1516,12 @@ gf_icon_view_set_representative_color (GfIconView *self,
}
}
+void
+gf_icon_view_clear_selection (GfIconView *self)
+{
+ unselect_icons (self);
+}
+
GList *
gf_icon_view_get_selected_icons (GfIconView *self)
{
diff --git a/gnome-flashback/libdesktop/gf-icon-view.h b/gnome-flashback/libdesktop/gf-icon-view.h
index fcabc46..d716c51 100644
--- a/gnome-flashback/libdesktop/gf-icon-view.h
+++ b/gnome-flashback/libdesktop/gf-icon-view.h
@@ -30,6 +30,8 @@ GtkWidget *gf_icon_view_new (void);
void gf_icon_view_set_representative_color (GfIconView *self,
GdkRGBA *color);
+void gf_icon_view_clear_selection (GfIconView *self);
+
GList *gf_icon_view_get_selected_icons (GfIconView *self);
void gf_icon_view_show_item_properties (GfIconView *self,
diff --git a/gnome-flashback/libdesktop/gf-icon.c b/gnome-flashback/libdesktop/gf-icon.c
index 83ce9b4..024fcf4 100644
--- a/gnome-flashback/libdesktop/gf-icon.c
+++ b/gnome-flashback/libdesktop/gf-icon.c
@@ -203,7 +203,6 @@ multi_press_pressed_cb (GtkGestureMultiPress *gesture,
guint button;
GdkEventSequence *sequence;
const GdkEvent *event;
- GfIconSelectedFlags flags;
GdkModifierType state;
gboolean control_pressed;
gboolean shift_pressed;
@@ -213,7 +212,6 @@ multi_press_pressed_cb (GtkGestureMultiPress *gesture,
button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
- flags = GF_ICON_SELECTED_NONE;
if (event == NULL)
return;
@@ -225,27 +223,13 @@ multi_press_pressed_cb (GtkGestureMultiPress *gesture,
if (button == GDK_BUTTON_PRIMARY)
{
- gboolean selected;
-
if (!control_pressed && !shift_pressed)
- flags |= GF_ICON_SELECTED_CLEAR;
+ gf_icon_view_clear_selection (priv->icon_view);
if (control_pressed || shift_pressed)
- {
- selected = !priv->selected;
-
- if (priv->selected)
- flags |= GF_ICON_SELECTED_REMOVE;
- else
- flags |= GF_ICON_SELECTED_ADD;
- }
+ gf_icon_set_selected (self, !priv->selected);
else
- {
- selected = TRUE;
- flags |= GF_ICON_SELECTED_ADD;
- }
-
- gf_icon_set_selected (self, selected, flags);
+ gf_icon_set_selected (self, TRUE);
if (!control_pressed && n_press == 2)
icon_open (self);
@@ -255,11 +239,10 @@ multi_press_pressed_cb (GtkGestureMultiPress *gesture,
GtkWidget *popup_menu;
if (!priv->selected && !control_pressed)
- flags |= GF_ICON_SELECTED_CLEAR;
- flags |= GF_ICON_SELECTED_ADD;
+ gf_icon_view_clear_selection (priv->icon_view);
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
- gf_icon_set_selected (self, TRUE, flags);
+ gf_icon_set_selected (self, TRUE);
popup_menu = create_popup_menu (self);
g_object_ref_sink (popup_menu);
@@ -500,8 +483,7 @@ install_signals (void)
{
icon_signals[SELECTED] =
g_signal_new ("selected", GF_TYPE_ICON, G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL, G_TYPE_NONE, 1,
- GF_TYPE_ICON_SELECTED_FLAGS);
+ 0, NULL, NULL, NULL, G_TYPE_NONE, 0);
}
static void
@@ -625,9 +607,8 @@ gf_icon_is_hidden (GfIcon *self)
}
void
-gf_icon_set_selected (GfIcon *self,
- gboolean selected,
- GfIconSelectedFlags flags)
+gf_icon_set_selected (GfIcon *self,
+ gboolean selected)
{
GfIconPrivate *priv;
@@ -639,7 +620,7 @@ gf_icon_set_selected (GfIcon *self,
priv->selected = selected;
update_state (self);
- g_signal_emit (self, icon_signals[SELECTED], 0, flags);
+ g_signal_emit (self, icon_signals[SELECTED], 0);
}
gboolean
diff --git a/gnome-flashback/libdesktop/gf-icon.h b/gnome-flashback/libdesktop/gf-icon.h
index 9ac0d92..25236e1 100644
--- a/gnome-flashback/libdesktop/gf-icon.h
+++ b/gnome-flashback/libdesktop/gf-icon.h
@@ -22,14 +22,6 @@
G_BEGIN_DECLS
-typedef enum
-{
- GF_ICON_SELECTED_NONE = 0,
- GF_ICON_SELECTED_CLEAR = (1 << 0),
- GF_ICON_SELECTED_ADD = (1 << 1),
- GF_ICON_SELECTED_REMOVE = (1 << 2)
-} GfIconSelectedFlags;
-
#define GF_TYPE_ICON (gf_icon_get_type ())
G_DECLARE_DERIVABLE_TYPE (GfIcon, gf_icon, GF, ICON, GtkButton)
@@ -38,21 +30,20 @@ struct _GfIconClass
GtkButtonClass parent_class;
};
-GtkWidget *gf_icon_new (GfIconView *icon_view,
- GFile *file,
- GFileInfo *info);
+GtkWidget *gf_icon_new (GfIconView *icon_view,
+ GFile *file,
+ GFileInfo *info);
-GFile *gf_icon_get_file (GfIcon *self);
+GFile *gf_icon_get_file (GfIcon *self);
-const char *gf_icon_get_name (GfIcon *self);
+const char *gf_icon_get_name (GfIcon *self);
-gboolean gf_icon_is_hidden (GfIcon *self);
+gboolean gf_icon_is_hidden (GfIcon *self);
-void gf_icon_set_selected (GfIcon *self,
- gboolean selected,
- GfIconSelectedFlags flags);
+void gf_icon_set_selected (GfIcon *self,
+ gboolean selected);
-gboolean gf_icon_get_selected (GfIcon *self);
+gboolean gf_icon_get_selected (GfIcon *self);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]