Commit 3828d64f authored by Tristan Van Berkom's avatar Tristan Van Berkom
Browse files

* gladeui/glade-clipboard.[ch], gladeui/glade-project.c:

	Privatized GladeClipboard members.
parent cd730730
......@@ -9,6 +9,9 @@
gladeui/glade-signal-editor.c, gladeui/glade-command.c: Made GladeSignal an
opaque structure with accessors.
* gladeui/glade-clipboard.[ch], gladeui/glade-project.c:
Privatized GladeClipboard members.
2011-01-04 Johannes Schmid <jhs@gnome.org>
* data/gladeui-2.0.pc.in: Fix include paths and library name
......
......@@ -40,12 +40,20 @@
#include "glade-placeholder.h"
#include "glade-project.h"
struct _GladeClipboardPrivate
{
GList *widgets; /* A list of GladeWidget's on the clipboard */
gboolean has_selection; /* TRUE if clipboard has selection */
};
enum
{
PROP_0,
PROP_HAS_SELECTION
};
G_DEFINE_TYPE (GladeClipboard, glade_clipboard, G_TYPE_OBJECT);
static void
glade_project_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec)
......@@ -55,7 +63,7 @@ glade_project_get_property (GObject * object,
switch (prop_id)
{
case PROP_HAS_SELECTION:
g_value_set_boolean (value, clipboard->has_selection);
g_value_set_boolean (value, clipboard->priv->has_selection);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......@@ -79,49 +87,29 @@ glade_clipboard_class_init (GladeClipboardClass * klass)
"Whether clipboard has a selection of items to paste",
FALSE,
G_PARAM_READABLE));
g_type_class_add_private (klass, sizeof (GladeClipboardPrivate));
}
static void
glade_clipboard_init (GladeClipboard * clipboard)
{
clipboard->widgets = NULL;
clipboard->has_selection = FALSE;
}
GType
glade_clipboard_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo info = {
sizeof (GladeClipboardClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) glade_clipboard_class_init,
(GClassFinalizeFunc) NULL,
NULL,
sizeof (GladeClipboard),
0,
(GInstanceInitFunc) glade_clipboard_init
};
type = g_type_register_static (G_TYPE_OBJECT, "GladeClipboard", &info, 0);
}
clipboard->priv =
G_TYPE_INSTANCE_GET_PRIVATE (clipboard,
GLADE_TYPE_CLIPBOARD,
GladeClipboardPrivate);
return type;
clipboard->priv->widgets = NULL;
clipboard->priv->has_selection = FALSE;
}
static void
glade_clipboard_set_has_selection (GladeClipboard * clipboard,
gboolean has_selection)
{
g_assert (GLADE_IS_CLIPBOARD (clipboard));
if (clipboard->has_selection != has_selection)
if (clipboard->priv->has_selection != has_selection)
{
clipboard->has_selection = has_selection;
clipboard->priv->has_selection = has_selection;
g_object_notify (G_OBJECT (clipboard), "has-selection");
}
......@@ -136,11 +124,19 @@ glade_clipboard_set_has_selection (GladeClipboard * clipboard,
gboolean
glade_clipboard_get_has_selection (GladeClipboard * clipboard)
{
g_assert (GLADE_IS_CLIPBOARD (clipboard));
g_return_val_if_fail (GLADE_IS_CLIPBOARD (clipboard), FALSE);
return clipboard->has_selection;
return clipboard->priv->has_selection;
}
GList *
glade_clipboard_widgets (GladeClipboard *clipboard)
{
g_return_val_if_fail (GLADE_IS_CLIPBOARD (clipboard), NULL);
return clipboard->priv->widgets;
}
/**
* glade_clipboard_new:
......@@ -167,6 +163,8 @@ glade_clipboard_add (GladeClipboard * clipboard, GList * widgets)
GladeWidget *widget;
GList *list;
g_return_if_fail (GLADE_IS_CLIPBOARD (clipboard));
glade_clipboard_clear (clipboard);
/*
......@@ -175,8 +173,8 @@ glade_clipboard_add (GladeClipboard * clipboard, GList * widgets)
for (list = widgets; list && list->data; list = list->next)
{
widget = list->data;
clipboard->widgets =
g_list_prepend (clipboard->widgets, g_object_ref_sink (G_OBJECT (widget)));
clipboard->priv->widgets =
g_list_prepend (clipboard->priv->widgets, g_object_ref_sink (G_OBJECT (widget)));
}
glade_clipboard_set_has_selection (clipboard, TRUE);
......@@ -194,15 +192,17 @@ glade_clipboard_clear (GladeClipboard * clipboard)
GladeWidget *widget;
GList *list;
for (list = clipboard->widgets; list && list->data; list = list->next)
g_return_if_fail (GLADE_IS_CLIPBOARD (clipboard));
for (list = clipboard->priv->widgets; list && list->data; list = list->next)
{
widget = list->data;
g_object_unref (G_OBJECT (widget));
}
clipboard->widgets =
(g_list_free (clipboard->widgets), NULL);
clipboard->priv->widgets =
(g_list_free (clipboard->priv->widgets), NULL);
glade_clipboard_set_has_selection (clipboard, FALSE);
}
......@@ -9,33 +9,37 @@ G_BEGIN_DECLS
#define GLADE_CLIPBOARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_CLIPBOARD, GladeClipboard))
#define GLADE_IS_CLIPBOARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_CLIPBOARD))
typedef struct _GladeClipboard GladeClipboard;
typedef struct _GladeClipboardClass GladeClipboardClass;
typedef struct _GladeClipboard GladeClipboard;
typedef struct _GladeClipboardClass GladeClipboardClass;
typedef struct _GladeClipboardPrivate GladeClipboardPrivate;
struct _GladeClipboard
{
GObject parent_instance;
GObject parent_instance;
GList *widgets; /* A list of GladeWidget's on the clipboard */
gboolean has_selection; /* TRUE if clipboard has selection */
GladeClipboardPrivate *priv;
};
struct _GladeClipboardClass
{
GObjectClass parent_class;
GObjectClass parent_class;
void (* glade_reserved1) (void);
void (* glade_reserved2) (void);
void (* glade_reserved3) (void);
void (* glade_reserved4) (void);
};
GType glade_clipboard_get_type (void);
GladeClipboard *glade_clipboard_new (void);
void glade_clipboard_add (GladeClipboard *clipboard,
GList *widgets);
void glade_clipboard_clear (GladeClipboard *clipboard);
gboolean glade_clipboard_get_has_selection (GladeClipboard *clipboard);
gboolean glade_clipboard_get_has_selection(GladeClipboard *clipboard);
GList *glade_clipboard_widgets (GladeClipboard *clipboard);
G_END_DECLS
......
......@@ -330,7 +330,7 @@ glade_project_dispose (GObject * object)
glade_project_remove_object (project, project->priv->tree->data);
while (project->priv->objects)
glade_project_remove_object (project, project->priv->objects->data);
glade_project_remove_object (project, project->priv->objects->data);
g_assert (project->priv->tree == NULL);
g_assert (project->priv->objects == NULL);
......@@ -5036,11 +5036,11 @@ glade_project_command_paste (GladeProject *project,
parent = list ? glade_widget_get_from_gobject (list->data) :
(placeholder) ? glade_placeholder_get_parent (placeholder) : NULL;
widget = clipboard->widgets ? clipboard->widgets->data : NULL;
widget = glade_clipboard_widgets (clipboard) ? glade_clipboard_widgets (clipboard)->data : NULL;
/* Ignore parent argument if we are pasting a toplevel
*/
if (g_list_length (clipboard->widgets) == 1 &&
if (g_list_length (glade_clipboard_widgets (clipboard)) == 1 &&
widget && GWA_IS_TOPLEVEL (glade_widget_get_adaptor (widget)))
parent = NULL;
......@@ -5073,7 +5073,7 @@ glade_project_command_paste (GladeProject *project,
return;
/* Check if we have anything to paste */
if (g_list_length (clipboard->widgets) == 0)
if (g_list_length (glade_clipboard_widgets (clipboard)) == 0)
{
glade_util_ui_message (glade_app_get_window (), GLADE_UI_INFO, NULL,
_("No widget on the clipboard"));
......@@ -5082,7 +5082,7 @@ glade_project_command_paste (GladeProject *project,
}
/* Check that we have compatible heirarchies */
for (list = clipboard->widgets; list && list->data; list = list->next)
for (list = glade_clipboard_widgets (clipboard); list && list->data; list = list->next)
{
widget = list->data;
......@@ -5102,7 +5102,7 @@ glade_project_command_paste (GladeProject *project,
*/
if (GTK_IS_WIDGET (glade_widget_get_object (widget)) &&
parent && !GWA_USE_PLACEHOLDERS (glade_widget_get_adaptor (parent)) &&
g_list_length (clipboard->widgets) != 1)
g_list_length (glade_clipboard_widgets (clipboard)) != 1)
{
glade_util_ui_message (glade_app_get_window (),
GLADE_UI_INFO, NULL,
......@@ -5123,7 +5123,7 @@ glade_project_command_paste (GladeProject *project,
return;
}
glade_command_paste (clipboard->widgets, parent, placeholder, project);
glade_command_paste (glade_clipboard_widgets (clipboard), parent, placeholder, project);
}
void
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment