mirror of
https://gitlab.gnome.org/GNOME/glade.git
synced 2025-09-21 00:02:57 -04:00
I have just come back ;-)
First task: Commit the cut/copy/paste implementation by Archit Baweja Next tasks: Finish glade2!!! ;-) 2001-12-24 Archit Baweja <bighead@users.sourceforge.net> * src/glade-placeholder.c (glade_placeholder_on_button_press_event): on right-click, do PASTE. * src/glade-widget.c (glade_widget_cut): implemented. (glade_widget_copy): likewise. * src/glade-clipboard.[ch]: new files added. * src/glade-clipboard-view.[ch]: new files added.
This commit is contained in:
parent
4c0edb5984
commit
5a285e0b25
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
||||
2001-12-24 Archit Baweja <bighead@users.sourceforge.net>
|
||||
|
||||
* src/glade-placeholder.c (glade_placeholder_on_button_press_event):
|
||||
on right-click, do PASTE.
|
||||
|
||||
* src/glade-widget.c (glade_widget_cut): implemented.
|
||||
(glade_widget_copy): likewise.
|
||||
|
||||
* src/glade-clipboard.[ch]: new files added.
|
||||
|
||||
* src/glade-clipboard-view.[ch]: new files added.
|
||||
|
||||
2002-01-07 Zbigniew Chyla <cyba@gnome.pl>
|
||||
|
||||
* configure.in (ALL_LINGUAS): Added pl.
|
||||
|
@ -42,7 +42,9 @@ glade2_SOURCES = \
|
||||
glade-utils.c \
|
||||
glade-signal.c \
|
||||
glade-packing.c \
|
||||
glade-signal-editor.c
|
||||
glade-signal-editor.c \
|
||||
glade-clipboard.c \
|
||||
glade-clipboard-view.c
|
||||
|
||||
noinst_HEADERS = \
|
||||
glade.h \
|
||||
@ -68,4 +70,6 @@ noinst_HEADERS = \
|
||||
glade-utils.h \
|
||||
glade-signal.h \
|
||||
glade-packing.h \
|
||||
glade-xml-utils.h
|
||||
glade-xml-utils.h \
|
||||
glade-clipboard.h \
|
||||
glade-clipboard-view.h
|
||||
|
248
src/glade-clipboard-view.c
Normal file
248
src/glade-clipboard-view.c
Normal file
@ -0,0 +1,248 @@
|
||||
/*
|
||||
* glade-clipboard-view.c - The View for the Clipboard.
|
||||
*
|
||||
* Copyright (C) 2001 The GNOME Foundation.
|
||||
*
|
||||
* Author(s):
|
||||
* Archit Baweja <bighead@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
* USA.
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include "glade.h"
|
||||
#include "glade-clipboard.h"
|
||||
#include "glade-clipboard-view.h"
|
||||
#include "glade-widget.h"
|
||||
#include "glade-widget-class.h"
|
||||
#include "glade-project-window.h"
|
||||
|
||||
static void
|
||||
glade_clipboard_view_selection_changed_cb (GtkTreeSelection * sel,
|
||||
GladeClipboardView * view)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GladeWidget *widget;
|
||||
GtkTreeModel *model;
|
||||
|
||||
model = GTK_TREE_MODEL (view->model);
|
||||
gtk_tree_selection_get_selected (sel, &model, &iter);
|
||||
gtk_tree_model_get (model, &iter, 0, &widget, -1);
|
||||
|
||||
if (widget)
|
||||
view->clipboard->curr = widget;
|
||||
}
|
||||
|
||||
static void
|
||||
glade_clipboard_view_cell_function (GtkTreeViewColumn * tree_column,
|
||||
GtkCellRenderer * cell,
|
||||
GtkTreeModel * tree_model,
|
||||
GtkTreeIter * iter, gpointer data)
|
||||
{
|
||||
GladeWidget *widget;
|
||||
|
||||
gtk_tree_model_get (tree_model, iter, 0, &widget, -1);
|
||||
|
||||
g_return_if_fail (GLADE_IS_WIDGET (widget));
|
||||
g_return_if_fail (widget->name != NULL);
|
||||
|
||||
g_object_set (G_OBJECT (cell), "text", widget->name, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_clipboard_view_populate_model_real (GtkTreeStore * model,
|
||||
GList * widgets,
|
||||
GtkTreeIter * parent_iter,
|
||||
gboolean add_childs)
|
||||
{
|
||||
GladeWidget *widget;
|
||||
GList *list;
|
||||
GtkTreeIter iter;
|
||||
GtkTreeIter *copy = NULL;
|
||||
|
||||
list = g_list_copy (widgets);
|
||||
for (; list != NULL; list = list->next) {
|
||||
widget = list->data;
|
||||
gtk_tree_store_append (model, &iter, parent_iter);
|
||||
gtk_tree_store_set (model, &iter, 0, widget, -1);
|
||||
if (add_childs && widget->children != NULL) {
|
||||
copy = gtk_tree_iter_copy (&iter);
|
||||
glade_clipboard_view_populate_model_real (model,
|
||||
widget->children,
|
||||
copy, TRUE);
|
||||
gtk_tree_iter_free (copy);
|
||||
}
|
||||
}
|
||||
g_list_free (list);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_clipboard_view_populate_model (GladeClipboardView * view)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
view->model = gtk_tree_store_new (1, G_TYPE_STRING);
|
||||
list = GLADE_CLIPBOARD (view->clipboard)->widgets;
|
||||
|
||||
/* add the widgets and recurse */
|
||||
glade_clipboard_view_populate_model_real (view->model, list,
|
||||
NULL, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_clipboard_view_create_tree_view (GladeClipboardView * view)
|
||||
{
|
||||
GtkTreeSelection *sel;
|
||||
GtkCellRenderer *cell;
|
||||
GtkTreeViewColumn *col;
|
||||
|
||||
view->widget =
|
||||
gtk_tree_view_new_with_model (GTK_TREE_MODEL (view->model));
|
||||
|
||||
cell = gtk_cell_renderer_text_new ();
|
||||
col =
|
||||
gtk_tree_view_column_new_with_attributes (_("Widget"), cell,
|
||||
NULL);
|
||||
gtk_tree_view_column_set_cell_data_func (col, cell,
|
||||
glade_clipboard_view_cell_function,
|
||||
NULL, NULL);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (view->widget), col);
|
||||
|
||||
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (view->widget));
|
||||
g_signal_connect_data (G_OBJECT (sel), "changed",
|
||||
glade_clipboard_view_selection_changed_cb,
|
||||
view, NULL, 0);
|
||||
|
||||
gtk_widget_set_usize (view->widget, 272, 130);
|
||||
gtk_widget_show (view->widget);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_clipboard_view_construct (GladeClipboardView * view)
|
||||
{
|
||||
GtkWidget *scrolled_window;
|
||||
|
||||
glade_clipboard_view_populate_model (view);
|
||||
glade_clipboard_view_create_tree_view (view);
|
||||
|
||||
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_widget_set_usize (scrolled_window, 272, 130);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW
|
||||
(scrolled_window),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_widget_set_usize (scrolled_window, 272, 130);
|
||||
gtk_container_add (GTK_CONTAINER (scrolled_window), view->widget);
|
||||
gtk_container_add (GTK_CONTAINER (view), scrolled_window);
|
||||
gtk_widget_show (scrolled_window);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
glade_clipboard_view_class_init (GladeClipboardViewClass * klass)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
glade_clipboard_view_init (GladeClipboardView * view)
|
||||
{
|
||||
view->widget = NULL;
|
||||
view->clipboard = NULL;
|
||||
view->model = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_clipboard_view_get_type:
|
||||
*
|
||||
* Creates the typecode for the GladeClipboardView Widget type.
|
||||
*
|
||||
* Return value: the typecode for the GladeClipboardView widget type.
|
||||
**/
|
||||
GtkType
|
||||
glade_clipboard_view_get_type ()
|
||||
{
|
||||
static GtkType type = 0;
|
||||
|
||||
if (!type) {
|
||||
static const GtkTypeInfo info = {
|
||||
"GladeClipboardView",
|
||||
sizeof (GladeClipboardView),
|
||||
sizeof (GladeClipboardViewClass),
|
||||
(GtkClassInitFunc) glade_clipboard_view_class_init,
|
||||
(GtkObjectInitFunc) glade_clipboard_view_init,
|
||||
/* reserved 1 */ NULL,
|
||||
/* reserved 2 */ NULL,
|
||||
(GtkClassInitFunc) NULL
|
||||
};
|
||||
|
||||
type = gtk_type_unique (gtk_window_get_type (), &info);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_clipboard_view_new:
|
||||
*
|
||||
* Create a new #GladeClipboardView widget.
|
||||
*
|
||||
* Return Value: a #GtkWidget.
|
||||
**/
|
||||
GtkWidget *
|
||||
glade_clipboard_view_new (GladeClipboard * clipboard)
|
||||
{
|
||||
GladeClipboardView *view;
|
||||
|
||||
g_return_val_if_fail (clipboard != NULL, NULL);
|
||||
|
||||
view = gtk_type_new (glade_clipboard_view_get_type ());
|
||||
view->clipboard = clipboard;
|
||||
glade_clipboard_view_construct (view);
|
||||
|
||||
return GTK_WIDGET (view);
|
||||
}
|
||||
|
||||
void
|
||||
glade_clipboard_view_add (GladeClipboardView * view, GladeWidget * widget)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
|
||||
g_return_if_fail (GLADE_IS_CLIPBOARD_VIEW (view));
|
||||
g_return_if_fail (GLADE_IS_WIDGET (widget));
|
||||
|
||||
gtk_tree_store_append (view->model, &iter, NULL);
|
||||
gtk_tree_store_set (view->model, &iter, 0, widget, -1);
|
||||
}
|
||||
|
||||
void
|
||||
glade_clipboard_view_remove (GladeClipboardView * view,
|
||||
GladeWidget * widget)
|
||||
{
|
||||
GtkTreeSelection *sel;
|
||||
GtkTreeIter iter;
|
||||
GtkTreeModel *model;
|
||||
|
||||
g_return_if_fail (GLADE_IS_CLIPBOARD_VIEW (view));
|
||||
g_return_if_fail (GLADE_IS_WIDGET (widget));
|
||||
|
||||
model = gtk_tree_view_get_model (GTK_TREE_VIEW (view->widget));
|
||||
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (view->widget));
|
||||
gtk_tree_selection_get_selected (sel, &model, &iter);
|
||||
gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
|
||||
}
|
32
src/glade-clipboard-view.h
Normal file
32
src/glade-clipboard-view.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef __GLADE_CLIPBOARD_VIEW_H__
|
||||
#define __GLADE_CLIPBOARD_VIEW_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
#define GLADE_CLIPBOARD_VIEW(obj) (GTK_CHECK_CAST (obj, glade_clipboard_view_get_type (), GladeClipboardView))
|
||||
#define GLADE_CLIPBOARD_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST (klass, glade_clipboard_view_get_type (), GladeClipboardViewClass))
|
||||
#define GLADE_IS_CLIPBOARD_VIEW(obj) (GTK_CHECK_TYPE (obj, glade_clipboard_view_get_type ()))
|
||||
typedef struct _GladeClipboardView GladeClipboardView;
|
||||
typedef struct _GladeClipboardViewClass GladeClipboardViewClass;
|
||||
|
||||
struct _GladeClipboardView {
|
||||
GtkWindow __parent__;
|
||||
|
||||
GtkWidget *widget; /* The GtkTreeView widget */
|
||||
GtkTreeStore *model; /* The GtkTreeStore model for the View */
|
||||
GladeClipboard *clipboard; /* The Clipboard for which this is a view */
|
||||
};
|
||||
|
||||
struct _GladeClipboardViewClass {
|
||||
GtkWindowClass __parent__;
|
||||
};
|
||||
|
||||
GtkType glade_clipboard_view_get_type ();
|
||||
GtkWidget *glade_clipboard_view_new (GladeClipboard * clipboard);
|
||||
|
||||
void glade_clipboard_view_add (GladeClipboardView * view,
|
||||
GladeWidget * widget);
|
||||
void glade_clipboard_view_remove (GladeClipboardView * view,
|
||||
GladeWidget * widget);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* __GLADE_CLIPBOARD_VIEW_H__ */
|
298
src/glade-clipboard.c
Normal file
298
src/glade-clipboard.c
Normal file
@ -0,0 +1,298 @@
|
||||
/*
|
||||
* glade-clipboard.c - An object for handling Cut/Copy/Paste.
|
||||
*
|
||||
* Copyright (C) 2001 The GNOME Foundation.
|
||||
*
|
||||
* Author(s):
|
||||
* Archit Baweja <bighead@crosswinds.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
* USA.
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "glade.h"
|
||||
#include "glade-clipboard-view.h"
|
||||
#include "glade-clipboard.h"
|
||||
#include "glade-project-window.h"
|
||||
#include "glade-widget.h"
|
||||
#include "glade-widget-class.h"
|
||||
#include "glade-placeholder.h"
|
||||
#include "glade-project.h"
|
||||
|
||||
static void
|
||||
glade_clipboard_class_init (GladeClipboardClass * klass)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
glade_clipboard_init (GladeClipboard * clipboard)
|
||||
{
|
||||
clipboard->widgets = NULL;
|
||||
clipboard->view = NULL;
|
||||
clipboard->curr = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_clipboard_get_type:
|
||||
*
|
||||
* Creates the typecode for the GladeClipboard object type.
|
||||
*
|
||||
* Return value: the typecode for the GladeClipboard object type.
|
||||
**/
|
||||
GType
|
||||
glade_clipboard_get_type ()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_clipboard_new:
|
||||
* @:
|
||||
*
|
||||
* Create a new @GladeClipboard object.
|
||||
*
|
||||
* Return Value: a @GladeClipboard object.
|
||||
**/
|
||||
GladeClipboard *
|
||||
glade_clipboard_new ()
|
||||
{
|
||||
return GLADE_CLIPBOARD (g_object_new (GLADE_TYPE_CLIPBOARD, NULL));
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_clipboard_add:
|
||||
* @clipboard:
|
||||
* @widget:
|
||||
*
|
||||
* Add a GladeWidget to the Clipboard. Basically has stuff common to
|
||||
* Cut/Copy commands.
|
||||
**/
|
||||
static void
|
||||
glade_clipboard_add (GladeClipboard * clipboard, GladeWidget * widget)
|
||||
{
|
||||
/*
|
||||
* Add the GladeWidget to the list of children. And set the
|
||||
* latest addition, to currently selected widget in the clipboard.
|
||||
*/
|
||||
clipboard->widgets = g_list_prepend (clipboard->widgets, widget);
|
||||
clipboard->curr = widget;
|
||||
|
||||
/*
|
||||
* If there is view present, update it.
|
||||
*/
|
||||
if (clipboard->view)
|
||||
glade_clipboard_view_add (clipboard->view, widget);
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_clipboard_remove:
|
||||
* @clipboard:
|
||||
* @widget:
|
||||
*
|
||||
* Remove a GladeWidget from the Clipboard
|
||||
**/
|
||||
static void
|
||||
glade_clipboard_remove (GladeClipboard * clipboard, GladeWidget * widget)
|
||||
{
|
||||
clipboard->widgets = g_list_remove (clipboard->widgets, widget);
|
||||
|
||||
/*
|
||||
* If there is a view present, update it.
|
||||
*/
|
||||
if (clipboard->view)
|
||||
glade_clipboard_view_remove (clipboard->view, widget);
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_clipboard_cut:
|
||||
* @clipboard:
|
||||
* @widget:
|
||||
*
|
||||
* Cut a GladeWidget onto the Clipboard.
|
||||
**/
|
||||
void
|
||||
glade_clipboard_cut (GladeClipboard * clipboard, GladeWidget * widget)
|
||||
{
|
||||
GladeWidget *parent;
|
||||
|
||||
g_return_if_fail (GLADE_IS_CLIPBOARD (clipboard));
|
||||
g_return_if_fail (GLADE_IS_WIDGET (widget));
|
||||
|
||||
parent = widget->parent;
|
||||
|
||||
glade_project_remove_widget (widget);
|
||||
|
||||
/*
|
||||
* If its not a toplevel widget, we remove it from its container.
|
||||
* This is all GladeWidget stuff.
|
||||
*/
|
||||
if (parent) {
|
||||
GladePlaceholder *placeholder;
|
||||
|
||||
gtk_widget_ref (widget->widget);
|
||||
placeholder = glade_placeholder_new (parent);
|
||||
if (parent->class->placeholder_replace)
|
||||
parent->class->placeholder_replace (widget->widget,
|
||||
GTK_WIDGET (placeholder),
|
||||
parent->widget);
|
||||
gtk_widget_unref (widget->widget);
|
||||
|
||||
/* Remove it from the parent's child list */
|
||||
parent->children = g_list_remove (parent->children,
|
||||
widget);
|
||||
}
|
||||
|
||||
gtk_widget_hide (widget->widget);
|
||||
|
||||
glade_clipboard_add (clipboard, widget);
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_clipboard_copy:
|
||||
* @clipboard:
|
||||
* @widget:
|
||||
*
|
||||
* Copy a GladeWidget onto the Clipboard.
|
||||
**/
|
||||
void
|
||||
glade_clipboard_copy (GladeClipboard * clipboard, GladeWidget * widget)
|
||||
{
|
||||
GladeWidget *copy;
|
||||
|
||||
g_return_if_fail (GLADE_IS_CLIPBOARD (clipboard));
|
||||
g_return_if_fail (GLADE_IS_WIDGET (widget));
|
||||
|
||||
/*
|
||||
* FIXME: not sure if this is the right way to copy a struct in C.
|
||||
* should work though.
|
||||
*/
|
||||
copy = g_new0 (GladeWidget, 1);
|
||||
*copy = *widget;
|
||||
|
||||
glade_clipboard_add (clipboard, copy);
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_clipboard_paste:
|
||||
* @clipboard:
|
||||
* @parent:
|
||||
*
|
||||
* Paste a GladeWidget from the Clipboard.
|
||||
**/
|
||||
void
|
||||
glade_clipboard_paste (GladeClipboard * clipboard,
|
||||
GladePlaceholder * placeholder)
|
||||
{
|
||||
GladeProjectWindow *gpw;
|
||||
GladeWidget *widget;
|
||||
GladeWidget *parent;
|
||||
GladeProject *project;
|
||||
|
||||
g_return_if_fail (GLADE_IS_CLIPBOARD (clipboard));
|
||||
|
||||
gpw = glade_project_window_get ();
|
||||
widget = clipboard->curr;
|
||||
project = glade_project_window_get_project ();
|
||||
parent = glade_placeholder_get_parent (placeholder);
|
||||
|
||||
if (!widget)
|
||||
return;
|
||||
|
||||
widget->name = glade_widget_new_name (project, widget->class);
|
||||
widget->parent = parent;
|
||||
glade_packing_add_properties (widget);
|
||||
glade_widget_create_gtk_widget (widget);
|
||||
glade_project_add_widget (project, widget);
|
||||
|
||||
if (parent)
|
||||
parent->children =
|
||||
g_list_prepend (parent->children, widget);
|
||||
|
||||
glade_widget_set_contents (widget);
|
||||
glade_widget_connect_signals (widget);
|
||||
glade_placeholder_replace (placeholder, parent, widget);
|
||||
glade_widget_set_default_packing_options (widget);
|
||||
glade_project_selection_set (widget, TRUE);
|
||||
|
||||
/*
|
||||
* This damned 'if' statement caused a 1 month delay.
|
||||
*/
|
||||
if (GTK_IS_WIDGET (widget->widget))
|
||||
gtk_widget_show (GTK_WIDGET (widget->widget));
|
||||
|
||||
/*
|
||||
* Finally remove widget from clipboard.
|
||||
* FIXME: should this be done? I mean should we leave a copy on the
|
||||
* clipboard anyway?
|
||||
*/
|
||||
glade_clipboard_remove (clipboard, widget);
|
||||
}
|
||||
|
||||
void
|
||||
glade_clipboard_create (GladeProjectWindow * gpw)
|
||||
{
|
||||
g_return_if_fail (gpw != NULL);
|
||||
|
||||
if (gpw->clipboard == NULL) {
|
||||
GladeClipboard *clipboard;
|
||||
|
||||
clipboard = glade_clipboard_new ();
|
||||
gpw->clipboard = clipboard;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
glade_clipboard_show_view (GladeProjectWindow * gpw)
|
||||
{
|
||||
g_return_if_fail (gpw != NULL);
|
||||
|
||||
if (gpw->clipboard->view == NULL) {
|
||||
GtkWidget *view;
|
||||
|
||||
view = glade_clipboard_view_new (gpw->clipboard);
|
||||
gtk_window_set_title (GTK_WINDOW (view), _("Clipboard"));
|
||||
g_signal_connect_data (G_OBJECT (view), "delete_event",
|
||||
G_CALLBACK (gtk_widget_hide),
|
||||
view, NULL, 0);
|
||||
|
||||
gpw->clipboard->view = view;
|
||||
}
|
||||
|
||||
if (!GTK_WIDGET_VISIBLE (gpw->clipboard->view))
|
||||
gtk_widget_show (GTK_WIDGET (gpw->clipboard->view));
|
||||
}
|
43
src/glade-clipboard.h
Normal file
43
src/glade-clipboard.h
Normal file
@ -0,0 +1,43 @@
|
||||
#ifndef __GLADE_CLIPBOARD_H__
|
||||
#define __GLADE_CLIPBOARD_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
#define GLADE_TYPE_CLIPBOARD (glade_clipboard_get_type ())
|
||||
#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 _GladeClipboardClass GladeClipboardClass;
|
||||
|
||||
struct _GladeClipboard {
|
||||
GObject __parent__;
|
||||
|
||||
GList *widgets; /* A list of GladeWidget's on the clipboard */
|
||||
GladeWidget *curr; /* The currently selected GladeWidget in the
|
||||
Clipboard */
|
||||
|
||||
GtkWidget *view; /* see glade-clipboard-view.c */
|
||||
};
|
||||
|
||||
struct _GladeClipboardClass {
|
||||
GObjectClass __parent__;
|
||||
};
|
||||
|
||||
|
||||
GType glade_clipboard_get_type ();
|
||||
GladeClipboard *glade_clipboard_new ();
|
||||
|
||||
void glade_clipboard_add (GladeClipboard * clipboard,
|
||||
GladeWidget * widget);
|
||||
void glade_clipboard_remove (GladeClipboard * clipboard,
|
||||
GladeWidget * widget);
|
||||
void glade_clipboard_cut (GladeClipboard * clipboard,
|
||||
GladeWidget * widget);
|
||||
void glade_clipboard_copy (GladeClipboard * clipboard,
|
||||
GladeWidget * widget);
|
||||
void glade_clipboard_paste (GladeClipboard * clipboard,
|
||||
GladePlaceholder * placeholder);
|
||||
|
||||
void glade_clipboard_create (GladeProjectWindow * gpw);
|
||||
void glade_clipboard_show_view (GladeProjectWindow * gpw);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* __GLADE_CLIPBOARD_H__ */
|
@ -235,6 +235,18 @@ glade_placeholder_on_button_press_event (GladePlaceholder *placeholder, GdkEvent
|
||||
if (event->button == 1 && event->type == GDK_BUTTON_PRESS && gpw->add_class != NULL) {
|
||||
glade_placeholder_replace_widget (placeholder, gpw->add_class, project);
|
||||
glade_project_window_set_add_class (gpw, NULL);
|
||||
} else if (event->button == 3) {
|
||||
/*
|
||||
* If a right-click, do a PASTE from the clipboard.
|
||||
* FIXME: should show a menu.
|
||||
*/
|
||||
GladeProjectWindow *gpw;
|
||||
GladeClipboard *clipboard;
|
||||
|
||||
gpw = glade_project_window_get ();
|
||||
clipboard = gpw->clipboard;
|
||||
|
||||
glade_clipboard_paste (clipboard, placeholder);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "glade.h"
|
||||
#include "glade-palette.h"
|
||||
#include "glade-editor.h"
|
||||
#include "glade-clipboard.h"
|
||||
#include "glade-widget.h"
|
||||
#include "glade-widget-class.h"
|
||||
#include "glade-parameter.h"
|
||||
@ -46,7 +47,7 @@ static void gpw_quit_cb (void);
|
||||
static void gpw_show_palette_cb (void);
|
||||
static void gpw_show_editor_cb (void);
|
||||
static void gpw_show_widget_tree_cb (void);
|
||||
static void gpw_show_clipboard_cb (void) {};
|
||||
static void gpw_show_clipboard_cb (void);
|
||||
|
||||
static void gpw_undo_cb (void);
|
||||
static void gpw_redo_cb (void);
|
||||
@ -324,6 +325,7 @@ glade_project_window_new (GList *catalogs)
|
||||
glade_project_window = gpw;
|
||||
glade_palette_create (gpw);
|
||||
glade_editor_create (gpw);
|
||||
glade_clipboard_create (gpw);
|
||||
|
||||
return gpw;
|
||||
}
|
||||
@ -402,6 +404,14 @@ gpw_show_editor_cb (void)
|
||||
glade_editor_show (gpw);
|
||||
}
|
||||
|
||||
static void
|
||||
gpw_show_clipboard_cb (void)
|
||||
{
|
||||
GladeProjectWindow *gpw = glade_project_window_get ();
|
||||
|
||||
glade_clipboard_show_view (gpw);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_project_window_selection_changed_cb (GladeProject *project,
|
||||
GladeProjectWindow *gpw)
|
||||
|
@ -27,6 +27,7 @@ struct _GladeProjectWindow
|
||||
GtkWidget *widget_tree; /* The widget tree window*/
|
||||
GladePalette *palette; /* See glade-palette */
|
||||
GladeEditor *editor; /* See glade-editor */
|
||||
GladeClipboard *clipboard; /* See glade-clipboard */
|
||||
GladeProjectView *active_view; /* See glade-project-view */
|
||||
GList *catalogs; /* See glade-catalog */
|
||||
GladeWidgetClass *add_class; /* The GladeWidgetClass that we are about
|
||||
|
@ -1,10 +1,11 @@
|
||||
typedef struct _GladePaletteSection GladePaletteSection;
|
||||
|
||||
typedef struct _GladePalette GladePalette;
|
||||
typedef struct _GladePalette GladePalette;
|
||||
typedef struct _GladeEditor GladeEditor;
|
||||
typedef struct _GladeSignal GladeSignal;
|
||||
typedef struct _GladeSignalEditor GladeSignalEditor;
|
||||
typedef struct _GladeProject GladeProject;
|
||||
typedef struct _GladeClipboard GladeClipboard;
|
||||
|
||||
typedef struct _GladeWidget GladeWidget;
|
||||
typedef struct _GladeWidgetClass GladeWidgetClass;
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "glade-signal.h"
|
||||
#include "glade-gtk.h"
|
||||
#include "glade-packing.h"
|
||||
#include "glade-clipboard.h"
|
||||
|
||||
#define GLADE_WIDGET_SELECTION_NODE_SIZE 7
|
||||
|
||||
@ -548,7 +549,7 @@ glade_widget_connect_mouse_signals (GladeWidget *glade_widget)
|
||||
* "button1" text in it, or a label will have "label4". right after
|
||||
* it is created.
|
||||
**/
|
||||
static void
|
||||
void
|
||||
glade_widget_set_contents (GladeWidget *widget)
|
||||
{
|
||||
GladeProperty *property = NULL;
|
||||
@ -659,7 +660,7 @@ glade_widget_ugly_hack (gpointer data)
|
||||
}
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
gboolean
|
||||
glade_widget_create_gtk_widget (GladeWidget *glade_widget)
|
||||
{
|
||||
GladeWidgetClass *class;
|
||||
@ -716,7 +717,7 @@ glade_widget_create_gtk_widget (GladeWidget *glade_widget)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
glade_widget_connect_signals (GladeWidget *widget)
|
||||
{
|
||||
/* We can be a GtkObject. For example an adjustment. */
|
||||
@ -1052,19 +1053,35 @@ glade_widget_delete (GladeWidget *widget)
|
||||
void
|
||||
glade_widget_cut (GladeWidget *widget)
|
||||
{
|
||||
glade_implement_me ();
|
||||
GladeProjectWindow *gpw;
|
||||
GladeClipboard *clipboard;
|
||||
|
||||
gpw = glade_project_window_get ();
|
||||
clipboard = gpw->clipboard;
|
||||
|
||||
glade_clipboard_cut (clipboard, widget);
|
||||
}
|
||||
|
||||
void
|
||||
glade_widget_copy (GladeWidget *widget)
|
||||
{
|
||||
glade_implement_me ();
|
||||
GladeProjectWindow *gpw;
|
||||
GladeClipboard *clipboard;
|
||||
|
||||
gpw = glade_project_window_get ();
|
||||
clipboard = gpw->clipboard;
|
||||
|
||||
glade_clipboard_copy (clipboard, widget);
|
||||
}
|
||||
|
||||
void
|
||||
glade_widget_paste (GladeWidget *widget)
|
||||
{
|
||||
glade_implement_me ();
|
||||
/*
|
||||
* look in glade-placeholder.c (glade_placeholder_on_button_press_event
|
||||
* for the "paste" operation code.
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user