mirror of
https://gitlab.gnome.org/GNOME/glade.git
synced 2025-09-21 00:02:57 -04:00
implemented cut/copy/paste from the main window. -)
* implemented cut/copy/paste from the main window. * some other misc stuff. :-)
This commit is contained in:
parent
c6e6dfc322
commit
ee4a5d28f6
21
ChangeLog
21
ChangeLog
@ -1,3 +1,24 @@
|
||||
2002-04-29 Archit Baweja <bighead@users.sourceforge.net>
|
||||
|
||||
* src/glade-project-window.c
|
||||
(glade_project_window_selection_changed_cb): set gpw->active_widget.
|
||||
|
||||
2002-04-28 Archit Baweja <bighead@users.sourceforge.net>
|
||||
|
||||
* src/glade-project-window.c (gpw_copy_cb): implemented.
|
||||
(gpw_cut_cb, gpw_paste_cb): likewise.
|
||||
(gpw_save_cb): don't refresh title, on error.
|
||||
(gpw_save_as_cb): likewise.
|
||||
|
||||
* src/glade-utils.c (glade_util_ui_warn): new function.
|
||||
|
||||
* src/glade-clipboard.c (glade_clipboard_paste): support pasting of
|
||||
toplevel widgets.
|
||||
|
||||
* src/glade-placeholder.c (glade_placeholder_on_button_press_event):
|
||||
set active placeholder.
|
||||
(glade_placeholder_draw_selection_nodes): new function.
|
||||
|
||||
2002-04-27 Carlos Perello Marin <carlos@gnome-db.org>
|
||||
|
||||
* configure.in: Fixed the pixmap location.
|
||||
|
@ -223,8 +223,21 @@ glade_clipboard_paste (GladeClipboard * clipboard,
|
||||
|
||||
glade_widget_set_contents (widget);
|
||||
glade_widget_connect_signals (widget);
|
||||
glade_placeholder_replace (placeholder, parent, widget);
|
||||
glade_widget_set_default_packing_options (widget);
|
||||
|
||||
/*
|
||||
* Toplevel widgets are not packed into other containers :-)
|
||||
*/
|
||||
if (!GLADE_WIDGET_IS_TOPLEVEL (widget)) {
|
||||
/* Signal error, if placeholder not selected */
|
||||
if (!placeholder) {
|
||||
glade_util_ui_warn (_("Placeholder not selected!"));
|
||||
return;
|
||||
}
|
||||
|
||||
glade_placeholder_replace (placeholder, parent, widget);
|
||||
glade_widget_set_default_packing_options (widget);
|
||||
}
|
||||
|
||||
glade_widget_select (widget);
|
||||
glade_editor_select_widget (gpw->editor, widget);
|
||||
|
||||
|
@ -42,6 +42,8 @@
|
||||
#define GLADE_PLACEHOLDER_PARENT_DATA "GladePlaceholderParentData"
|
||||
#define GLADE_PLACEHOLDER_IS_DATA "GladeIsPlaceholderData"
|
||||
|
||||
#define GLADE_PLACEHOLDER_SELECTION_NODE_SIZE 7
|
||||
|
||||
static void
|
||||
glade_placeholder_replace_box (GtkWidget *current,
|
||||
GtkWidget *new,
|
||||
@ -227,6 +229,88 @@ glade_placeholder_add_methods_to_class (GladeWidgetClass *class)
|
||||
class->name);
|
||||
}
|
||||
|
||||
static GdkWindow*
|
||||
glade_placeholder_get_gdk_window (GladePlaceholder *placeholder,
|
||||
GtkWidget **paint_widget)
|
||||
{
|
||||
GtkWidget *parent = GTK_WIDGET (placeholder)->parent;
|
||||
|
||||
if (parent) {
|
||||
*paint_widget = parent;
|
||||
return parent->window;
|
||||
}
|
||||
|
||||
*paint_widget = GTK_WIDGET (placeholder);
|
||||
return GTK_WIDGET (placeholder)->window;
|
||||
}
|
||||
|
||||
static void
|
||||
glade_placeholder_draw_selection_nodes (GladePlaceholder *placeholder)
|
||||
{
|
||||
GtkWidget *widget, *paint_widget;
|
||||
GdkWindow *window;
|
||||
GdkGC *gc;
|
||||
gint x, y, w, h;
|
||||
gint width, height;
|
||||
|
||||
widget = GTK_WIDGET (placeholder);
|
||||
window = glade_placeholder_get_gdk_window (placeholder, &paint_widget);
|
||||
|
||||
if (widget->parent) {
|
||||
gtk_widget_translate_coordinates (widget, paint_widget,
|
||||
0, 0, &x, &y);
|
||||
w = widget->allocation.width;
|
||||
h = widget->allocation.height;
|
||||
} else {
|
||||
x = 0;
|
||||
y = 0;
|
||||
gdk_window_get_size (window, &w, &h);
|
||||
}
|
||||
|
||||
gc = paint_widget->style->black_gc;
|
||||
gdk_gc_set_subwindow (gc, GDK_INCLUDE_INFERIORS);
|
||||
|
||||
width = w;
|
||||
height = h;
|
||||
if (width > GLADE_PLACEHOLDER_SELECTION_NODE_SIZE
|
||||
&& height > GLADE_PLACEHOLDER_SELECTION_NODE_SIZE) {
|
||||
gdk_draw_rectangle (window, gc, TRUE, x, y,
|
||||
GLADE_PLACEHOLDER_SELECTION_NODE_SIZE,
|
||||
GLADE_PLACEHOLDER_SELECTION_NODE_SIZE);
|
||||
gdk_draw_rectangle (window, gc, TRUE, x,
|
||||
y + height - GLADE_PLACEHOLDER_SELECTION_NODE_SIZE,
|
||||
GLADE_PLACEHOLDER_SELECTION_NODE_SIZE,
|
||||
GLADE_PLACEHOLDER_SELECTION_NODE_SIZE);
|
||||
gdk_draw_rectangle (window, gc, TRUE,
|
||||
x + width - GLADE_PLACEHOLDER_SELECTION_NODE_SIZE, y,
|
||||
GLADE_PLACEHOLDER_SELECTION_NODE_SIZE,
|
||||
GLADE_PLACEHOLDER_SELECTION_NODE_SIZE);
|
||||
gdk_draw_rectangle (window, gc, TRUE,
|
||||
x + width - GLADE_PLACEHOLDER_SELECTION_NODE_SIZE,
|
||||
y + height - GLADE_PLACEHOLDER_SELECTION_NODE_SIZE,
|
||||
GLADE_PLACEHOLDER_SELECTION_NODE_SIZE,
|
||||
GLADE_PLACEHOLDER_SELECTION_NODE_SIZE);
|
||||
}
|
||||
|
||||
gdk_draw_rectangle (window, gc, FALSE, x, y, width - 1, height - 1);
|
||||
|
||||
gdk_gc_set_subwindow (gc, GDK_CLIP_BY_CHILDREN);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_placeholder_clear_selection_nodes (GladePlaceholder *placeholder)
|
||||
{
|
||||
g_return_if_fail (GLADE_IS_WIDGET (placeholder));
|
||||
|
||||
gdk_window_clear_area (placeholder->window,
|
||||
placeholder->allocation.x,
|
||||
placeholder->allocation.y,
|
||||
placeholder->allocation.width,
|
||||
placeholder->allocation.height);
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (placeholder));
|
||||
}
|
||||
|
||||
static void
|
||||
glade_placeholder_on_button_press_event (GladePlaceholder *placeholder, GdkEventButton *event, GladeProject *project)
|
||||
{
|
||||
@ -234,9 +318,25 @@ glade_placeholder_on_button_press_event (GladePlaceholder *placeholder, GdkEvent
|
||||
|
||||
gpw = glade_project_window_get ();
|
||||
|
||||
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);
|
||||
if (event->button == 1 && event->type == GDK_BUTTON_PRESS) {
|
||||
|
||||
if (gpw->add_class != NULL) {
|
||||
/*
|
||||
* A widget type is selected in the palette.
|
||||
* Add a new widget of that type.
|
||||
*/
|
||||
glade_placeholder_replace_widget (placeholder, gpw->add_class, project);
|
||||
glade_project_window_set_add_class (gpw, NULL);
|
||||
gpw->active_placeholder = NULL;
|
||||
} else {
|
||||
/*
|
||||
* Else set the current placeholder as selected,
|
||||
* so that Paste from the Main Menu works.
|
||||
*/
|
||||
glade_placeholder_clear_selection_nodes (gpw->active_placeholder);
|
||||
gpw->active_placeholder = placeholder;
|
||||
glade_placeholder_draw_selection_nodes (placeholder);
|
||||
}
|
||||
} else if (event->button == 3) {
|
||||
glade_popup_placeholder_pop (placeholder, event);
|
||||
}
|
||||
|
@ -86,13 +86,3 @@ glade_project_ui_get_path (const gchar *title)
|
||||
|
||||
return gtk_object_get_user_data (GTK_OBJECT (selector));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glade_project_ui_warn (const gchar *warning)
|
||||
{
|
||||
/* This are warnings to the users, use a nice dialog and stuff */
|
||||
|
||||
g_warning (warning);
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gchar * glade_project_ui_get_path (const gchar *title);
|
||||
void glade_project_ui_warn (const gchar *warning);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -117,8 +117,8 @@ gpw_save_cb (void)
|
||||
|
||||
gpw = glade_project_window_get ();
|
||||
project = glade_project_window_get_project ();
|
||||
glade_project_save (project);
|
||||
glade_project_window_refresh_title (gpw);
|
||||
if (glade_project_save (project))
|
||||
glade_project_window_refresh_title (gpw);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -129,8 +129,8 @@ gpw_save_as_cb (void)
|
||||
|
||||
gpw = glade_project_window_get ();
|
||||
project = glade_project_window_get_project ();
|
||||
glade_project_save_as (project);
|
||||
glade_project_window_refresh_title (gpw);
|
||||
if (glade_project_save_as (project))
|
||||
glade_project_window_refresh_title (gpw);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -142,19 +142,36 @@ gpw_quit_cb (void)
|
||||
static void
|
||||
gpw_copy_cb (void)
|
||||
{
|
||||
glade_implement_me ();
|
||||
GladeProjectWindow *gpw;
|
||||
GladeWidget *widget;
|
||||
|
||||
gpw = glade_project_window_get ();
|
||||
widget = gpw->active_widget;
|
||||
|
||||
if (widget)
|
||||
glade_clipboard_copy (gpw->clipboard, widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gpw_cut_cb (void)
|
||||
{
|
||||
glade_implement_me ();
|
||||
GladeProjectWindow *gpw;
|
||||
GladeWidget *widget;
|
||||
|
||||
gpw = glade_project_window_get ();
|
||||
widget = gpw->active_widget;
|
||||
|
||||
if (widget)
|
||||
glade_clipboard_cut (gpw->clipboard, widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gpw_paste_cb (void)
|
||||
{
|
||||
glade_implement_me ();
|
||||
GladeProjectWindow *gpw;
|
||||
|
||||
gpw = glade_project_window_get ();
|
||||
glade_clipboard_paste (gpw->clipboard, gpw->active_placeholder);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -332,7 +349,8 @@ glade_project_window_new (GList *catalogs)
|
||||
gpw->catalogs = catalogs;
|
||||
gpw->views = g_list_prepend (NULL, view);
|
||||
gpw->add_class = NULL;
|
||||
|
||||
gpw->active_widget = NULL;
|
||||
gpw->active_placeholder = NULL;
|
||||
glade_project_window_set_view (gpw, view);
|
||||
|
||||
glade_project_window = gpw;
|
||||
@ -438,12 +456,13 @@ glade_project_window_selection_changed_cb (GladeProject *project,
|
||||
if (gpw->editor) {
|
||||
list = project->selection;
|
||||
num = g_list_length (list);
|
||||
if (num == 1)
|
||||
if (num == 1) {
|
||||
glade_editor_select_widget (gpw->editor, list->data);
|
||||
else
|
||||
gpw->active_widget = list->data;
|
||||
} else {
|
||||
glade_editor_select_widget (gpw->editor, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -36,7 +36,12 @@ struct _GladeProjectWindow
|
||||
* be in sync with the depressed button
|
||||
* in the GladePalette
|
||||
*/
|
||||
|
||||
|
||||
GladeWidget *active_widget; /* The currently selected widget */
|
||||
GladePlaceholder *active_placeholder; /* The currently selected
|
||||
* placeholder
|
||||
*/
|
||||
|
||||
GList *views; /* A list of GladeProjectView item */
|
||||
GList *projects; /* The list of Projects */
|
||||
|
||||
|
@ -632,17 +632,18 @@ glade_project_save (GladeProject *project)
|
||||
g_free (project->name);
|
||||
project->path = glade_project_ui_get_path (_("Save ..."));
|
||||
project->name = g_path_get_basename (project->path);
|
||||
glade_project_refresh_menu_item (project);
|
||||
g_free (backup);
|
||||
}
|
||||
|
||||
if (!glade_project_save_to_file (project, project->path)) {
|
||||
glade_project_ui_warn (_("Invalid file name"));
|
||||
glade_util_ui_warn (_("Invalid file name"));
|
||||
g_free (project->path);
|
||||
project->path = backup;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
glade_project_refresh_menu_item (project);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -668,7 +669,7 @@ glade_project_save_as (GladeProject *project)
|
||||
|
||||
/* On error, warn and restore its previous name and return */
|
||||
if (!glade_project_save_to_file (project, project->path)) {
|
||||
glade_project_ui_warn (_("Invalid file name"));
|
||||
glade_util_ui_warn (_("Invalid file name"));
|
||||
g_free (project->path);
|
||||
project->path = backup;
|
||||
return FALSE;
|
||||
@ -713,7 +714,7 @@ glade_project_open (void)
|
||||
project = glade_project_open_from_file (path);
|
||||
|
||||
if (!project) {
|
||||
glade_project_ui_warn (_("Could not open project."));
|
||||
glade_util_ui_warn (_("Could not open project."));
|
||||
g_free (path);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <gtk/gtktooltips.h>
|
||||
#include "glade.h"
|
||||
#include <gmodule.h>
|
||||
#include "glade-project-window.h"
|
||||
|
||||
|
||||
gboolean
|
||||
@ -83,3 +84,19 @@ glade_util_get_type_from_name (const gchar *name)
|
||||
return type;
|
||||
}
|
||||
|
||||
void
|
||||
glade_util_ui_warn (const gchar *warning)
|
||||
{
|
||||
GladeProjectWindow *gpw;
|
||||
GtkWidget *dialog;
|
||||
|
||||
gpw = glade_project_window_get ();
|
||||
dialog = gtk_message_dialog_new (gpw->window,
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_WARNING,
|
||||
GTK_BUTTONS_OK,
|
||||
warning);
|
||||
|
||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ G_BEGIN_DECLS
|
||||
gboolean glade_util_path_is_writable (const gchar *full_path);
|
||||
void glade_util_widget_set_tooltip (GtkWidget *widget, const gchar *str);
|
||||
GType glade_util_get_type_from_name (const gchar *name);
|
||||
void glade_util_ui_warn (const gchar *warning);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -264,6 +264,7 @@ glade_widget_get_from_event_widget (GtkWidget *event_widget, GdkEventButton *eve
|
||||
static gboolean
|
||||
glade_widget_button_press (GtkWidget *event_widget, GdkEventButton *event, gpointer not_used)
|
||||
{
|
||||
GladeProjectWindow *gpw;
|
||||
GladeWidget *glade_widget;
|
||||
|
||||
glade_widget = glade_widget_get_from_event_widget (event_widget, event);
|
||||
@ -292,6 +293,9 @@ glade_widget_button_press (GtkWidget *event_widget, GdkEventButton *event, gpoin
|
||||
|
||||
g_debug(("The widget found was a %s\n", glade_widget->class->name));
|
||||
|
||||
gpw = glade_project_window_get ();
|
||||
gpw->active_placeholder = NULL;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user