diff --git a/ChangeLog b/ChangeLog index b5efca73..755aabfc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-12-28 Tristan Van Berkom + + * gladeui/Makefile.am, gladeui/glade.h, gladeui/glade-clipboard.c, gladeui/glade-app.[ch], + src/glade-window.c, gladeui/glade-clipboard-view.[ch]: + Removed GladeClipboradView completely. + 2010-12-27 Tristan Van Berkom * gladeui/glade-project.c: Fixed glade-project to unset the loading flag when diff --git a/gladeui/Makefile.am b/gladeui/Makefile.am index 2d2858ce..f0f920a6 100644 --- a/gladeui/Makefile.am +++ b/gladeui/Makefile.am @@ -72,7 +72,6 @@ libgladeui_2_la_SOURCES = \ glade-signal.c \ glade-signal-editor.c \ glade-clipboard.c \ - glade-clipboard-view.c \ glade-command.c \ glade-id-allocator.c \ glade-id-allocator.h \ @@ -129,7 +128,6 @@ libgladeuiinclude_HEADERS = \ glade-property-class.h \ glade-utils.h \ glade-clipboard.h \ - glade-clipboard-view.h \ glade-command.h \ glade-app.h \ glade-builtins.h \ diff --git a/gladeui/glade-app.c b/gladeui/glade-app.c index e600dba4..796aa992 100644 --- a/gladeui/glade-app.c +++ b/gladeui/glade-app.c @@ -33,7 +33,6 @@ */ #include "glade.h" -#include "glade-clipboard-view.h" #include "glade-debug.h" #include "glade-cursor.h" #include "glade-catalog.h" @@ -304,13 +303,6 @@ glade_app_signal_editor_created_default (GladeApp *app, GladeSignalEditor *signa glade_signal_editor_construct_signals_list (signal_editor); } -static gboolean -clipboard_view_on_delete_cb (GtkWidget *clipboard_view, GdkEvent *e, GladeApp *app) -{ - glade_util_hide_window (GTK_WINDOW (clipboard_view)); - return TRUE; -} - static GKeyFile * glade_app_config_load (GladeApp *app) { @@ -455,11 +447,6 @@ glade_app_init (GladeApp *app) /* Create clipboard */ app->priv->clipboard = glade_clipboard_new (); - app->priv->clipboard->view = glade_clipboard_view_new (app->priv->clipboard); - gtk_window_set_title (GTK_WINDOW (app->priv->clipboard->view), _("Clipboard")); - g_signal_connect_after (G_OBJECT (app->priv->clipboard->view), "delete_event", - G_CALLBACK (clipboard_view_on_delete_cb), - app); /* Load the configuration file */ app->priv->config = glade_app_config_load (app); @@ -801,13 +788,6 @@ glade_app_get_clipboard (void) return app->priv->clipboard; } -GtkWidget * -glade_app_get_clipboard_view (void) -{ - GladeApp *app = glade_app_get (); - return app->priv->clipboard->view; -} - GladeProject * glade_app_get_project (void) { diff --git a/gladeui/glade-app.h b/gladeui/glade-app.h index 87000d1e..6570baa4 100644 --- a/gladeui/glade-app.h +++ b/gladeui/glade-app.h @@ -105,14 +105,12 @@ gboolean glade_app_get_catalog_version (const gchar *name, gint *major GList *glade_app_get_catalogs (void); GladeCatalog *glade_app_get_catalog (const gchar *name); - + GladeEditor* glade_app_get_editor (void); - + GladePalette* glade_app_get_palette (void); - + GladeClipboard* glade_app_get_clipboard (void); - -GtkWidget* glade_app_get_clipboard_view (void); GladeProject* glade_app_get_project (void); diff --git a/gladeui/glade-clipboard-view.c b/gladeui/glade-clipboard-view.c deleted file mode 100644 index c7438421..00000000 --- a/gladeui/glade-clipboard-view.c +++ /dev/null @@ -1,388 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * glade-clipboard-view.c - The View for the Clipboard. - * - * Copyright (C) 2001 The GNOME Foundation. - * - * Author(s): - * Archit Baweja - * - * 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. - */ -#ifdef HAVE_CONFIG_H -#include -#endif - -/** - * SECTION:glade-clipboard-view - * @Short_Description: A widget to view and control the #GladeClipboard. - * - * The #GladeClipboardView is a widget to view the #GladeWidget objects - * in the #GladeClipboard; the user can paste or delete objects on the clipboard. - */ - -#include - -#include "glade.h" -#include "glade-clipboard.h" -#include "glade-clipboard-view.h" -#include "glade-widget.h" -#include "glade-widget-adaptor.h" -#include "glade-popup.h" - - -const gint GLADE_CLIPBOARD_VIEW_WIDTH = 230; -const gint GLADE_CLIPBOARD_VIEW_HEIGHT = 200; - -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; -} - -GType -glade_clipboard_view_get_type () -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (GladeClipboardViewClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) glade_clipboard_view_class_init, - (GClassFinalizeFunc) NULL, - NULL, - sizeof (GladeClipboardView), - 0, - (GInstanceInitFunc) glade_clipboard_view_init - }; - - type = g_type_register_static (GTK_TYPE_WINDOW, "GladeClipboardView", &info, 0); - } - - return type; -} - -static void -gcv_foreach_add_selection (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data) -{ - GladeWidget *widget = NULL; - GladeClipboardView *view = (GladeClipboardView *)data; - gtk_tree_model_get (model, iter, 0, &widget, -1); - glade_clipboard_selection_add (view->clipboard, (widget)); -} - -static void -glade_clipboard_view_selection_changed_cb (GtkTreeSelection *sel, - GladeClipboardView *view) -{ - if (view->updating == FALSE) - { - glade_clipboard_selection_clear (view->clipboard); - gtk_tree_selection_selected_foreach - (sel, gcv_foreach_add_selection, view); - } -} - -static void -glade_clipboard_view_populate_model (GladeClipboardView *view) -{ - GladeClipboard *clipboard; - GtkTreeModel *model; - GladeWidget *widget; - GList *list; - GtkTreeIter iter; - - clipboard = GLADE_CLIPBOARD (view->clipboard); - model = GTK_TREE_MODEL (view->model); - - for (list = clipboard->widgets; list; list = list->next) - { - widget = list->data; - view->updating = TRUE; - gtk_list_store_append (GTK_LIST_STORE (model), &iter); - gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, widget, -1); - view->updating = FALSE; - } -} - -static void -glade_clipboard_view_cell_function (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *tree_model, - GtkTreeIter *iter, - gpointer data) -{ - gboolean is_icon = GPOINTER_TO_INT (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); - - if (is_icon) - g_object_set (G_OBJECT (cell), - "icon-name", widget->adaptor->icon_name, - "stock-size", GTK_ICON_SIZE_MENU, - NULL); - else - g_object_set (G_OBJECT (cell), - "text", widget->name, - NULL); - -} - -static gint -glade_clipboard_view_button_press_cb (GtkWidget *widget, - GdkEventButton *event, - GladeClipboardView *view) -{ - GtkTreeView *tree_view = GTK_TREE_VIEW (widget); - GtkTreePath *path = NULL; - gboolean handled = FALSE; - - if (event->window == gtk_tree_view_get_bin_window (tree_view) && - gtk_tree_view_get_path_at_pos (tree_view, - (gint) event->x, (gint) event->y, - &path, NULL, - NULL, NULL) && path != NULL) - { - GtkTreeIter iter; - GladeWidget *widget = NULL; - if (gtk_tree_model_get_iter (GTK_TREE_MODEL (view->model), - &iter, path)) - { - /* Alright, now we can obtain - * the widget from the iter. - */ - gtk_tree_model_get (GTK_TREE_MODEL (view->model), &iter, - 0, &widget, -1); - if (widget != NULL && - event->button == 3) - { - glade_popup_clipboard_pop (widget, event); - handled = TRUE; - } - gtk_tree_path_free (path); - } - } - return handled; -} - -static void -glade_clipboard_view_create_tree_view (GladeClipboardView *view) -{ - GtkTreeSelection *sel; - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; - - view->widget = - gtk_tree_view_new_with_model (GTK_TREE_MODEL (view->model)); - - column = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title (column, _("Widget")); - - renderer = gtk_cell_renderer_pixbuf_new (); - gtk_tree_view_column_pack_start (column, renderer, FALSE); - gtk_tree_view_column_set_cell_data_func (column, renderer, - glade_clipboard_view_cell_function, - GINT_TO_POINTER (1), NULL); - - renderer = gtk_cell_renderer_text_new (); - g_object_set (G_OBJECT (renderer), - "xpad", 6, NULL); - gtk_tree_view_column_pack_start (column, renderer, TRUE); - gtk_tree_view_column_set_cell_data_func (column, renderer, - glade_clipboard_view_cell_function, - GINT_TO_POINTER (0), NULL); - - gtk_tree_view_append_column (GTK_TREE_VIEW (view->widget), column); - - sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (view->widget)); - gtk_tree_selection_set_mode (sel, GTK_SELECTION_MULTIPLE); - - g_signal_connect_data (G_OBJECT (sel), "changed", - G_CALLBACK (glade_clipboard_view_selection_changed_cb), - view, NULL, 0); - - /* Popup menu */ - g_signal_connect (G_OBJECT (view->widget), "button-press-event", - G_CALLBACK (glade_clipboard_view_button_press_cb), view); - -} - -static void -glade_clipboard_view_construct (GladeClipboardView *view) -{ - GtkWidget *scrolled_window, *viewport; - - view->model = gtk_list_store_new (1, G_TYPE_POINTER); - - glade_clipboard_view_populate_model (view); - glade_clipboard_view_create_tree_view (view); - glade_clipboard_view_refresh_sel (view); - - viewport = gtk_viewport_new (NULL, NULL); - gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_OUT); - - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type - (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN); - gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), - 6); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_container_add (GTK_CONTAINER (scrolled_window), view->widget); - gtk_container_add (GTK_CONTAINER (viewport), scrolled_window); - gtk_container_add (GTK_CONTAINER (view), viewport); - - gtk_window_set_default_size (GTK_WINDOW (view), - GLADE_CLIPBOARD_VIEW_WIDTH, - GLADE_CLIPBOARD_VIEW_HEIGHT); - - gtk_window_set_type_hint (GTK_WINDOW (view), GDK_WINDOW_TYPE_HINT_UTILITY); - - gtk_widget_show_all (scrolled_window); - - return; -} - -/** - * glade_clipboard_view_new: - * @clipboard: a #GladeClipboard - * - * Create a new #GladeClipboardView widget for @clipboard. - * - * Returns: a new #GladeClipboardView cast to be a #GtkWidget - */ -GtkWidget * -glade_clipboard_view_new (GladeClipboard *clipboard) -{ - GladeClipboardView *view; - - g_return_val_if_fail (GLADE_IS_CLIPBOARD (clipboard), NULL); - - view = g_object_new (GLADE_TYPE_CLIPBOARD_VIEW, NULL); - view->clipboard = clipboard; - glade_clipboard_view_construct (view); - - return GTK_WIDGET (view); -} - -/** - * glade_clipboard_view_add: - * @view: a #GladeClipboardView - * @widget: a #GladeWidget - * - * Adds @widget to @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)); - - view->updating = TRUE; - gtk_list_store_append (view->model, &iter); - gtk_list_store_set (view->model, &iter, 0, widget, -1); - view->updating = FALSE; -} - -/** - * glade_cliboard_view_remove: - * @view: a #GladeClipboardView - * @widget: a #GladeWidget - * - * Removes @widget from @view. - */ -void -glade_clipboard_view_remove (GladeClipboardView *view, GladeWidget *widget) -{ - GtkTreeIter iter; - GtkTreeModel *model; - GladeWidget *clip_widget; - - g_return_if_fail (GLADE_IS_CLIPBOARD_VIEW (view)); - g_return_if_fail (GLADE_IS_WIDGET (widget)); - - model = GTK_TREE_MODEL (view->model); - if (gtk_tree_model_get_iter_first (model, &iter)) - { - do - { - gtk_tree_model_get (model, &iter, 0, &clip_widget, -1); - if (widget == clip_widget) - break; - } - while (gtk_tree_model_iter_next (model, &iter)); - } - - view->updating = TRUE; - gtk_list_store_remove (view->model, &iter); - view->updating = FALSE; -} - -/** - * glade_clipboard_view_refresh_sel: - * @view: a #GladeClipboardView - * - * Synchronizes the treeview selection to the clipboard selection. - */ -void -glade_clipboard_view_refresh_sel (GladeClipboardView *view) -{ - GladeWidget *widget; - GtkTreeSelection *sel; - GList *list; - GtkTreeIter *iter; - - g_return_if_fail (GLADE_IS_CLIPBOARD_VIEW (view)); - - if (view->updating) return; - view->updating = TRUE; - - sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (view->widget)); - - gtk_tree_selection_unselect_all (sel); - for (list = view->clipboard->selection; - list && list->data; list = list->next) - { - widget = list->data; - if ((iter = glade_util_find_iter_by_widget - (GTK_TREE_MODEL (view->model), widget, 0)) != NULL) - { - gtk_tree_selection_select_iter (sel, iter); - /* gtk_tree_iter_free (iter); */ - } - } - view->updating = FALSE; -} diff --git a/gladeui/glade-clipboard-view.h b/gladeui/glade-clipboard-view.h deleted file mode 100644 index 3498c155..00000000 --- a/gladeui/glade-clipboard-view.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef __GLADE_CLIPBOARD_VIEW_H__ -#define __GLADE_CLIPBOARD_VIEW_H__ - -#include - -G_BEGIN_DECLS - -#define GLADE_TYPE_CLIPBOARD_VIEW (glade_clipboard_view_get_type ()) -#define GLADE_CLIPBOARD_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_CLIPBOARD_VIEW, GladeClipboardView)) -#define GLADE_CLIPBOARD_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_CLIPBOARD_VIEW, GladeClipboardViewClass)) -#define GLADE_IS_CLIPBOARD_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_CLIPBOARD_VIEW)) -#define GLADE_IS_CLIPBOARD_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_CLIPBOARD_VIEW)) -#define GLADE_CLIPBOARD_VIEW_GET_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), GLADE_TYPE_CLIPBOARD_VIEW, GladeClipboardViewClass)) - -typedef struct _GladeClipboardView GladeClipboardView; -typedef struct _GladeClipboardViewClass GladeClipboardViewClass; - -struct _GladeClipboardView -{ - GtkWindow parent_instance; - - GtkWidget *widget; /* The GtkTreeView widget */ - GtkListStore *model; /* The GtkListStore model for the View */ - GladeClipboard *clipboard; /* The Clipboard for which this is a view */ - gboolean updating; /* Prevent feedback from treeview when changing - * the selecion. */ -}; - -struct _GladeClipboardViewClass -{ - GtkWindowClass parent_class; -}; - - - -GType glade_clipboard_view_get_type (void) G_GNUC_CONST; - - -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); - -void glade_clipboard_view_refresh_sel (GladeClipboardView *view); - -G_END_DECLS - -#endif /* __GLADE_CLIPBOARD_VIEW_H__ */ diff --git a/gladeui/glade-clipboard.c b/gladeui/glade-clipboard.c index 9e69e2e3..e847312d 100644 --- a/gladeui/glade-clipboard.c +++ b/gladeui/glade-clipboard.c @@ -36,7 +36,6 @@ #include #include "glade.h" -#include "glade-clipboard-view.h" #include "glade-clipboard.h" #include "glade-widget.h" #include "glade-placeholder.h" @@ -89,7 +88,6 @@ static void glade_clipboard_init (GladeClipboard *clipboard) { clipboard->widgets = NULL; - clipboard->view = NULL; clipboard->selection = NULL; clipboard->has_selection = FALSE; } @@ -186,17 +184,8 @@ glade_clipboard_add (GladeClipboard *clipboard, GList *widgets) clipboard->widgets = g_list_prepend (clipboard->widgets, g_object_ref (G_OBJECT (widget))); - /* - * Update view. - */ + glade_clipboard_selection_add (clipboard, widget); - if (clipboard->view) - { - glade_clipboard_view_add - (GLADE_CLIPBOARD_VIEW (clipboard->view), widget); - glade_clipboard_view_refresh_sel - (GLADE_CLIPBOARD_VIEW (clipboard->view)); - } } } @@ -221,13 +210,6 @@ glade_clipboard_remove (GladeClipboard *clipboard, GList *widgets) clipboard->widgets = g_list_remove (clipboard->widgets, widget); glade_clipboard_selection_remove (clipboard, widget); - - /* - * If there is a view present, update it. - */ - if (clipboard->view) - glade_clipboard_view_remove - (GLADE_CLIPBOARD_VIEW (clipboard->view), widget); g_object_unref (G_OBJECT (widget)); } @@ -240,8 +222,6 @@ glade_clipboard_remove (GladeClipboard *clipboard, GList *widgets) { glade_clipboard_selection_add (clipboard, GLADE_WIDGET (list->data)); - glade_clipboard_view_refresh_sel - (GLADE_CLIPBOARD_VIEW (clipboard->view)); } } diff --git a/gladeui/glade.h b/gladeui/glade.h index 580fbc4d..32ae7c74 100644 --- a/gladeui/glade.h +++ b/gladeui/glade.h @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include diff --git a/src/glade-window.c b/src/glade-window.c index ee988648..fe832f9a 100644 --- a/src/glade-window.c +++ b/src/glade-window.c @@ -3234,7 +3234,6 @@ glade_window_init (GladeWindow *window) GtkWidget *widget; GtkWidget *sep; GtkAction *undo_action, *redo_action; - GtkAccelGroup *accel_group; window->priv = priv = GLADE_WINDOW_GET_PRIVATE (window); @@ -3300,6 +3299,7 @@ glade_window_init (GladeWindow *window) /* notebook */ priv->notebook = gtk_notebook_new (); + gtk_notebook_set_scrollable (GTK_NOTEBOOK (priv->notebook), TRUE); /* Show tabs (user preference) */ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), TRUE); @@ -3438,10 +3438,6 @@ glade_window_init (GladeWindow *window) glade_app_set_window (GTK_WIDGET (window)); - accel_group = gtk_ui_manager_get_accel_group(priv->ui); - - gtk_window_add_accel_group (GTK_WINDOW (glade_app_get_clipboard_view ()), accel_group); - glade_window_config_load (window); #ifdef MAC_INTEGRATION