[glade3] * gladeui/glade-utils.[ch], gladeui/glade-widget.c, gladeui/glade-project.c, gladeui/glade-popup.c
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade3] * gladeui/glade-utils.[ch], gladeui/glade-widget.c, gladeui/glade-project.c, gladeui/glade-popup.c
- Date: Sat, 8 Jan 2011 08:21:09 +0000 (UTC)
commit e37b0289bee744544536810dde3f9d90440857e8
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Sat Jan 8 17:16:17 2011 +0900
* gladeui/glade-utils.[ch], gladeui/glade-widget.c, gladeui/glade-project.c,
gladeui/glade-popup.c, gladeui/glade-placeholder.c: Removed global selection list
from glade-utils, selection can only be placed on widgets and only be controlled
by their owning project.
ChangeLog | 5 ++
gladeui/glade-placeholder.c | 2 -
gladeui/glade-popup.c | 10 +---
gladeui/glade-project.c | 19 ++++---
gladeui/glade-utils.c | 116 ++++++-------------------------------------
gladeui/glade-utils.h | 7 ---
gladeui/glade-widget.c | 1 -
7 files changed, 32 insertions(+), 128 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0050693..7f3ca8f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,11 @@
* gladeui/glade-utils.[ch]: Some cleanup in glade-utils, removed lots of obsolete stuff.
+ * gladeui/glade-utils.[ch], gladeui/glade-widget.c, gladeui/glade-project.c,
+ gladeui/glade-popup.c, gladeui/glade-placeholder.c: Removed global selection list
+ from glade-utils, selection can only be placed on widgets and only be controlled
+ by their owning project.
+
2011-01-07 Emilio Pozuelo Monfort <pochu27 gmail com>
* configure.ac: Bump the minimum GTK+ version to 2.99.0.
diff --git a/gladeui/glade-placeholder.c b/gladeui/glade-placeholder.c
index ee2d139..7c49e61 100644
--- a/gladeui/glade-placeholder.c
+++ b/gladeui/glade-placeholder.c
@@ -392,8 +392,6 @@ glade_placeholder_draw (GtkWidget * widget, cairo_t * cr)
glade_utils_cairo_draw_line (cr, dark, 0, h - 1, w - 1, h - 1);
glade_utils_cairo_draw_line (cr, dark, w - 1, 0, w - 1, h - 1);
- glade_util_draw_selection_nodes (widget, cr);
-
return FALSE;
}
diff --git a/gladeui/glade-popup.c b/gladeui/glade-popup.c
index de132e3..91bcec2 100644
--- a/gladeui/glade-popup.c
+++ b/gladeui/glade-popup.c
@@ -54,7 +54,6 @@ glade_popup_docs_cb (GtkMenuItem * item, GladeWidgetAdaptor * adaptor)
static void
glade_popup_select_cb (GtkMenuItem * item, GladeWidget * widget)
{
- glade_util_clear_selection ();
glade_project_selection_set (glade_widget_get_project (widget),
glade_widget_get_object (widget), TRUE);
}
@@ -132,8 +131,6 @@ glade_popup_cut_cb (GtkMenuItem * item, GladeWidget * widget)
{
GladeProject *project = glade_widget_get_project (widget);
- glade_util_clear_selection ();
-
/* Assign selection first only if its not already assigned (it may be a delete
* of multiple widgets) */
if (!glade_project_is_selected (project, glade_widget_get_object (widget)))
@@ -147,10 +144,8 @@ glade_popup_copy_cb (GtkMenuItem * item, GladeWidget * widget)
{
GladeProject *project = glade_widget_get_project (widget);
- glade_util_clear_selection ();
-
/* Assign selection first */
- if (glade_project_is_selected (project, glade_widget_get_object (widget)) == FALSE)
+ if (!glade_project_is_selected (project, glade_widget_get_object (widget)))
glade_project_selection_set (project, glade_widget_get_object (widget), FALSE);
glade_project_copy_selection (project);
@@ -172,8 +167,6 @@ glade_popup_paste_cb (GtkMenuItem * item, gpointer data)
else
g_return_if_reached ();
- glade_util_clear_selection ();
-
/* The selected widget is the paste destination */
if (widget)
glade_project_selection_set (project, glade_widget_get_object (widget), FALSE);
@@ -207,7 +200,6 @@ glade_popup_placeholder_paste_cb (GtkMenuItem * item,
project = glade_placeholder_get_project (placeholder);
- glade_util_clear_selection ();
glade_project_selection_clear (project, FALSE);
glade_project_command_paste (project, placeholder);
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index 32332ca..7e9273d 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -887,7 +887,7 @@ glade_project_class_init (GladeProjectClass * klass)
G_TYPE_NONE, 1, GLADE_TYPE_WIDGET);
- /**
+ /**
* GladeProject::selection-changed:
* @gladeproject: the #GladeProject which received the signal.
*
@@ -3329,11 +3329,18 @@ glade_project_is_selected (GladeProject * project, GObject * object)
void
glade_project_selection_clear (GladeProject * project, gboolean emit_signal)
{
+ GList *l;
+
g_return_if_fail (GLADE_IS_PROJECT (project));
+
if (project->priv->selection == NULL)
return;
- glade_util_clear_selection ();
+ for (l = project->priv->selection; l; l = l->next)
+ {
+ if (GTK_IS_WIDGET (l->data))
+ gtk_widget_queue_draw (GTK_WIDGET (l->data));
+ }
g_list_free (project->priv->selection);
project->priv->selection = NULL;
@@ -3363,8 +3370,6 @@ glade_project_selection_remove (GladeProject * project,
if (glade_project_is_selected (project, object))
{
- if (GTK_IS_WIDGET (object))
- glade_util_remove_selection (GTK_WIDGET (object));
project->priv->selection =
g_list_remove (project->priv->selection, object);
if (project->priv->selection == NULL)
@@ -3398,7 +3403,7 @@ glade_project_selection_add (GladeProject * project,
gboolean toggle_has_selection = (project->priv->selection == NULL);
if (GTK_IS_WIDGET (object))
- glade_util_add_selection (GTK_WIDGET (object));
+ gtk_widget_queue_draw (GTK_WIDGET (object));
project->priv->selection =
g_list_prepend (project->priv->selection, object);
@@ -3428,9 +3433,7 @@ glade_project_selection_set (GladeProject * project,
{
g_return_if_fail (GLADE_IS_PROJECT (project));
g_return_if_fail (G_IS_OBJECT (object));
-
- if (!glade_project_has_object (project, object))
- return;
+ g_return_if_fail (glade_project_has_object (project, object));
if (glade_project_is_selected (project, object) == FALSE ||
g_list_length (project->priv->selection) != 1)
diff --git a/gladeui/glade-utils.c b/gladeui/glade-utils.c
index 6017b0c..019e12f 100644
--- a/gladeui/glade-utils.c
+++ b/gladeui/glade-utils.c
@@ -57,10 +57,6 @@
#define GLADE_UTIL_COPY_BUFFSIZE 1024
-/* List of widgets that have selection
- */
-static GList *glade_util_selection = NULL;
-
/**
* glade_util_compose_get_type_func:
* @name:
@@ -613,114 +609,32 @@ glade_util_draw_nodes (cairo_t * cr, GdkColor * color,
void
glade_util_draw_selection_nodes (GtkWidget * widget, cairo_t * cr)
{
+ GladeWidget *gwidget;
+ GladeProject *project;
GdkColor *color;
+ GtkAllocation allocation;
g_return_if_fail (GTK_IS_WIDGET (widget));
-
- cairo_save (cr);
-
- color = &(gtk_widget_get_style (widget)->black);
-
- if (g_list_find (glade_util_selection, widget))
- {
- GtkAllocation allocation;
-
- gtk_widget_get_allocation (widget, &allocation);
- glade_util_draw_nodes (cr, color,
- 0, 0, allocation.width, allocation.height);
- }
-
- cairo_restore (cr);
-}
-
-/**
- * glade_util_add_selection:
- * @widget: a #GtkWidget
- *
- * Add visual selection to this GtkWidget
- */
-void
-glade_util_add_selection (GtkWidget * widget)
-{
- g_return_if_fail (GTK_IS_WIDGET (widget));
- if (glade_util_has_selection (widget))
+
+ gwidget = glade_widget_get_from_gobject (widget);
+ if (!gwidget)
return;
- glade_util_selection = g_list_prepend (glade_util_selection, widget);
- gtk_widget_queue_draw (widget);
-}
-
-/**
- * glade_util_remove_selection:
- * @widget: a #GtkWidget
- *
- * Remove visual selection from this GtkWidget
- */
-void
-glade_util_remove_selection (GtkWidget * widget)
-{
- GtkWidget *parent;
+ project = glade_widget_get_project (gwidget);
+ g_return_if_fail (GLADE_IS_PROJECT (project));
- g_return_if_fail (GTK_IS_WIDGET (widget));
- if (!glade_util_has_selection (widget))
+ if (!glade_project_is_selected (project, G_OBJECT (widget)))
return;
- glade_util_selection = g_list_remove (glade_util_selection, widget);
-
- /* We redraw the parent, since the selection rectangle may not be
- cleared if we just redraw the widget itself. */
- parent = gtk_widget_get_parent (widget);
- if (parent)
- gtk_widget_queue_draw (parent);
- gtk_widget_queue_draw (widget);
-}
-
-/**
- * glade_util_clear_selection:
- *
- * Clear all visual selections
- */
-void
-glade_util_clear_selection (void)
-{
- GtkWidget *widget;
- GtkWidget *parent;
- GList *list;
-
- for (list = glade_util_selection; list && list->data; list = list->next)
- {
- widget = list->data;
- parent = gtk_widget_get_parent (widget);
+ cairo_save (cr);
- if (parent)
- gtk_widget_queue_draw (parent);
- gtk_widget_queue_draw (widget);
- }
- glade_util_selection = (g_list_free (glade_util_selection), NULL);
-}
+ color = &(gtk_widget_get_style (widget)->black);
-/**
- * glade_util_has_selection:
- * @widget: a #GtkWidget
- *
- * Returns: %TRUE if @widget has visual selection, %FALSE otherwise
- */
-gboolean
-glade_util_has_selection (GtkWidget * widget)
-{
- g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return g_list_find (glade_util_selection, widget) != NULL;
-}
+ gtk_widget_get_allocation (widget, &allocation);
+ glade_util_draw_nodes (cr, color,
+ 0, 0, allocation.width, allocation.height);
-/**
- * glade_util_get_selectoin:
- *
- * Returns: The list of selected #GtkWidgets
- */
-GList *
-glade_util_get_selection ()
-{
- return glade_util_selection;
+ cairo_restore (cr);
}
/*
diff --git a/gladeui/glade-utils.h b/gladeui/glade-utils.h
index 8ac854a..5e8baec 100644
--- a/gladeui/glade-utils.h
+++ b/gladeui/glade-utils.h
@@ -66,13 +66,6 @@ GValue *glade_utils_value_from_string (GType type,
GladeWidget *widget);
gchar *glade_utils_string_from_value (const GValue *value);
-/* Selection (TODO, Move to GladeProject) */
-void glade_util_add_selection (GtkWidget *widget);
-void glade_util_remove_selection (GtkWidget *widget);
-gboolean glade_util_has_selection (GtkWidget *widget);
-void glade_util_clear_selection (void);
-GList *glade_util_get_selection (void);
-
/* Devhelp */
gboolean glade_util_have_devhelp (void);
GtkWidget *glade_util_get_devhelp_icon (GtkIconSize size);
diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c
index 927ea4e..13fd0e0 100644
--- a/gladeui/glade-widget.c
+++ b/gladeui/glade-widget.c
@@ -428,7 +428,6 @@ glade_widget_button_press_event_impl (GladeWidget * gwidget,
else if (glade_project_is_selected (gwidget->priv->project,
gwidget->priv->object) == FALSE)
{
- glade_util_clear_selection ();
glade_project_selection_set (gwidget->priv->project,
gwidget->priv->object, TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]