From d09d8de870b6697c8a8b262e7e077b871a69b315 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 10 Dec 2012 08:09:59 -0500 Subject: Consolidate base utility libraries into libeutil. Evolution consists of entirely too many small utility libraries, which increases linking and loading time, places a burden on higher layers of the application (e.g. modules) which has to remember to link to all the small in-tree utility libraries, and makes it difficult to generate API documentation for these utility libraries in one Gtk-Doc module. Merge the following utility libraries under the umbrella of libeutil, and enforce a single-include policy on libeutil so we can reorganize the files as desired without disrupting its pseudo-public API. libemail-utils/libemail-utils.la libevolution-utils/libevolution-utils.la filter/libfilter.la widgets/e-timezone-dialog/libetimezonedialog.la widgets/menus/libmenus.la widgets/misc/libemiscwidgets.la widgets/table/libetable.la widgets/text/libetext.la This also merges libedataserverui from the Evolution-Data-Server module, since Evolution is its only consumer nowadays, and I'd like to make some improvements to those APIs without concern for backward-compatibility. And finally, start a Gtk-Doc module for libeutil. It's going to be a project just getting all the symbols _listed_ much less _documented_. But the skeletal structure is in place and I'm off to a good start. --- widgets/menus/Makefile.am | 58 -- widgets/menus/gal-define-views-dialog.c | 451 ------------ widgets/menus/gal-define-views-dialog.h | 73 -- widgets/menus/gal-define-views-model.c | 353 --------- widgets/menus/gal-define-views-model.h | 66 -- widgets/menus/gal-define-views.ui | 177 ----- widgets/menus/gal-view-collection.c | 829 ---------------------- widgets/menus/gal-view-collection.h | 146 ---- widgets/menus/gal-view-etable.c | 335 --------- widgets/menus/gal-view-etable.h | 92 --- widgets/menus/gal-view-factory-etable.c | 196 ----- widgets/menus/gal-view-factory-etable.h | 73 -- widgets/menus/gal-view-factory.c | 103 --- widgets/menus/gal-view-factory.h | 81 --- widgets/menus/gal-view-instance-save-as-dialog.c | 358 ---------- widgets/menus/gal-view-instance-save-as-dialog.h | 88 --- widgets/menus/gal-view-instance-save-as-dialog.ui | 133 ---- widgets/menus/gal-view-instance.c | 503 ------------- widgets/menus/gal-view-instance.h | 110 --- widgets/menus/gal-view-new-dialog.c | 290 -------- widgets/menus/gal-view-new-dialog.h | 77 -- widgets/menus/gal-view-new-dialog.ui | 177 ----- widgets/menus/gal-view.c | 282 -------- widgets/menus/gal-view.h | 94 --- 24 files changed, 5145 deletions(-) delete mode 100644 widgets/menus/Makefile.am delete mode 100644 widgets/menus/gal-define-views-dialog.c delete mode 100644 widgets/menus/gal-define-views-dialog.h delete mode 100644 widgets/menus/gal-define-views-model.c delete mode 100644 widgets/menus/gal-define-views-model.h delete mode 100644 widgets/menus/gal-define-views.ui delete mode 100644 widgets/menus/gal-view-collection.c delete mode 100644 widgets/menus/gal-view-collection.h delete mode 100644 widgets/menus/gal-view-etable.c delete mode 100644 widgets/menus/gal-view-etable.h delete mode 100644 widgets/menus/gal-view-factory-etable.c delete mode 100644 widgets/menus/gal-view-factory-etable.h delete mode 100644 widgets/menus/gal-view-factory.c delete mode 100644 widgets/menus/gal-view-factory.h delete mode 100644 widgets/menus/gal-view-instance-save-as-dialog.c delete mode 100644 widgets/menus/gal-view-instance-save-as-dialog.h delete mode 100644 widgets/menus/gal-view-instance-save-as-dialog.ui delete mode 100644 widgets/menus/gal-view-instance.c delete mode 100644 widgets/menus/gal-view-instance.h delete mode 100644 widgets/menus/gal-view-new-dialog.c delete mode 100644 widgets/menus/gal-view-new-dialog.h delete mode 100644 widgets/menus/gal-view-new-dialog.ui delete mode 100644 widgets/menus/gal-view.c delete mode 100644 widgets/menus/gal-view.h (limited to 'widgets/menus') diff --git a/widgets/menus/Makefile.am b/widgets/menus/Makefile.am deleted file mode 100644 index aa3bb75b73..0000000000 --- a/widgets/menus/Makefile.am +++ /dev/null @@ -1,58 +0,0 @@ -privsolib_LTLIBRARIES = libmenus.la - -libmenus_la_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -I$(top_srcdir) \ - -I$(top_srcdir)/widgets \ - -DEVOLUTION_UIDIR=\""$(uidir)"\" \ - -DG_LOG_DOMAIN=\"menus\" \ - $(EVOLUTION_DATA_SERVER_CFLAGS) \ - $(GNOME_PLATFORM_CFLAGS) - -libmenus_la_SOURCES = \ - gal-define-views-dialog.c \ - gal-define-views-model.c \ - gal-view-collection.c \ - gal-view-etable.c \ - gal-view-factory-etable.c \ - gal-view-factory.c \ - gal-view-instance-save-as-dialog.c \ - gal-view-instance.c \ - gal-view-new-dialog.c \ - gal-view.c - -ui_DATA = \ - gal-define-views.ui \ - gal-view-new-dialog.ui \ - gal-view-instance-save-as-dialog.ui - -libmenusincludedir = $(privincludedir)/menus - -libmenusinclude_HEADERS = \ - gal-define-views-dialog.h \ - gal-define-views-model.h \ - gal-view-collection.h \ - gal-view-etable.h \ - gal-view-factory-etable.h \ - gal-view-factory.h \ - gal-view-instance-save-as-dialog.h \ - gal-view-instance.h \ - gal-view-new-dialog.h \ - gal-view.h - -libmenus_la_LDFLAGS = -avoid-version $(NO_UNDEFINED) - -libmenus_la_LIBADD = \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/widgets/table/libetable.la \ - $(top_builddir)/widgets/misc/libemiscwidgets.la \ - $(top_builddir)/libevolution-utils/libevolution-utils.la \ - $(EVOLUTION_DATA_SERVER_LIBS) \ - $(GNOME_PLATFORM_LIBS) - -icons = -EXTRA_DIST = \ - $(icons) \ - $(ui_DATA) - --include $(top_srcdir)/git.mk diff --git a/widgets/menus/gal-define-views-dialog.c b/widgets/menus/gal-define-views-dialog.c deleted file mode 100644 index 974cdad323..0000000000 --- a/widgets/menus/gal-define-views-dialog.c +++ /dev/null @@ -1,451 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Chris Lahey - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include "e-util/e-util.h" -#include "e-util/e-util-private.h" - -#include "gal-define-views-dialog.h" -#include "gal-define-views-model.h" -#include "gal-view-new-dialog.h" - -static void gal_define_views_dialog_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); -static void gal_define_views_dialog_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); -static void gal_define_views_dialog_dispose (GObject *object); - -/* The properties we support */ -enum { - PROP_0, - PROP_COLLECTION -}; - -enum { - COL_GALVIEW_NAME, - COL_GALVIEW_DATA -}; - -typedef struct { - gchar *title; - - GtkTreeView *treeview; - GtkTreeModel *model; - - GalDefineViewsDialog *names; -} GalDefineViewsDialogChild; - -G_DEFINE_TYPE (GalDefineViewsDialog, gal_define_views_dialog, GTK_TYPE_DIALOG) - -static void -gal_define_views_dialog_class_init (GalDefineViewsDialogClass *class) -{ - GObjectClass *object_class; - - object_class = (GObjectClass *) class; - - object_class->set_property = gal_define_views_dialog_set_property; - object_class->get_property = gal_define_views_dialog_get_property; - object_class->dispose = gal_define_views_dialog_dispose; - - g_object_class_install_property ( - object_class, - PROP_COLLECTION, - g_param_spec_object ( - "collection", - "Collection", - NULL, - GAL_VIEW_COLLECTION_TYPE, - G_PARAM_READWRITE)); -} - -/* Button callbacks */ - -static void -gdvd_button_new_dialog_callback (GtkWidget *widget, - gint id, - GalDefineViewsDialog *dialog) -{ - gchar *name; - GtkTreeIter iter; - GalView *view; - GalViewCollectionItem *item; - GalViewFactory *factory; - - switch (id) { - case GTK_RESPONSE_OK: - g_object_get ( - widget, - "name", &name, - "factory", &factory, - NULL); - - if (name && factory) { - g_strchomp (name); - if (*name != '\0') { - view = gal_view_factory_new_view (factory, name); - gal_view_collection_append (dialog->collection, view); - - item = dialog->collection->view_data[dialog->collection->view_count - 1]; - gtk_list_store_append (GTK_LIST_STORE (dialog->model), &iter); - gtk_list_store_set ( - GTK_LIST_STORE (dialog->model), &iter, - COL_GALVIEW_NAME, name, - COL_GALVIEW_DATA, item, - -1); - - if (view && GAL_VIEW_GET_CLASS (view)->edit) - gal_view_edit (view, GTK_WINDOW (dialog)); - g_object_unref (view); - } - } - g_object_unref (factory); - g_free (name); - break; - } - gtk_widget_destroy (widget); -} - -static void -gdvd_button_new_callback (GtkWidget *widget, - GalDefineViewsDialog *dialog) -{ - GtkWidget *view_new_dialog = gal_view_new_dialog_new (dialog->collection); - gtk_window_set_transient_for (GTK_WINDOW (view_new_dialog), GTK_WINDOW (dialog)); - g_signal_connect ( - view_new_dialog, "response", - G_CALLBACK (gdvd_button_new_dialog_callback), dialog); - gtk_widget_show (view_new_dialog); -} - -static void -gdvd_button_modify_callback (GtkWidget *widget, - GalDefineViewsDialog *dialog) -{ - GtkTreeIter iter; - GalViewCollectionItem *item; - - if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection (dialog->treeview), - &dialog->model, - &iter)) { - gtk_tree_model_get (dialog->model, &iter, COL_GALVIEW_DATA, &item, -1); - - g_return_if_fail (item && !item->built_in); - - gal_view_edit (item->view, GTK_WINDOW (dialog)); - } -} - -static void -gdvd_button_delete_callback (GtkWidget *widget, - GalDefineViewsDialog *dialog) -{ - gint row; - GtkTreeIter iter; - GtkTreePath *path; - GtkTreeSelection *selection; - GalViewCollectionItem *item; - - selection = gtk_tree_view_get_selection (dialog->treeview); - - if (gtk_tree_selection_get_selected (selection, - &dialog->model, - &iter)) { - gtk_tree_model_get (dialog->model, &iter, COL_GALVIEW_DATA, &item, -1); - - g_return_if_fail (item && !item->built_in); - - for (row = 0; row < dialog->collection->view_count; row++) { - if (item == dialog->collection->view_data[row]) { - gal_view_collection_delete_view (dialog->collection, row); - path = gtk_tree_model_get_path (dialog->model, &iter); - gtk_list_store_remove (GTK_LIST_STORE (dialog->model), &iter); - - if (gtk_tree_path_prev (path)) { - gtk_tree_model_get_iter (dialog->model, &iter, path); - } else { - gtk_tree_model_get_iter_first (dialog->model, &iter); - } - - gtk_tree_selection_select_iter (selection, &iter); - break; - } - } - } -} - -static void -gdvd_selection_changed_callback (GtkTreeSelection *selection, - GalDefineViewsDialog *dialog) -{ - GtkWidget *button; - GtkTreeIter iter; - GalViewCollectionItem *item = NULL; - GalViewClass *gvclass = NULL; - - if (gtk_tree_selection_get_selected (selection, &dialog->model, &iter)) { - gtk_tree_model_get (dialog->model, &iter, COL_GALVIEW_DATA, &item, -1); - - if (item && item->view) - gvclass = GAL_VIEW_GET_CLASS (item->view); - } - - button = e_builder_get_widget (dialog->builder, "button-delete"); - gtk_widget_set_sensitive (GTK_WIDGET (button), item && !item->built_in); - - button = e_builder_get_widget (dialog->builder, "button-modify"); - gtk_widget_set_sensitive (GTK_WIDGET (button), item && !item->built_in && gvclass && gvclass->edit != NULL); -} - -static void -gdvd_connect_signal (GalDefineViewsDialog *dialog, - const gchar *widget_name, - const gchar *signal, - GCallback handler) -{ - GtkWidget *widget; - - widget = e_builder_get_widget (dialog->builder, widget_name); - - if (widget) - g_signal_connect (widget, signal, handler, dialog); -} - -static void -dialog_response (GalDefineViewsDialog *dialog, - gint response_id, - gpointer data) -{ - gal_view_collection_save (dialog->collection); -} - -static void -gal_define_views_dialog_init (GalDefineViewsDialog *dialog) -{ - GtkWidget *content_area; - GtkWidget *parent; - GtkWidget *widget; - GtkTreeSelection *selection; - - dialog->collection = NULL; - - dialog->builder = gtk_builder_new (); - e_load_ui_builder_definition (dialog->builder, "gal-define-views.ui"); - - widget = e_builder_get_widget (dialog->builder, "table-top"); - if (!widget) { - return; - } - - g_object_ref (widget); - - parent = gtk_widget_get_parent (widget); - gtk_container_remove (GTK_CONTAINER (parent), widget); - gtk_window_set_default_size (GTK_WINDOW (dialog), 360, 270); - gtk_container_set_border_width (GTK_CONTAINER (dialog), 6); - gtk_container_set_border_width (GTK_CONTAINER (widget), 6); - - content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); - gtk_box_pack_start (GTK_BOX (content_area), widget, TRUE, TRUE, 0); - - g_object_unref (widget); - - gtk_dialog_add_buttons ( - GTK_DIALOG (dialog), - GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, - NULL); - - dialog->treeview = GTK_TREE_VIEW (e_builder_get_widget (dialog->builder, "treeview1")); - gtk_tree_view_set_reorderable (GTK_TREE_VIEW (dialog->treeview), FALSE); - gtk_tree_view_set_headers_visible (dialog->treeview, TRUE); - - gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE); - - gdvd_connect_signal (dialog, "button-new", "clicked", G_CALLBACK (gdvd_button_new_callback)); - gdvd_connect_signal (dialog, "button-modify", "clicked", G_CALLBACK (gdvd_button_modify_callback)); - gdvd_connect_signal (dialog, "button-delete", "clicked", G_CALLBACK (gdvd_button_delete_callback)); - g_signal_connect ( - dialog, "response", - G_CALLBACK (dialog_response), NULL); - - selection = gtk_tree_view_get_selection (dialog->treeview); - g_signal_connect ( - selection, "changed", - G_CALLBACK (gdvd_selection_changed_callback), dialog); - gdvd_selection_changed_callback (selection, dialog); - - gtk_widget_show (GTK_WIDGET (dialog)); -} - -static void -gal_define_views_dialog_dispose (GObject *object) -{ - GalDefineViewsDialog *gal_define_views_dialog = GAL_DEFINE_VIEWS_DIALOG (object); - - if (gal_define_views_dialog->builder) - g_object_unref (gal_define_views_dialog->builder); - gal_define_views_dialog->builder = NULL; - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (gal_define_views_dialog_parent_class)->dispose (object); -} - -static void -gal_define_views_dialog_set_collection (GalDefineViewsDialog *dialog, - GalViewCollection *collection) -{ - gint i; - GtkListStore *store; - GtkCellRenderer *renderer; - dialog->collection = collection; - - store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER); - - for (i = 0; i < collection->view_count; i++) { - GalViewCollectionItem *item = collection->view_data[i]; - GtkTreeIter iter; - - /* hide built in views */ - /*if (item->built_in == 1) - continue;*/ - - gchar *title = NULL; - title = e_str_without_underscores (item->title); - - gtk_list_store_append (store, &iter); - gtk_list_store_set ( - store, &iter, - COL_GALVIEW_NAME, title, - COL_GALVIEW_DATA, item, - -1); - - g_free (title); - } - - gtk_tree_sortable_set_sort_column_id ( - GTK_TREE_SORTABLE (store), - COL_GALVIEW_NAME, GTK_SORT_ASCENDING); - - /* attaching treeview to model */ - gtk_tree_view_set_model (dialog->treeview, GTK_TREE_MODEL (store)); - gtk_tree_view_set_search_column (dialog->treeview, COL_GALVIEW_NAME); - - dialog->model = GTK_TREE_MODEL (store); - - renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes ( - dialog->treeview, - COL_GALVIEW_NAME, _("Name"), - renderer, "text", COL_GALVIEW_NAME, - NULL); - - /* set sort column */ - gtk_tree_sortable_set_sort_column_id ( - GTK_TREE_SORTABLE (dialog->model), - COL_GALVIEW_NAME, GTK_SORT_ASCENDING); - - if (dialog->builder) { - GtkWidget *widget = e_builder_get_widget (dialog->builder, "label-views"); - if (widget && GTK_IS_LABEL (widget)) { - if (collection->title) { - gchar *text = g_strdup_printf ( - _("Define Views for %s"), - collection->title); - gtk_label_set_text ( - GTK_LABEL (widget), - text); - gtk_window_set_title (GTK_WINDOW (dialog), text); - g_free (text); - } else { - gtk_label_set_text ( - GTK_LABEL (widget), - _("Define Views")); - gtk_window_set_title ( - GTK_WINDOW (dialog), - _("Define Views")); - } - } - } -} - -/** - * gal_define_views_dialog_new - * - * Returns a new dialog for defining views. - * - * Returns: The GalDefineViewsDialog. - */ -GtkWidget * -gal_define_views_dialog_new (GalViewCollection *collection) -{ - GtkWidget *widget = g_object_new (GAL_TYPE_DEFINE_VIEWS_DIALOG, NULL); - gal_define_views_dialog_set_collection (GAL_DEFINE_VIEWS_DIALOG (widget), collection); - return widget; -} - -static void -gal_define_views_dialog_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - GalDefineViewsDialog *dialog; - - dialog = GAL_DEFINE_VIEWS_DIALOG (object); - - switch (property_id) { - case PROP_COLLECTION: - if (g_value_get_object (value)) - gal_define_views_dialog_set_collection (dialog, GAL_VIEW_COLLECTION (g_value_get_object (value))); - else - gal_define_views_dialog_set_collection (dialog, NULL); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - return; - } -} - -static void -gal_define_views_dialog_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - GalDefineViewsDialog *dialog; - - dialog = GAL_DEFINE_VIEWS_DIALOG (object); - - switch (property_id) { - case PROP_COLLECTION: - g_value_set_object (value, dialog->collection); - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} diff --git a/widgets/menus/gal-define-views-dialog.h b/widgets/menus/gal-define-views-dialog.h deleted file mode 100644 index feb349e2d3..0000000000 --- a/widgets/menus/gal-define-views-dialog.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Chris Lahey - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef GAL_DEFINE_VIEWS_DIALOG_H -#define GAL_DEFINE_VIEWS_DIALOG_H - -#include -#include - -/* Standard GObject macros */ -#define GAL_TYPE_DEFINE_VIEWS_DIALOG \ - (gal_define_views_dialog_get_type ()) -#define GAL_DEFINE_VIEWS_DIALOG(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), GAL_TYPE_DEFINE_VIEWS_DIALOG, GalDefineViewsDialog)) -#define GAL_DEFINE_VIEWS_DIALOG_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), GAL_TYPE_DEFINE_VIEWS_DIALOG, GalDefineViewsDialogClass)) -#define GAL_IS_DEFINE_VIEWS_DIALOG(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), GAL_TYPE_DEFINE_VIEWS_DIALOG)) -#define GAL_IS_DEFINE_VIEWS_DIALOG_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), GAL_TYPE_DEFINE_VIEWS_DIALOG)) -#define GAL_DEFINE_VIEWS_DIALOG_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), GAL_TYPE_DEFINE_VIEWS_DIALOG, GalDefineViewsDialogClass)) - -G_BEGIN_DECLS - -typedef struct _GalDefineViewsDialog GalDefineViewsDialog; -typedef struct _GalDefineViewsDialogClass GalDefineViewsDialogClass; - -struct _GalDefineViewsDialog { - GtkDialog parent; - - /* item specific fields */ - GtkBuilder *builder; - GtkTreeView *treeview; - GtkTreeModel *model; - - GalViewCollection *collection; -}; - -struct _GalDefineViewsDialogClass { - GtkDialogClass parent_class; -}; - -GType gal_define_views_dialog_get_type (void); -GtkWidget * gal_define_views_dialog_new (GalViewCollection *collection); - -G_END_DECLS - -#endif /* GAL_DEFINE_VIEWS_DIALOG_H */ diff --git a/widgets/menus/gal-define-views-model.c b/widgets/menus/gal-define-views-model.c deleted file mode 100644 index d9432d24cc..0000000000 --- a/widgets/menus/gal-define-views-model.c +++ /dev/null @@ -1,353 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Chris Lahey - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include - -#include -#include "e-util/e-util.h" - -#include "gal-define-views-model.h" - -G_DEFINE_TYPE (GalDefineViewsModel, gal_define_views_model, E_TYPE_TABLE_MODEL) - -enum { - PROP_0, - PROP_EDITABLE, - PROP_COLLECTION -}; - -static void -gal_define_views_model_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - GalDefineViewsModel *model; - - model = GAL_DEFINE_VIEWS_MODEL (object); - - switch (property_id) { - case PROP_EDITABLE: - model->editable = g_value_get_boolean (value); - return; - - case PROP_COLLECTION: - e_table_model_pre_change (E_TABLE_MODEL (object)); - if (g_value_get_object (value)) - model->collection = GAL_VIEW_COLLECTION ( - g_value_get_object (value)); - else - model->collection = NULL; - e_table_model_changed (E_TABLE_MODEL (object)); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -gal_define_views_model_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - GalDefineViewsModel *model; - - model = GAL_DEFINE_VIEWS_MODEL (object); - - switch (property_id) { - case PROP_EDITABLE: - g_value_set_boolean (value, model->editable); - return; - - case PROP_COLLECTION: - g_value_set_object (value, model->collection); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -gdvm_dispose (GObject *object) -{ - GalDefineViewsModel *model = GAL_DEFINE_VIEWS_MODEL (object); - - if (model->collection) - g_object_unref (model->collection); - model->collection = NULL; - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (gal_define_views_model_parent_class)->dispose (object); -} - -/* This function returns the number of columns in our ETableModel. */ -static gint -gdvm_col_count (ETableModel *etc) -{ - return 1; -} - -/* This function returns the number of rows in our ETableModel. */ -static gint -gdvm_row_count (ETableModel *etc) -{ - GalDefineViewsModel *views = GAL_DEFINE_VIEWS_MODEL (etc); - if (views->collection) - return gal_view_collection_get_count (views->collection); - else - return 0; -} - -/* This function returns the value at a particular point in our ETableModel. */ -static gpointer -gdvm_value_at (ETableModel *etc, - gint col, - gint row) -{ - GalDefineViewsModel *views = GAL_DEFINE_VIEWS_MODEL (etc); - GalView *view; - const gchar *value; - - view = gal_view_collection_get_view (views->collection, row); - value = gal_view_get_title (view); - - return (gpointer) ((value != NULL) ? value : ""); -} - -/* This function sets the value at a particular point in our ETableModel. */ -static void -gdvm_set_value_at (ETableModel *etc, - gint col, - gint row, - gconstpointer val) -{ - GalDefineViewsModel *views = GAL_DEFINE_VIEWS_MODEL (etc); - if (views->editable) { - GalView *view; - - view = gal_view_collection_get_view (views->collection, row); - - e_table_model_pre_change (etc); - gal_view_set_title (view, val); - e_table_model_cell_changed (etc, col, row); - } -} - -/* This function returns whether a particular cell is editable. */ -static gboolean -gdvm_is_cell_editable (ETableModel *etc, - gint col, - gint row) -{ - return GAL_DEFINE_VIEWS_MODEL (etc)->editable; -} - -static void -gdvm_append_row (ETableModel *etm, - ETableModel *source, - gint row) -{ -} - -/* This function duplicates the value passed to it. */ -static gpointer -gdvm_duplicate_value (ETableModel *etc, - gint col, - gconstpointer value) -{ - return g_strdup (value); -} - -/* This function frees the value passed to it. */ -static void -gdvm_free_value (ETableModel *etc, - gint col, - gpointer value) -{ - g_free (value); -} - -static gpointer -gdvm_initialize_value (ETableModel *etc, - gint col) -{ - return g_strdup (""); -} - -static gboolean -gdvm_value_is_empty (ETableModel *etc, - gint col, - gconstpointer value) -{ - return !(value && *(gchar *) value); -} - -static gchar * -gdvm_value_to_string (ETableModel *etc, - gint col, - gconstpointer value) -{ - return g_strdup (value); -} - -/** - * gal_define_views_model_append - * @model: The model to add to. - * @view: The view to add. - * - * Adds the given view to the gal define views model. - */ -void -gal_define_views_model_append (GalDefineViewsModel *model, - GalView *view) -{ - ETableModel *etm = E_TABLE_MODEL (model); - - e_table_model_pre_change (etm); - gal_view_collection_append (model->collection, view); - e_table_model_row_inserted ( - etm, gal_view_collection_get_count (model->collection) - 1); -} - -static void -gal_define_views_model_class_init (GalDefineViewsModelClass *class) -{ - ETableModelClass *model_class = E_TABLE_MODEL_CLASS (class); - GObjectClass *object_class = G_OBJECT_CLASS (class); - - object_class->dispose = gdvm_dispose; - object_class->set_property = gal_define_views_model_set_property; - object_class->get_property = gal_define_views_model_get_property; - - g_object_class_install_property ( - object_class, - PROP_EDITABLE, - g_param_spec_boolean ( - "editable", - "Editable", - NULL, - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - object_class, - PROP_COLLECTION, - g_param_spec_object ( - "collection", - "Collection", - NULL, - GAL_VIEW_COLLECTION_TYPE, - G_PARAM_READWRITE)); - - model_class->column_count = gdvm_col_count; - model_class->row_count = gdvm_row_count; - model_class->value_at = gdvm_value_at; - model_class->set_value_at = gdvm_set_value_at; - model_class->is_cell_editable = gdvm_is_cell_editable; - model_class->append_row = gdvm_append_row; - model_class->duplicate_value = gdvm_duplicate_value; - model_class->free_value = gdvm_free_value; - model_class->initialize_value = gdvm_initialize_value; - model_class->value_is_empty = gdvm_value_is_empty; - model_class->value_to_string = gdvm_value_to_string; -} - -static void -gal_define_views_model_init (GalDefineViewsModel *model) -{ - model->collection = NULL; -} - -/** - * gal_define_views_model_new - * - * Returns a new define views model. This is a list of views as an - * ETable for use in the GalDefineViewsDialog. - * - * Returns: The new GalDefineViewsModel. - */ -ETableModel * -gal_define_views_model_new (void) -{ - GalDefineViewsModel *et; - - et = g_object_new (GAL_DEFINE_VIEWS_MODEL_TYPE, NULL); - - return E_TABLE_MODEL (et); -} - -/** - * gal_define_views_model_get_view: - * @model: The GalDefineViewsModel. - * @n: Which view to get. - * - * Gets the nth view. - * - * Returns: The view. - */ -GalView * -gal_define_views_model_get_view (GalDefineViewsModel *model, - gint n) -{ - return gal_view_collection_get_view (model->collection, n); -} - -/** - * gal_define_views_model_delete_view: - * @model: The GalDefineViewsModel. - * @n: Which view to delete. - * - * Deletes the nth view. - */ -void -gal_define_views_model_delete_view (GalDefineViewsModel *model, - gint n) -{ - e_table_model_pre_change (E_TABLE_MODEL (model)); - gal_view_collection_delete_view (model->collection, n); - e_table_model_row_deleted (E_TABLE_MODEL (model), n); -} - -/** - * gal_define_views_model_copy_view: - * @model: The GalDefineViewsModel. - * @n: Which view to copy. - * - * Copys the nth view. - */ -void -gal_define_views_model_copy_view (GalDefineViewsModel *model, - gint n) -{ - ETableModel *etm = E_TABLE_MODEL (model); - e_table_model_pre_change (etm); - gal_view_collection_copy_view (model->collection, n); - e_table_model_row_inserted ( - etm, gal_view_collection_get_count (model->collection) - 1); -} diff --git a/widgets/menus/gal-define-views-model.h b/widgets/menus/gal-define-views-model.h deleted file mode 100644 index cc7b7a5aa4..0000000000 --- a/widgets/menus/gal-define-views-model.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Chris Lahey - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef _GAL_DEFINE_VIEWS_MODEL_H_ -#define _GAL_DEFINE_VIEWS_MODEL_H_ - -#include -#include -#include - -G_BEGIN_DECLS - -#define GAL_DEFINE_VIEWS_MODEL_TYPE (gal_define_views_model_get_type ()) -#define GAL_DEFINE_VIEWS_MODEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GAL_DEFINE_VIEWS_MODEL_TYPE, GalDefineViewsModel)) -#define GAL_DEFINE_VIEWS_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GAL_DEFINE_VIEWS_MODEL_TYPE, GalDefineViewsModelClass)) -#define GAL_IS_DEFINE_VIEWS_MODEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GAL_DEFINE_VIEWS_MODEL_TYPE)) -#define GAL_IS_DEFINE_VIEWS_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GAL_DEFINE_VIEWS_MODEL_TYPE)) - -typedef struct { - ETableModel parent; - - /* item specific fields */ - GalViewCollection *collection; - - guint editable : 1; -} GalDefineViewsModel; - -typedef struct { - ETableModelClass parent_class; -} GalDefineViewsModelClass; - -GType gal_define_views_model_get_type (void); -ETableModel *gal_define_views_model_new (void); - -void gal_define_views_model_append (GalDefineViewsModel *model, - GalView *view); -GalView *gal_define_views_model_get_view (GalDefineViewsModel *model, - gint i); -void gal_define_views_model_delete_view (GalDefineViewsModel *model, - gint i); -void gal_define_views_model_copy_view (GalDefineViewsModel *model, - gint i); - -G_END_DECLS - -#endif /* _GAL_DEFINE_VIEWS_MODEL_H_ */ diff --git a/widgets/menus/gal-define-views.ui b/widgets/menus/gal-define-views.ui deleted file mode 100644 index b3314aa4ee..0000000000 --- a/widgets/menus/gal-define-views.ui +++ /dev/null @@ -1,177 +0,0 @@ - - - - - Define Views for "%s" - GDK_WINDOW_TYPE_HINT_NORMAL - - - True - 6 - - - True - 2 - 1 - 6 - 6 - - - True - 0 - Define Views for %s - - - GTK_FILL - - - - - - True - 6 - 6 - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - True - True - True - - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 6 - GTK_BUTTONBOX_START - - - True - True - gtk-new - True - - - False - False - - - - - True - False - True - True - - - True - 0 - 0 - - - True - 2 - - - True - gtk-properties - - - False - False - - - - - True - _Edit - True - - - False - False - 1 - - - - - - - - - False - False - 1 - - - - - True - True - gtk-delete - True - - - False - False - 2 - - - - - False - False - 1 - - - - - 1 - 2 - - - - - 12 - 2 - - - - - True - GTK_BUTTONBOX_END - - - True - True - True - gtk-close - True - - - - - False - GTK_PACK_END - - - - - - button7 - - - diff --git a/widgets/menus/gal-view-collection.c b/widgets/menus/gal-view-collection.c deleted file mode 100644 index 85dcc32f13..0000000000 --- a/widgets/menus/gal-view-collection.c +++ /dev/null @@ -1,829 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Chris Lahey - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include - -#include -#include - -#include -#include "e-util/e-util.h" -#include "libevolution-utils/e-xml-utils.h" -#include "e-util/e-unicode.h" - -#include "gal-view-collection.h" - -G_DEFINE_TYPE (GalViewCollection, gal_view_collection, G_TYPE_OBJECT) - -#define d(x) - -enum { - DISPLAY_VIEW, - CHANGED, - LAST_SIGNAL -}; - -static guint gal_view_collection_signals[LAST_SIGNAL] = { 0, }; - -/** - * gal_view_collection_display_view: - * @collection: The GalViewCollection to send the signal on. - * @view: The view to display. - * - */ -void -gal_view_collection_display_view (GalViewCollection *collection, - GalView *view) -{ - g_return_if_fail (GAL_IS_VIEW_COLLECTION (collection)); - g_return_if_fail (GAL_IS_VIEW (view)); - - g_signal_emit ( - collection, - gal_view_collection_signals[DISPLAY_VIEW], 0, - view); -} - -static void -gal_view_collection_changed (GalViewCollection *collection) -{ - g_return_if_fail (GAL_IS_VIEW_COLLECTION (collection)); - - g_signal_emit ( - collection, - gal_view_collection_signals[CHANGED], 0); -} - -static void -gal_view_collection_item_free (GalViewCollectionItem *item) -{ - g_free (item->id); - if (item->view) { - if (item->view_changed_id) - g_signal_handler_disconnect ( - item->view, - item->view_changed_id); - g_object_unref (item->view); - } - g_free (item); -} - -static gchar * -gal_view_generate_string (GalViewCollection *collection, - GalView *view, - gint which) -{ - gchar *ret_val; - gchar *pointer; - - if (which == 1) - ret_val = g_strdup (gal_view_get_title (view)); - else - ret_val = g_strdup_printf ("%s_%d", gal_view_get_title (view), which); - for (pointer = ret_val; *pointer; pointer = g_utf8_next_char (pointer)) { - if (!g_unichar_isalnum (g_utf8_get_char (pointer))) { - gchar *ptr = pointer; - for (; ptr < g_utf8_next_char (pointer); *ptr = '_', ptr++) - ; - } - } - return ret_val; -} - -static gint -gal_view_check_string (GalViewCollection *collection, - gchar *string) -{ - gint i; - - if (!strcmp (string, "current_view")) - return FALSE; - - for (i = 0; i < collection->view_count; i++) { - if (!strcmp (string, collection->view_data[i]->id)) - return FALSE; - } - for (i = 0; i < collection->removed_view_count; i++) { - if (!strcmp (string, collection->removed_view_data[i]->id)) - return FALSE; - } - return TRUE; -} - -static gchar * -gal_view_generate_id (GalViewCollection *collection, - GalView *view) -{ - gint i; - for (i = 1; TRUE; i++) { - gchar *try; - - try = gal_view_generate_string (collection, view, i); - if (gal_view_check_string (collection, try)) - return try; - g_free (try); - } -} - -static void -gal_view_collection_dispose (GObject *object) -{ - GalViewCollection *collection = GAL_VIEW_COLLECTION (object); - gint i; - - for (i = 0; i < collection->view_count; i++) { - gal_view_collection_item_free (collection->view_data[i]); - } - g_free (collection->view_data); - collection->view_data = NULL; - collection->view_count = 0; - - g_list_foreach ( - collection->factory_list, - (GFunc) g_object_unref, NULL); - g_list_free (collection->factory_list); - collection->factory_list = NULL; - - for (i = 0; i < collection->removed_view_count; i++) { - gal_view_collection_item_free (collection->removed_view_data[i]); - } - g_free (collection->removed_view_data); - collection->removed_view_data = NULL; - collection->removed_view_count = 0; - - g_free (collection->system_dir); - collection->system_dir = NULL; - - g_free (collection->local_dir); - collection->local_dir = NULL; - - g_free (collection->default_view); - collection->default_view = NULL; - - g_free (collection->title); - collection->title = NULL; - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (gal_view_collection_parent_class)->dispose (object); -} - -static void -gal_view_collection_class_init (GalViewCollectionClass *class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (class); - - object_class->dispose = gal_view_collection_dispose; - - gal_view_collection_signals[DISPLAY_VIEW] = g_signal_new ( - "display_view", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GalViewCollectionClass, display_view), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, - GAL_TYPE_VIEW); - - gal_view_collection_signals[CHANGED] = g_signal_new ( - "changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GalViewCollectionClass, changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - class->display_view = NULL; - class->changed = NULL; -} - -static void -gal_view_collection_init (GalViewCollection *collection) -{ - collection->view_data = NULL; - collection->view_count = 0; - collection->factory_list = NULL; - - collection->removed_view_data = NULL; - collection->removed_view_count = 0; - - collection->system_dir = NULL; - collection->local_dir = NULL; - - collection->loaded = FALSE; - collection->default_view = NULL; - collection->default_view_built_in = TRUE; - - collection->title = NULL; -} - -/** - * gal_view_collection_new: - * - * A collection of views and view factories. - */ -GalViewCollection * -gal_view_collection_new (void) -{ - return g_object_new (GAL_VIEW_COLLECTION_TYPE, NULL); -} - -void -gal_view_collection_set_title (GalViewCollection *collection, - const gchar *title) -{ - g_free (collection->title); - collection->title = g_strdup (title); -} - -/** - * gal_view_collection_set_storage_directories - * @collection: The view collection to initialize - * @system_dir: The location of the system built in views - * @local_dir: The location to store the users set up views - * - * Sets up the GalViewCollection. - */ -void -gal_view_collection_set_storage_directories (GalViewCollection *collection, - const gchar *system_dir, - const gchar *local_dir) -{ - g_return_if_fail (GAL_IS_VIEW_COLLECTION (collection)); - g_return_if_fail (system_dir != NULL); - g_return_if_fail (local_dir != NULL); - - g_free (collection->system_dir); - g_free (collection->local_dir); - - collection->system_dir = g_strdup (system_dir); - collection->local_dir = g_strdup (local_dir); -} - -/** - * gal_view_collection_add_factory - * @collection: The view collection to add a factory to - * @factory: The factory to add. The @collection will add a reference - * to the factory object, so you should unref it after calling this - * function if you no longer need it. - * - * Adds the given factory to this collection. This list is used both - * when loading views from their xml description as well as when the - * user tries to create a new view. - */ -void -gal_view_collection_add_factory (GalViewCollection *collection, - GalViewFactory *factory) -{ - g_return_if_fail (GAL_IS_VIEW_COLLECTION (collection)); - g_return_if_fail (GAL_IS_VIEW_FACTORY (factory)); - - g_object_ref (factory); - collection->factory_list = g_list_prepend (collection->factory_list, factory); -} - -static void -view_changed (GalView *view, - GalViewCollectionItem *item) -{ - item->changed = TRUE; - item->ever_changed = TRUE; - - g_signal_handler_block (item->view, item->view_changed_id); - gal_view_collection_changed (item->collection); - g_signal_handler_unblock (item->view, item->view_changed_id); -} - -/* Use factory list to load a GalView file. */ -static GalView * -gal_view_collection_real_load_view_from_file (GalViewCollection *collection, - const gchar *type, - const gchar *title, - const gchar *dir, - const gchar *filename) -{ - GalViewFactory *factory; - GList *factories; - - factory = NULL; - for (factories = collection->factory_list; factories; factories = factories->next) { - if (type && !strcmp (gal_view_factory_get_type_code (factories->data), type)) { - factory = factories->data; - break; - } - } - if (factory) { - GalView *view; - - view = gal_view_factory_new_view (factory, title); - gal_view_set_title (view, title); - gal_view_load (view, filename); - return view; - } - return NULL; -} - -GalView * -gal_view_collection_load_view_from_file (GalViewCollection *collection, - const gchar *type, - const gchar *filename) -{ - return gal_view_collection_real_load_view_from_file (collection, type, "", collection->local_dir, filename); -} - -static GalViewCollectionItem * -load_single_file (GalViewCollection *collection, - gchar *dir, - gboolean local, - xmlNode *node) -{ - GalViewCollectionItem *item; - item = g_new (GalViewCollectionItem, 1); - item->ever_changed = local; - item->changed = FALSE; - item->built_in = !local; - item->id = e_xml_get_string_prop_by_name (node, (const guchar *)"id"); - item->filename = e_xml_get_string_prop_by_name (node, (const guchar *)"filename"); - item->title = e_xml_get_translated_utf8_string_prop_by_name (node, (const guchar *)"title"); - item->type = e_xml_get_string_prop_by_name (node, (const guchar *)"type"); - item->collection = collection; - item->view_changed_id = 0; - - if (item->filename) { - gchar *fullpath; - fullpath = g_build_filename (dir, item->filename, NULL); - item->view = gal_view_collection_real_load_view_from_file (collection, item->type, item->title, dir, fullpath); - g_free (fullpath); - if (item->view) { - item->view_changed_id = g_signal_connect ( - item->view, "changed", - G_CALLBACK (view_changed), item); - } - } - return item; -} - -static void -load_single_dir (GalViewCollection *collection, - gchar *dir, - gboolean local) -{ - xmlDoc *doc = NULL; - xmlNode *root; - xmlNode *child; - gchar *filename = g_build_filename (dir, "galview.xml", NULL); - gchar *default_view; - - if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) { -#ifdef G_OS_WIN32 - gchar *locale_filename = g_win32_locale_filename_from_utf8 (filename); - if (locale_filename != NULL) - doc = xmlParseFile (locale_filename); - g_free (locale_filename); -#else - doc = xmlParseFile (filename); -#endif - } - - if (!doc) { - g_free (filename); - return; - } - root = xmlDocGetRootElement (doc); - for (child = root->xmlChildrenNode; child; child = child->next) { - gchar *id; - gboolean found = FALSE; - gint i; - - if (!strcmp ((gchar *) child->name, "text")) - continue; - - id = e_xml_get_string_prop_by_name (child, (const guchar *)"id"); - for (i = 0; i < collection->view_count; i++) { - if (!strcmp (id, collection->view_data[i]->id)) { - if (!local) - collection->view_data[i]->built_in = TRUE; - found = TRUE; - break; - } - } - if (!found) { - for (i = 0; i < collection->removed_view_count; i++) { - if (!strcmp (id, collection->removed_view_data[i]->id)) { - if (!local) - collection->removed_view_data[i]->built_in = TRUE; - found = TRUE; - break; - } - } - } - - if (!found) { - GalViewCollectionItem *item = load_single_file (collection, dir, local, child); - if (item->filename && *item->filename) { - collection->view_data = g_renew (GalViewCollectionItem *, collection->view_data, collection->view_count + 1); - collection->view_data[collection->view_count] = item; - collection->view_count++; - } else { - collection->removed_view_data = g_renew (GalViewCollectionItem *, collection->removed_view_data, collection->removed_view_count + 1); - collection->removed_view_data[collection->removed_view_count] = item; - collection->removed_view_count++; - } - } - g_free (id); - } - - default_view = e_xml_get_string_prop_by_name (root, (const guchar *)"default-view"); - if (default_view) { - if (local) - collection->default_view_built_in = FALSE; - else - collection->default_view_built_in = TRUE; - g_free (collection->default_view); - collection->default_view = default_view; - } - - g_free (filename); - xmlFreeDoc (doc); -} - -/** - * gal_view_collection_load - * @collection: The view collection to load information for - * - * Loads the data from the system and user directories specified in - * set storage directories. This is primarily for internal use by - * other parts of gal_view. - */ -void -gal_view_collection_load (GalViewCollection *collection) -{ - g_return_if_fail (GAL_IS_VIEW_COLLECTION (collection)); - g_return_if_fail (collection->local_dir != NULL); - g_return_if_fail (collection->system_dir != NULL); - g_return_if_fail (!collection->loaded); - - if ((g_mkdir_with_parents (collection->local_dir, 0777) == -1) && (errno != EEXIST)) - g_warning ("Unable to create dir %s: %s", collection->local_dir, g_strerror (errno)); - - load_single_dir (collection, collection->local_dir, TRUE); - load_single_dir (collection, collection->system_dir, FALSE); - gal_view_collection_changed (collection); - - collection->loaded = TRUE; -} - -/** - * gal_view_collection_save - * @collection: The view collection to save information for - * - * Saves the data to the user directory specified in set storage - * directories. This is primarily for internal use by other parts of - * gal_view. - */ -void -gal_view_collection_save (GalViewCollection *collection) -{ - gint i; - xmlDoc *doc; - xmlNode *root; - gchar *filename; - - g_return_if_fail (GAL_IS_VIEW_COLLECTION (collection)); - g_return_if_fail (collection->local_dir != NULL); - - doc = xmlNewDoc ((const guchar *)"1.0"); - root = xmlNewNode (NULL, (const guchar *)"GalViewCollection"); - xmlDocSetRootElement (doc, root); - - if (collection->default_view && !collection->default_view_built_in) { - e_xml_set_string_prop_by_name (root, (const guchar *)"default-view", collection->default_view); - } - - for (i = 0; i < collection->view_count; i++) { - xmlNode *child; - GalViewCollectionItem *item; - - item = collection->view_data[i]; - if (item->ever_changed) { - child = xmlNewChild (root, NULL, (const guchar *)"GalView", NULL); - e_xml_set_string_prop_by_name (child, (const guchar *)"id", item->id); - e_xml_set_string_prop_by_name (child, (const guchar *)"title", item->title); - e_xml_set_string_prop_by_name (child, (const guchar *)"filename", item->filename); - e_xml_set_string_prop_by_name (child, (const guchar *)"type", item->type); - - if (item->changed) { - filename = g_build_filename (collection->local_dir, item->filename, NULL); - gal_view_save (item->view, filename); - g_free (filename); - } - } - } - for (i = 0; i < collection->removed_view_count; i++) { - xmlNode *child; - GalViewCollectionItem *item; - - item = collection->removed_view_data[i]; - - child = xmlNewChild (root, NULL, (const guchar *)"GalView", NULL); - e_xml_set_string_prop_by_name (child, (const guchar *)"id", item->id); - e_xml_set_string_prop_by_name (child, (const guchar *)"title", item->title); - e_xml_set_string_prop_by_name (child, (const guchar *)"type", item->type); - } - filename = g_build_filename (collection->local_dir, "galview.xml", NULL); - if (e_xml_save_file (filename, doc) == -1) - g_warning ("Unable to save view to %s - %s", filename, g_strerror (errno)); - xmlFreeDoc (doc); - g_free (filename); -} - -/** - * gal_view_collection_get_count - * @collection: The view collection to count - * - * Calculates the number of views in the given collection. - * - * Returns: The number of views in the collection. - */ -gint -gal_view_collection_get_count (GalViewCollection *collection) -{ - g_return_val_if_fail (GAL_IS_VIEW_COLLECTION (collection), -1); - - return collection->view_count; -} - -/** - * gal_view_collection_get_view - * @collection: The view collection to query - * @n: The view to get. - * - * Returns: The nth view in the collection - */ -GalView * -gal_view_collection_get_view (GalViewCollection *collection, - gint n) -{ - g_return_val_if_fail (GAL_IS_VIEW_COLLECTION (collection), NULL); - g_return_val_if_fail (n < collection->view_count, NULL); - g_return_val_if_fail (n >= 0, NULL); - - return collection->view_data[n]->view; -} - -/** - * gal_view_collection_get_view_item - * @collection: The view collection to query - * @n: The view item to get. - * - * Returns: The nth view item in the collection - */ -GalViewCollectionItem * -gal_view_collection_get_view_item (GalViewCollection *collection, - gint n) -{ - g_return_val_if_fail (GAL_IS_VIEW_COLLECTION (collection), NULL); - g_return_val_if_fail (n < collection->view_count, NULL); - g_return_val_if_fail (n >= 0, NULL); - - return collection->view_data[n]; -} - -gint -gal_view_collection_get_view_index_by_id (GalViewCollection *collection, - const gchar *view_id) -{ - gint i; - for (i = 0; i < collection->view_count; i++) { - if (!strcmp (collection->view_data[i]->id, view_id)) - return i; - } - return -1; -} - -gchar * -gal_view_collection_get_view_id_by_index (GalViewCollection *collection, - gint n) -{ - g_return_val_if_fail (GAL_IS_VIEW_COLLECTION (collection), NULL); - g_return_val_if_fail (n < collection->view_count, NULL); - g_return_val_if_fail (n >= 0, NULL); - - return g_strdup (collection->view_data[n]->id); -} - -void -gal_view_collection_append (GalViewCollection *collection, - GalView *view) -{ - GalViewCollectionItem *item; - - g_return_if_fail (GAL_IS_VIEW_COLLECTION (collection)); - g_return_if_fail (GAL_IS_VIEW (view)); - - item = g_new (GalViewCollectionItem, 1); - item->ever_changed = TRUE; - item->changed = TRUE; - item->built_in = FALSE; - item->title = g_strdup (gal_view_get_title (view)); - item->type = g_strdup (gal_view_get_type_code (view)); - item->id = gal_view_generate_id (collection, view); - item->filename = g_strdup_printf ("%s.galview", item->id); - item->view = view; - item->collection = collection; - g_object_ref (view); - - item->view_changed_id = g_signal_connect ( - item->view, "changed", - G_CALLBACK (view_changed), item); - - collection->view_data = g_renew (GalViewCollectionItem *, collection->view_data, collection->view_count + 1); - collection->view_data[collection->view_count] = item; - collection->view_count++; - - gal_view_collection_changed (collection); -} - -void -gal_view_collection_delete_view (GalViewCollection *collection, - gint i) -{ - GalViewCollectionItem *item; - - g_return_if_fail (GAL_IS_VIEW_COLLECTION (collection)); - g_return_if_fail (i >= 0 && i < collection->view_count); - - item = collection->view_data[i]; - memmove (collection->view_data + i, collection->view_data + i + 1, (collection->view_count - i - 1) * sizeof (GalViewCollectionItem *)); - collection->view_count--; - if (item->built_in) { - g_free (item->filename); - item->filename = NULL; - - collection->removed_view_data = g_renew (GalViewCollectionItem *, collection->removed_view_data, collection->removed_view_count + 1); - collection->removed_view_data[collection->removed_view_count] = item; - collection->removed_view_count++; - } else { - gal_view_collection_item_free (item); - } - - gal_view_collection_changed (collection); -} - -void -gal_view_collection_copy_view (GalViewCollection *collection, - gint i) -{ - GalViewCollectionItem *item; - GalView *view; - - g_return_if_fail (GAL_IS_VIEW_COLLECTION (collection)); - g_return_if_fail (i >= 0 && i < collection->view_count); - - view = collection->view_data[i]->view; - - item = g_new (GalViewCollectionItem, 1); - item->ever_changed = TRUE; - item->changed = FALSE; - item->built_in = FALSE; - item->title = g_strdup (gal_view_get_title (view)); - item->type = g_strdup (gal_view_get_type_code (view)); - item->id = gal_view_generate_id (collection, view); - item->filename = g_strdup_printf ("%s.galview", item->id); - item->view = gal_view_clone (view); - item->collection = collection; - - item->view_changed_id = g_signal_connect ( - item->view, "changed", - G_CALLBACK (view_changed), item); - - collection->view_data = g_renew (GalViewCollectionItem *, collection->view_data, collection->view_count + 1); - collection->view_data[collection->view_count] = item; - collection->view_count++; - - gal_view_collection_changed (collection); -} - -gboolean -gal_view_collection_loaded (GalViewCollection *collection) -{ - return collection->loaded; -} - -const gchar * -gal_view_collection_append_with_title (GalViewCollection *collection, - const gchar *title, - GalView *view) -{ - GalViewCollectionItem *item; - - g_return_val_if_fail (GAL_IS_VIEW_COLLECTION (collection), NULL); - g_return_val_if_fail (GAL_IS_VIEW (view), NULL); - - gal_view_set_title (view, title); - - d (g_print ("%s: %p\n", G_STRFUNC, view)); - - item = g_new (GalViewCollectionItem, 1); - item->ever_changed = TRUE; - item->changed = TRUE; - item->built_in = FALSE; - item->title = g_strdup (gal_view_get_title (view)); - item->type = g_strdup (gal_view_get_type_code (view)); - item->id = gal_view_generate_id (collection, view); - item->filename = g_strdup_printf ("%s.galview", item->id); - item->view = view; - item->collection = collection; - g_object_ref (view); - - item->view_changed_id = g_signal_connect ( - item->view, "changed", - G_CALLBACK (view_changed), item); - - collection->view_data = g_renew (GalViewCollectionItem *, collection->view_data, collection->view_count + 1); - collection->view_data[collection->view_count] = item; - collection->view_count++; - - gal_view_collection_changed (collection); - return item->id; -} - -const gchar * -gal_view_collection_set_nth_view (GalViewCollection *collection, - gint i, - GalView *view) -{ - GalViewCollectionItem *item; - - g_return_val_if_fail (GAL_IS_VIEW_COLLECTION (collection), NULL); - g_return_val_if_fail (GAL_IS_VIEW (view), NULL); - g_return_val_if_fail (i >= 0, NULL); - g_return_val_if_fail (i < collection->view_count, NULL); - - d (g_print ("%s: %p\n", G_STRFUNC, view)); - - item = collection->view_data[i]; - - gal_view_set_title (view, item->title); - g_object_ref (view); - if (item->view) { - g_signal_handler_disconnect ( - item->view, - item->view_changed_id); - g_object_unref (item->view); - } - item->view = view; - - item->ever_changed = TRUE; - item->changed = TRUE; - item->type = g_strdup (gal_view_get_type_code (view)); - - item->view_changed_id = g_signal_connect ( - item->view, "changed", - G_CALLBACK (view_changed), item); - - gal_view_collection_changed (collection); - return item->id; -} - -const gchar * -gal_view_collection_get_default_view (GalViewCollection *collection) -{ - return collection->default_view; -} - -void -gal_view_collection_set_default_view (GalViewCollection *collection, - const gchar *id) -{ - g_free (collection->default_view); - collection->default_view = g_strdup (id); - gal_view_collection_changed (collection); - collection->default_view_built_in = FALSE; -} - diff --git a/widgets/menus/gal-view-collection.h b/widgets/menus/gal-view-collection.h deleted file mode 100644 index 143bee53d1..0000000000 --- a/widgets/menus/gal-view-collection.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Chris Lahey - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef _GAL_VIEW_SET_H_ -#define _GAL_VIEW_SET_H_ - -#include - -G_BEGIN_DECLS - -#define GAL_VIEW_COLLECTION_TYPE (gal_view_collection_get_type ()) -#define GAL_VIEW_COLLECTION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GAL_VIEW_COLLECTION_TYPE, GalViewCollection)) -#define GAL_VIEW_COLLECTION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GAL_VIEW_COLLECTION_TYPE, GalViewCollectionClass)) -#define GAL_IS_VIEW_COLLECTION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GAL_VIEW_COLLECTION_TYPE)) -#define GAL_IS_VIEW_COLLECTION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GAL_VIEW_COLLECTION_TYPE)) -#define GAL_VIEW_COLLECTION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GAL_VIEW_COLLECTION_TYPE, GalViewCollectionClass)) - -typedef struct GalViewCollectionItem GalViewCollectionItem; - -typedef struct { - GObject base; - - GalViewCollectionItem **view_data; - gint view_count; - - GList *factory_list; - - GalViewCollectionItem **removed_view_data; - gint removed_view_count; - - guint loaded : 1; - guint default_view_built_in : 1; - - gchar *system_dir; - gchar *local_dir; - - gchar *default_view; - - gchar *title; -} GalViewCollection; - -typedef struct { - GObjectClass parent_class; - - /* - * Signals - */ - void (*display_view) (GalViewCollection *collection, - GalView *view); - void (*changed) (GalViewCollection *collection); -} GalViewCollectionClass; - -struct GalViewCollectionItem { - GalView *view; - gchar *id; - guint changed : 1; - guint ever_changed : 1; - guint built_in : 1; - gchar *filename; - gchar *title; - gchar *type; - GalViewCollection *collection; - guint view_changed_id; -}; - -/* Standard functions */ -GType gal_view_collection_get_type (void); -GalViewCollection *gal_view_collection_new (void); - -void gal_view_collection_set_title (GalViewCollection *collection, - const gchar *title); -/* Set up the view collection. Call these two functions before ever doing load or save and never call them again. */ -void gal_view_collection_set_storage_directories (GalViewCollection *collection, - const gchar *system_dir, - const gchar *local_dir); -void gal_view_collection_add_factory (GalViewCollection *collection, - GalViewFactory *factory); - -/* Send the display view signal. This function is deprecated. */ -void gal_view_collection_display_view (GalViewCollection *collection, - GalView *view); - -/* Query the view collection. */ -gint gal_view_collection_get_count (GalViewCollection *collection); -GalView *gal_view_collection_get_view (GalViewCollection *collection, - gint n); -GalViewCollectionItem *gal_view_collection_get_view_item (GalViewCollection *collection, - gint n); -gint gal_view_collection_get_view_index_by_id (GalViewCollection *collection, - const gchar *view_id); -gchar *gal_view_collection_get_view_id_by_index (GalViewCollection *collection, - gint n); - -/* Manipulate the view collection */ -void gal_view_collection_append (GalViewCollection *collection, - GalView *view); -void gal_view_collection_delete_view (GalViewCollection *collection, - gint i); -void gal_view_collection_copy_view (GalViewCollection *collection, - gint i); -/* Call set_storage_directories and add factories for anything that - * might be found there before doing either of these. */ -void gal_view_collection_load (GalViewCollection *collection); -void gal_view_collection_save (GalViewCollection *collection); -gboolean gal_view_collection_loaded (GalViewCollection *collection); - -/* Use factory list to load a GalView file. */ -GalView *gal_view_collection_load_view_from_file (GalViewCollection *collection, - const gchar *type, - const gchar *filename); - -/* Returns id of the new view. These functions are used for - * GalViewInstanceSaveAsDialog. */ -const gchar *gal_view_collection_append_with_title (GalViewCollection *collection, - const gchar *title, - GalView *view); -const gchar *gal_view_collection_set_nth_view (GalViewCollection *collection, - gint i, - GalView *view); - -const gchar *gal_view_collection_get_default_view (GalViewCollection *collection); -void gal_view_collection_set_default_view (GalViewCollection *collection, - const gchar *id); - -G_END_DECLS - -#endif /* _GAL_VIEW_COLLECTION_H_ */ diff --git a/widgets/menus/gal-view-etable.c b/widgets/menus/gal-view-etable.c deleted file mode 100644 index c259cc9004..0000000000 --- a/widgets/menus/gal-view-etable.c +++ /dev/null @@ -1,335 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Chris Lahey - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "table/e-table-config.h" - -#include "gal-view-etable.h" - -G_DEFINE_TYPE (GalViewEtable, gal_view_etable, GAL_TYPE_VIEW) - -static void -detach_table (GalViewEtable *view) -{ - if (view->table == NULL) - return; - if (view->table_state_changed_id) { - g_signal_handler_disconnect ( - view->table, - view->table_state_changed_id); - view->table_state_changed_id = 0; - } - g_object_unref (view->table); - view->table = NULL; -} - -static void -detach_tree (GalViewEtable *view) -{ - if (view->tree == NULL) - return; - if (view->tree_state_changed_id) { - g_signal_handler_disconnect ( - view->tree, - view->tree_state_changed_id); - view->tree_state_changed_id = 0; - } - g_object_unref (view->tree); - view->tree = NULL; -} - -static void -config_changed (ETableConfig *config, - GalViewEtable *view) -{ - ETableState *state; - if (view->state) - g_object_unref (view->state); - g_object_get ( - config, - "state", &state, - NULL); - view->state = e_table_state_duplicate (state); - g_object_unref (state); - - gal_view_changed (GAL_VIEW (view)); -} - -static void -gal_view_etable_edit (GalView *view, - GtkWindow *parent) -{ - GalViewEtable *etable_view = GAL_VIEW_ETABLE (view); - ETableConfig *config; - - config = e_table_config_new ( - etable_view->title, - etable_view->spec, - etable_view->state, - parent); - - g_signal_connect ( - config, "changed", - G_CALLBACK (config_changed), view); -} - -static void -gal_view_etable_load (GalView *view, - const gchar *filename) -{ - e_table_state_load_from_file (GAL_VIEW_ETABLE (view)->state, filename); -} - -static void -gal_view_etable_save (GalView *view, - const gchar *filename) -{ - e_table_state_save_to_file (GAL_VIEW_ETABLE (view)->state, filename); -} - -static const gchar * -gal_view_etable_get_title (GalView *view) -{ - return GAL_VIEW_ETABLE (view)->title; -} - -static void -gal_view_etable_set_title (GalView *view, - const gchar *title) -{ - g_free (GAL_VIEW_ETABLE (view)->title); - GAL_VIEW_ETABLE (view)->title = g_strdup (title); -} - -static const gchar * -gal_view_etable_get_type_code (GalView *view) -{ - return "etable"; -} - -static GalView * -gal_view_etable_clone (GalView *view) -{ - GalViewEtable *gve, *new; - - gve = GAL_VIEW_ETABLE (view); - - new = g_object_new (GAL_TYPE_VIEW_ETABLE, NULL); - new->spec = gve->spec; - new->title = g_strdup (gve->title); - g_object_unref (new->state); - new->state = e_table_state_duplicate (gve->state); - - g_object_ref (new->spec); - - return GAL_VIEW (new); -} - -static void -gal_view_etable_dispose (GObject *object) -{ - GalViewEtable *view = GAL_VIEW_ETABLE (object); - - gal_view_etable_detach (view); - - g_free (view->title); - view->title = NULL; - - if (view->spec) - g_object_unref (view->spec); - view->spec = NULL; - - if (view->state) - g_object_unref (view->state); - view->state = NULL; - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (gal_view_etable_parent_class)->dispose (object); -} - -static void -gal_view_etable_class_init (GalViewEtableClass *class) -{ - GalViewClass *gal_view_class = GAL_VIEW_CLASS (class); - GObjectClass *object_class = G_OBJECT_CLASS (class); - - gal_view_class->edit = gal_view_etable_edit; - gal_view_class->load = gal_view_etable_load; - gal_view_class->save = gal_view_etable_save; - gal_view_class->get_title = gal_view_etable_get_title; - gal_view_class->set_title = gal_view_etable_set_title; - gal_view_class->get_type_code = gal_view_etable_get_type_code; - gal_view_class->clone = gal_view_etable_clone; - - object_class->dispose = gal_view_etable_dispose; -} - -static void -gal_view_etable_init (GalViewEtable *gve) -{ - gve->spec = NULL; - gve->state = e_table_state_new (); - gve->title = NULL; -} - -/** - * gal_view_etable_new - * @spec: The ETableSpecification that this view will be based upon. - * @title: The name of the new view. - * - * Returns a new GalViewEtable. This is primarily for use by - * GalViewFactoryEtable. - * - * Returns: The new GalViewEtable. - */ -GalView * -gal_view_etable_new (ETableSpecification *spec, - const gchar *title) -{ - GalViewEtable *view; - - g_return_val_if_fail (E_IS_TABLE_SPECIFICATION (spec), NULL); - - view = g_object_new (GAL_TYPE_VIEW_ETABLE, NULL); - - return gal_view_etable_construct (view, spec, title); -} - -/** - * gal_view_etable_construct - * @view: The view to construct. - * @spec: The ETableSpecification that this view will be based upon. - * @title: The name of the new view. - * - * constructs the GalViewEtable. To be used by subclasses and - * language bindings. - * - * Returns: The GalViewEtable. - */ -GalView * -gal_view_etable_construct (GalViewEtable *view, - ETableSpecification *spec, - const gchar *title) -{ - g_return_val_if_fail (GAL_IS_VIEW_ETABLE (view), NULL); - g_return_val_if_fail (E_IS_TABLE_SPECIFICATION (spec), NULL); - - view->spec = g_object_ref (spec); - - if (view->state) - g_object_unref (view->state); - view->state = e_table_state_duplicate (spec->state); - - view->title = g_strdup (title); - - return GAL_VIEW (view); -} - -void -gal_view_etable_set_state (GalViewEtable *view, - ETableState *state) -{ - g_return_if_fail (GAL_IS_VIEW_ETABLE (view)); - g_return_if_fail (E_IS_TABLE_STATE (state)); - - if (view->state) - g_object_unref (view->state); - view->state = e_table_state_duplicate (state); - - gal_view_changed (GAL_VIEW (view)); -} - -static void -table_state_changed (ETable *table, - GalViewEtable *view) -{ - ETableState *state; - - state = e_table_get_state_object (table); - g_object_unref (view->state); - view->state = state; - - gal_view_changed (GAL_VIEW (view)); -} - -static void -tree_state_changed (ETree *tree, - GalViewEtable *view) -{ - ETableState *state; - - state = e_tree_get_state_object (tree); - g_object_unref (view->state); - view->state = state; - - gal_view_changed (GAL_VIEW (view)); -} - -void -gal_view_etable_attach_table (GalViewEtable *view, - ETable *table) -{ - g_return_if_fail (GAL_IS_VIEW_ETABLE (view)); - g_return_if_fail (E_IS_TABLE (table)); - - gal_view_etable_detach (view); - - view->table = table; - - e_table_set_state_object (view->table, view->state); - g_object_ref (view->table); - view->table_state_changed_id = g_signal_connect ( - view->table, "state_change", - G_CALLBACK (table_state_changed), view); -} - -void -gal_view_etable_attach_tree (GalViewEtable *view, - ETree *tree) -{ - g_return_if_fail (GAL_IS_VIEW_ETABLE (view)); - g_return_if_fail (E_IS_TREE (tree)); - - gal_view_etable_detach (view); - - view->tree = tree; - - e_tree_set_state_object (view->tree, view->state); - g_object_ref (view->tree); - view->tree_state_changed_id = g_signal_connect ( - view->tree, "state_change", - G_CALLBACK (tree_state_changed), view); -} - -void -gal_view_etable_detach (GalViewEtable *view) -{ - g_return_if_fail (GAL_IS_VIEW_ETABLE (view)); - - if (view->table != NULL) - detach_table (view); - if (view->tree != NULL) - detach_tree (view); -} diff --git a/widgets/menus/gal-view-etable.h b/widgets/menus/gal-view-etable.h deleted file mode 100644 index cfccf1e15b..0000000000 --- a/widgets/menus/gal-view-etable.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Chris Lahey - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef GAL_VIEW_ETABLE_H -#define GAL_VIEW_ETABLE_H - -#include -#include -#include
-#include
-#include
-#include
- -/* Standard GObject macros */ -#define GAL_TYPE_VIEW_ETABLE \ - (gal_view_etable_get_type ()) -#define GAL_VIEW_ETABLE(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), GAL_TYPE_VIEW_ETABLE, GalViewEtable)) -#define GAL_VIEW_ETABLE_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), GAL_TYPE_VIEW_ETABLE, GalViewEtableClass)) -#define GAL_IS_VIEW_ETABLE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), GAL_TYPE_VIEW_ETABLE)) -#define GAL_IS_VIEW_ETABLE_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), GAL_TYPE_VIEW_ETABLE)) -#define GAL_VIEW_ETABLE_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), GAL_TYPE_VIEW_ETABLE, GalViewEtableClass)) - -G_BEGIN_DECLS - -typedef struct _GalViewEtable GalViewEtable; -typedef struct _GalViewEtableClass GalViewEtableClass; - -struct _GalViewEtable { - GalView parent; - - ETableSpecification *spec; - ETableState *state; - gchar *title; - - ETable *table; - guint table_state_changed_id; - - ETree *tree; - guint tree_state_changed_id; -}; - -struct _GalViewEtableClass { - GalViewClass parent_class; -}; - -GType gal_view_etable_get_type (void); -GalView * gal_view_etable_new (ETableSpecification *spec, - const gchar *title); -GalView * gal_view_etable_construct (GalViewEtable *view, - ETableSpecification *spec, - const gchar *title); -void gal_view_etable_set_state (GalViewEtable *view, - ETableState *state); -void gal_view_etable_attach_table (GalViewEtable *view, - ETable *table); -void gal_view_etable_attach_tree (GalViewEtable *view, - ETree *tree); -void gal_view_etable_detach (GalViewEtable *view); - -G_END_DECLS - -#endif /* GAL_VIEW_ETABLE_H */ diff --git a/widgets/menus/gal-view-factory-etable.c b/widgets/menus/gal-view-factory-etable.c deleted file mode 100644 index 8570d3c98c..0000000000 --- a/widgets/menus/gal-view-factory-etable.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Chris Lahey - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include "e-util/e-util.h" - -#include "gal-view-etable.h" -#include "gal-view-factory-etable.h" - -#define GAL_VIEW_FACTORY_ETABLE_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), GAL_TYPE_VIEW_FACTORY_ETABLE, GalViewFactoryEtablePrivate)) - -struct _GalViewFactoryEtablePrivate { - ETableSpecification *specification; -}; - -enum { - PROP_0, - PROP_SPECIFICATION -}; - -G_DEFINE_TYPE ( - GalViewFactoryEtable, - gal_view_factory_etable, GAL_TYPE_VIEW_FACTORY) - -static void -view_factory_etable_set_specification (GalViewFactoryEtable *factory, - ETableSpecification *specification) -{ - g_return_if_fail (factory->priv->specification == NULL); - g_return_if_fail (E_IS_TABLE_SPECIFICATION (specification)); - - factory->priv->specification = g_object_ref (specification); -} - -static void -view_factory_etable_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SPECIFICATION: - view_factory_etable_set_specification ( - GAL_VIEW_FACTORY_ETABLE (object), - g_value_get_object (value)); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -view_factory_etable_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SPECIFICATION: - g_value_set_object ( - value, - gal_view_factory_etable_get_specification ( - GAL_VIEW_FACTORY_ETABLE (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -view_factory_etable_dispose (GObject *object) -{ - GalViewFactoryEtablePrivate *priv; - - priv = GAL_VIEW_FACTORY_ETABLE_GET_PRIVATE (object); - - if (priv->specification != NULL) { - g_object_unref (priv->specification); - priv->specification = NULL; - } - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (gal_view_factory_etable_parent_class)->dispose (object); -} - -static const gchar * -view_factory_etable_get_title (GalViewFactory *factory) -{ - return _("Table"); -} - -static const gchar * -view_factory_etable_get_type_code (GalViewFactory *factory) -{ - return "etable"; -} - -static GalView * -view_factory_etable_new_view (GalViewFactory *factory, - const gchar *name) -{ - GalViewFactoryEtablePrivate *priv; - - priv = GAL_VIEW_FACTORY_ETABLE_GET_PRIVATE (factory); - - return gal_view_etable_new (priv->specification, name); -} - -static void -gal_view_factory_etable_class_init (GalViewFactoryEtableClass *class) -{ - GObjectClass *object_class; - GalViewFactoryClass *view_factory_class; - - g_type_class_add_private (class, sizeof (GalViewFactoryEtablePrivate)); - - object_class = G_OBJECT_CLASS (class); - object_class->set_property = view_factory_etable_set_property; - object_class->get_property = view_factory_etable_get_property; - object_class->dispose = view_factory_etable_dispose; - - view_factory_class = GAL_VIEW_FACTORY_CLASS (class); - view_factory_class->get_title = view_factory_etable_get_title; - view_factory_class->get_type_code = view_factory_etable_get_type_code; - view_factory_class->new_view = view_factory_etable_new_view; - - g_object_class_install_property ( - object_class, - PROP_SPECIFICATION, - g_param_spec_object ( - "specification", - NULL, - NULL, - E_TYPE_TABLE_SPECIFICATION, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); -} - -static void -gal_view_factory_etable_init (GalViewFactoryEtable *factory) -{ - factory->priv = GAL_VIEW_FACTORY_ETABLE_GET_PRIVATE (factory); -} - -/** - * gal_view_etable_new: - * @specification: The spec to create GalViewEtables based upon. - * - * A new GalViewFactory for creating ETable views. Create one of - * these and pass it to GalViewCollection for use. - * - * Returns: The new GalViewFactoryEtable. - */ -GalViewFactory * -gal_view_factory_etable_new (ETableSpecification *specification) -{ - g_return_val_if_fail (E_IS_TABLE_SPECIFICATION (specification), NULL); - - return g_object_new ( - GAL_TYPE_VIEW_FACTORY_ETABLE, - "specification", specification, NULL); -} - -ETableSpecification * -gal_view_factory_etable_get_specification (GalViewFactoryEtable *factory) -{ - g_return_val_if_fail (GAL_IS_VIEW_FACTORY_ETABLE (factory), NULL); - - return factory->priv->specification; -} diff --git a/widgets/menus/gal-view-factory-etable.h b/widgets/menus/gal-view-factory-etable.h deleted file mode 100644 index a107b87083..0000000000 --- a/widgets/menus/gal-view-factory-etable.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Chris Lahey - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef GAL_VIEW_FACTORY_ETABLE_H -#define GAL_VIEW_FACTORY_ETABLE_H - -#include -#include -#include
- -/* Standard GObject macros */ -#define GAL_TYPE_VIEW_FACTORY_ETABLE \ - (gal_view_factory_etable_get_type ()) -#define GAL_VIEW_FACTORY_ETABLE(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), GAL_TYPE_VIEW_FACTORY_ETABLE, GalViewFactoryEtable)) -#define GAL_VIEW_FACTORY_ETABLE_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), GAL_TYPE_VIEW_FACTORY_ETABLE, GalViewFactoryEtableClass)) -#define GAL_IS_VIEW_FACTORY_ETABLE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), GAL_TYPE_VIEW_FACTORY_ETABLE)) -#define GAL_IS_VIEW_FACTORY_ETABLE_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), GAL_TYPE_VIEW_FACTORY_ETABLE)) -#define GAL_VIEW_FACTORY_ETABLE_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), GAL_TYPE_VIEW_FACTORY_ETABLE, GalViewFactoryEtableClass)) - -G_BEGIN_DECLS - -typedef struct _GalViewFactoryEtable GalViewFactoryEtable; -typedef struct _GalViewFactoryEtableClass GalViewFactoryEtableClass; -typedef struct _GalViewFactoryEtablePrivate GalViewFactoryEtablePrivate; - -struct _GalViewFactoryEtable { - GalViewFactory parent; - GalViewFactoryEtablePrivate *priv; -}; - -struct _GalViewFactoryEtableClass { - GalViewFactoryClass parent_class; -}; - -GType gal_view_factory_etable_get_type (void); -ETableSpecification * - gal_view_factory_etable_get_specification - (GalViewFactoryEtable *factory); -GalViewFactory *gal_view_factory_etable_new (ETableSpecification *specification); - -G_END_DECLS - -#endif /* GAL_VIEW_FACTORY_ETABLE_H */ diff --git a/widgets/menus/gal-view-factory.c b/widgets/menus/gal-view-factory.c deleted file mode 100644 index 0f311cf976..0000000000 --- a/widgets/menus/gal-view-factory.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Chris Lahey - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "gal-view-factory.h" - -#include - -G_DEFINE_TYPE (GalViewFactory, gal_view_factory, G_TYPE_OBJECT) - -/* XXX Should GalViewFactory be a GInterface? */ - -static void -gal_view_factory_class_init (GalViewFactoryClass *class) -{ -} - -static void -gal_view_factory_init (GalViewFactory *factory) -{ -} - -/** - * gal_view_factory_get_title: - * @factory: a #GalViewFactory - * - * Returns: The title of the factory. - */ -const gchar * -gal_view_factory_get_title (GalViewFactory *factory) -{ - GalViewFactoryClass *class; - - g_return_val_if_fail (GAL_IS_VIEW_FACTORY (factory), NULL); - - class = GAL_VIEW_FACTORY_GET_CLASS (factory); - g_return_val_if_fail (class->get_title != NULL, NULL); - - return class->get_title (factory); -} - -/** - * gal_view_factory_get_type_code: - * @factory: a #GalViewFactory - * - * Returns: The type code - */ -const gchar * -gal_view_factory_get_type_code (GalViewFactory *factory) -{ - GalViewFactoryClass *class; - - g_return_val_if_fail (GAL_IS_VIEW_FACTORY (factory), NULL); - - class = GAL_VIEW_FACTORY_GET_CLASS (factory); - g_return_val_if_fail (class->get_type_code != NULL, NULL); - - return class->get_type_code (factory); -} - -/** - * gal_view_factory_new_view: - * @factory: a #GalViewFactory - * @name: the name for the view - * - * Returns: The new view - */ -GalView * -gal_view_factory_new_view (GalViewFactory *factory, - const gchar *name) -{ - GalViewFactoryClass *class; - - g_return_val_if_fail (GAL_IS_VIEW_FACTORY (factory), NULL); - - class = GAL_VIEW_FACTORY_GET_CLASS (factory); - g_return_val_if_fail (class->new_view != NULL, NULL); - - return class->new_view (factory, name); -} - diff --git a/widgets/menus/gal-view-factory.h b/widgets/menus/gal-view-factory.h deleted file mode 100644 index 92c3df45ac..0000000000 --- a/widgets/menus/gal-view-factory.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Chris Lahey - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef GAL_VIEW_FACTORY_H -#define GAL_VIEW_FACTORY_H - -#include - -/* Standard GObject macros */ -#define GAL_TYPE_VIEW_FACTORY \ - (gal_view_factory_get_type ()) -#define GAL_VIEW_FACTORY(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), GAL_TYPE_VIEW_FACTORY, GalViewFactory)) -#define GAL_VIEW_FACTORY_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), GAL_TYPE_VIEW_FACTORY, GalViewFactoryClass)) -#define GAL_IS_VIEW_FACTORY(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), GAL_TYPE_VIEW_FACTORY)) -#define GAL_IS_VIEW_FACTORY_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), GAL_TYPE_VIEW_FACTORY)) -#define GAL_VIEW_FACTORY_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), GAL_TYPE_VIEW_FACTORY, GalViewFactoryClass)) - -G_BEGIN_DECLS - -typedef struct _GalViewFactory GalViewFactory; -typedef struct _GalViewFactoryClass GalViewFactoryClass; - -struct _GalViewFactory { - GObject parent; -}; - -struct _GalViewFactoryClass { - GObjectClass parent_class; - - /* Methods */ - const gchar * (*get_title) (GalViewFactory *factory); - const gchar * (*get_type_code) (GalViewFactory *factory); - GalView * (*new_view) (GalViewFactory *factory, - const gchar *name); -}; - -GType gal_view_factory_get_type (void); -const gchar * gal_view_factory_get_title (GalViewFactory *factory); - -/* Returns the code for use in identifying this type of object in the - * view list. This identifier should identify this as being the - * unique factory for xml files which were written out with this - * identifier. Thus each factory should have a unique type code. */ -const gchar * gal_view_factory_get_type_code (GalViewFactory *factory); - -GalView * gal_view_factory_new_view (GalViewFactory *factory, - const gchar *name); - -G_END_DECLS - -#endif /* GAL_VIEW_FACTORY_H */ diff --git a/widgets/menus/gal-view-instance-save-as-dialog.c b/widgets/menus/gal-view-instance-save-as-dialog.c deleted file mode 100644 index df1d1ca743..0000000000 --- a/widgets/menus/gal-view-instance-save-as-dialog.c +++ /dev/null @@ -1,358 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Chris Lahey - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include "e-util/e-util.h" -#include "e-util/e-util-private.h" - -#include "gal-define-views-model.h" -#include "gal-view-instance-save-as-dialog.h" -#include "gal-view-new-dialog.h" - -G_DEFINE_TYPE (GalViewInstanceSaveAsDialog, gal_view_instance_save_as_dialog, GTK_TYPE_DIALOG) - -enum { - PROP_0, - PROP_INSTANCE -}; - -enum { - COL_GALVIEW_NAME, - COL_GALVIEW_DATA -}; - -/* Static functions */ -static void -gal_view_instance_save_as_dialog_set_instance (GalViewInstanceSaveAsDialog *dialog, - GalViewInstance *instance) -{ - gint i; - GtkListStore *store; - GtkCellRenderer *renderer; - dialog->instance = instance; - - store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER); - - for (i = 0; i < instance->collection->view_count; i++) { - GalViewCollectionItem *item = instance->collection->view_data[i]; - GtkTreeIter iter; - gchar *title = NULL; - - /* hide built in views */ - /*if (item->built_in == 1) - continue;*/ - - title = e_str_without_underscores (item->title); - - gtk_list_store_append (store, &iter); - gtk_list_store_set ( - store, &iter, - COL_GALVIEW_NAME, title, - COL_GALVIEW_DATA, item, - -1); - - g_free (title); - } - - gtk_tree_sortable_set_sort_column_id ( - GTK_TREE_SORTABLE (store), - COL_GALVIEW_NAME, GTK_SORT_ASCENDING); - - /* attaching treeview to model */ - gtk_tree_view_set_model (dialog->treeview, GTK_TREE_MODEL (store)); - gtk_tree_view_set_search_column (dialog->treeview, COL_GALVIEW_NAME); - - dialog->model = GTK_TREE_MODEL (store); - - renderer = gtk_cell_renderer_text_new (); - - gtk_tree_view_insert_column_with_attributes ( - dialog->treeview, - COL_GALVIEW_NAME, _("Name"), - renderer, "text", COL_GALVIEW_NAME, - NULL); - - /* set sort column */ - gtk_tree_sortable_set_sort_column_id ( - GTK_TREE_SORTABLE (dialog->model), - COL_GALVIEW_NAME, GTK_SORT_ASCENDING); -} - -static void -gvisad_setup_validate_button (GalViewInstanceSaveAsDialog *dialog) -{ - if ((dialog->toggle == GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TOGGLE_CREATE - && g_utf8_strlen (gtk_entry_get_text (GTK_ENTRY (dialog->entry_create)), -1) > 0) - || dialog->toggle == GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TOGGLE_REPLACE) { - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, TRUE); - } else { - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE); - } -} - -static void -gvisad_setup_radio_buttons (GalViewInstanceSaveAsDialog *dialog) -{ - GtkWidget *widget; - - widget = dialog->scrolledwindow; - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->radiobutton_replace))) { - GtkTreeIter iter; - GtkTreeSelection *selection; - - selection = gtk_tree_view_get_selection (dialog->treeview); - if (!gtk_tree_selection_get_selected (selection, &dialog->model, &iter)) { - if (gtk_tree_model_get_iter_first (dialog->model, &iter)) { - gtk_tree_selection_select_iter (selection, &iter); - } - } - - gtk_widget_set_sensitive (widget, TRUE); - dialog->toggle = GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TOGGLE_REPLACE; - } else { - gtk_widget_set_sensitive (widget, FALSE); - } - - widget = dialog->entry_create; - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->radiobutton_create))) { - gtk_widget_set_sensitive (widget, TRUE); - dialog->toggle = GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TOGGLE_CREATE; - } else { - gtk_widget_set_sensitive (widget, FALSE); - } - - gvisad_setup_validate_button (dialog); -} - -static void -gvisad_radio_toggled (GtkWidget *widget, - GalViewInstanceSaveAsDialog *dialog) -{ - gvisad_setup_radio_buttons (dialog); -} - -static void -gvisad_entry_changed (GtkWidget *widget, - GalViewInstanceSaveAsDialog *dialog) -{ - gvisad_setup_validate_button (dialog); -} - -/* Method override implementations */ -static void -gal_view_instance_save_as_dialog_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - GalViewInstanceSaveAsDialog *dialog; - - dialog = GAL_VIEW_INSTANCE_SAVE_AS_DIALOG (object); - - switch (property_id) { - case PROP_INSTANCE: - if (g_value_get_object (value)) - gal_view_instance_save_as_dialog_set_instance (dialog, GAL_VIEW_INSTANCE (g_value_get_object (value))); - else - gal_view_instance_save_as_dialog_set_instance (dialog, NULL); - break; - - default: - return; - } -} - -static void -gal_view_instance_save_as_dialog_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - GalViewInstanceSaveAsDialog *dialog; - - dialog = GAL_VIEW_INSTANCE_SAVE_AS_DIALOG (object); - - switch (property_id) { - case PROP_INSTANCE: - g_value_set_object (value, dialog->instance); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -gal_view_instance_save_as_dialog_dispose (GObject *object) -{ - GalViewInstanceSaveAsDialog *gal_view_instance_save_as_dialog = GAL_VIEW_INSTANCE_SAVE_AS_DIALOG (object); - - if (gal_view_instance_save_as_dialog->builder) - g_object_unref (gal_view_instance_save_as_dialog->builder); - gal_view_instance_save_as_dialog->builder = NULL; - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (gal_view_instance_save_as_dialog_parent_class)->dispose (object); -} - -/* Init functions */ -static void -gal_view_instance_save_as_dialog_class_init (GalViewInstanceSaveAsDialogClass *class) -{ - GObjectClass *object_class; - - object_class = (GObjectClass *) class; - - object_class->set_property = gal_view_instance_save_as_dialog_set_property; - object_class->get_property = gal_view_instance_save_as_dialog_get_property; - object_class->dispose = gal_view_instance_save_as_dialog_dispose; - - g_object_class_install_property ( - object_class, - PROP_INSTANCE, - g_param_spec_object ( - "instance", - "Instance", - NULL, - GAL_VIEW_INSTANCE_TYPE, - G_PARAM_READWRITE)); -} - -static void -gal_view_instance_save_as_dialog_init (GalViewInstanceSaveAsDialog *dialog) -{ - GtkWidget *content_area; - GtkWidget *widget; - - dialog->instance = NULL; - dialog->model = NULL; - dialog->collection = NULL; - - dialog->builder = gtk_builder_new (); - e_load_ui_builder_definition ( - dialog->builder, "gal-view-instance-save-as-dialog.ui"); - - widget = e_builder_get_widget (dialog->builder, "vbox-top"); - content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); - gtk_box_pack_start (GTK_BOX (content_area), widget, TRUE, TRUE, 0); - - /* TODO: add position/size saving/restoring */ - gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); - gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 360); - - gtk_dialog_add_buttons ( - GTK_DIALOG (dialog), - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_OK, - NULL); - - dialog->scrolledwindow = e_builder_get_widget (dialog->builder, "scrolledwindow2"); - dialog->treeview = GTK_TREE_VIEW (e_builder_get_widget (dialog->builder, "custom-replace")); - dialog->entry_create = e_builder_get_widget (dialog->builder, "entry-create"); - dialog->radiobutton_replace = e_builder_get_widget (dialog->builder, "radiobutton-replace"); - dialog->radiobutton_create = e_builder_get_widget (dialog->builder, "radiobutton-create"); - - gtk_tree_view_set_reorderable (GTK_TREE_VIEW (dialog->treeview), FALSE); - gtk_tree_view_set_headers_visible (dialog->treeview, FALSE); - - g_signal_connect ( - dialog->radiobutton_replace, "toggled", - G_CALLBACK (gvisad_radio_toggled), dialog); - g_signal_connect ( - dialog->radiobutton_create, "toggled", - G_CALLBACK (gvisad_radio_toggled), dialog); - g_signal_connect ( - dialog->entry_create, "changed", - G_CALLBACK (gvisad_entry_changed), dialog); - - gvisad_setup_radio_buttons (dialog); - gvisad_setup_validate_button (dialog); - - gtk_window_set_title (GTK_WINDOW (dialog), _("Save Current View")); - gtk_widget_show (GTK_WIDGET (dialog)); -} - -/* External methods */ -/** - * gal_view_instance_save_as_dialog_new - * - * Returns a new dialog for defining views. - * - * Returns: The GalViewInstanceSaveAsDialog. - */ -GtkWidget * -gal_view_instance_save_as_dialog_new (GalViewInstance *instance) -{ - GtkWidget *widget = g_object_new (GAL_TYPE_VIEW_INSTANCE_SAVE_AS_DIALOG, NULL); - gal_view_instance_save_as_dialog_set_instance (GAL_VIEW_INSTANCE_SAVE_AS_DIALOG (widget), instance); - return widget; -} - -void -gal_view_instance_save_as_dialog_save (GalViewInstanceSaveAsDialog *dialog) -{ - GalView *view = gal_view_instance_get_current_view (dialog->instance); - const gchar *title; - gint n; - const gchar *id = NULL; - GalViewCollectionItem *item; - - view = gal_view_clone (view); - switch (dialog->toggle) { - case GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TOGGLE_REPLACE: - if (dialog->treeview) { - GtkTreeIter iter; - GtkTreeSelection *selection; - - selection = gtk_tree_view_get_selection (dialog->treeview); - if (gtk_tree_selection_get_selected (selection, &dialog->model, &iter)) { - gtk_tree_model_get (dialog->model, &iter, COL_GALVIEW_DATA, &item, -1); - - for (n = 0; n < dialog->instance->collection->view_count; n++) { - if (item == dialog->instance->collection->view_data[n]) { - id = gal_view_collection_set_nth_view (dialog->instance->collection, n, view); - gal_view_collection_save (dialog->instance->collection); - } - } - } - - } - break; - - case GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TOGGLE_CREATE: - if (dialog->entry_create && GTK_IS_ENTRY (dialog->entry_create)) { - title = gtk_entry_get_text (GTK_ENTRY (dialog->entry_create)); - id = gal_view_collection_append_with_title (dialog->instance->collection, title, view); - gal_view_collection_save (dialog->instance->collection); - } - break; - } - - if (id) { - gal_view_instance_set_current_view_id (dialog->instance, id); - } -} diff --git a/widgets/menus/gal-view-instance-save-as-dialog.h b/widgets/menus/gal-view-instance-save-as-dialog.h deleted file mode 100644 index b5f9ac56e8..0000000000 --- a/widgets/menus/gal-view-instance-save-as-dialog.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Chris Lahey - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_H -#define GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_H - -#include -#include -#include - -/* Standard GObject macros */ -#define GAL_TYPE_VIEW_INSTANCE_SAVE_AS_DIALOG \ - (gal_view_instance_save_as_dialog_get_type ()) -#define GAL_VIEW_INSTANCE_SAVE_AS_DIALOG(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), GAL_TYPE_VIEW_INSTANCE_SAVE_AS_DIALOG, GalViewInstanceSaveAsDialog)) -#define GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), GAL_TYPE_VIEW_INSTANCE_SAVE_AS_DIALOG, GalViewInstanceSaveAsDialogClass)) -#define GAL_IS_VIEW_INSTANCE_SAVE_AS_DIALOG(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), GAL_TYPE_VIEW_INSTANCE_SAVE_AS_DIALOG)) -#define GAL_IS_VIEW_INSTANCE_SAVE_AS_DIALOG_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), GAL_TYPE_VIEW_INSTANCE_SAVE_AS_DIALOG)) -#define GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), GAL_TYPE_VIEW_INSTANCE_SAVE_AS_DIALOG, GalViewInstanceSaveAsDialogClass)) - -G_BEGIN_DECLS - -typedef struct _GalViewInstanceSaveAsDialog GalViewInstanceSaveAsDialog; -typedef struct _GalViewInstanceSaveAsDialogClass GalViewInstanceSaveAsDialogClass; - -typedef enum { - GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TOGGLE_REPLACE, - GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TOGGLE_CREATE -} GalViewInstanceSaveAsDialogToggle; - -struct _GalViewInstanceSaveAsDialog { - GtkDialog parent; - - /* item specific fields */ - GtkBuilder *builder; - GtkTreeView *treeview; - GtkTreeModel *model; - - GtkWidget *scrolledwindow, *radiobutton_replace; - GtkWidget *entry_create, *radiobutton_create; - - GalViewInstance *instance; - GalViewCollection *collection; - - GalViewInstanceSaveAsDialogToggle toggle; -}; - -struct _GalViewInstanceSaveAsDialogClass { - GtkDialogClass parent_class; -}; - -GType gal_view_instance_save_as_dialog_get_type (void); -GtkWidget * gal_view_instance_save_as_dialog_new - (GalViewInstance *instance); -void gal_view_instance_save_as_dialog_save - (GalViewInstanceSaveAsDialog *dialog); - -G_END_DECLS - -#endif /* GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_H */ diff --git a/widgets/menus/gal-view-instance-save-as-dialog.ui b/widgets/menus/gal-view-instance-save-as-dialog.ui deleted file mode 100644 index d7215f1f61..0000000000 --- a/widgets/menus/gal-view-instance-save-as-dialog.ui +++ /dev/null @@ -1,133 +0,0 @@ - - - - - - True - 5 - vertical - 12 - - - True - vertical - 6 - - - _Create new view - True - True - False - True - True - True - - - False - False - 0 - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 24 - - - True - 6 - - - True - _Name: - True - entry-create - - - False - False - 0 - - - - - True - False - True - - - - 1 - - - - - - - 1 - - - - - False - False - 0 - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - vertical - 6 - - - _Replace existing view - True - True - False - True - True - radiobutton-create - - - False - False - 0 - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 24 - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - automatic - automatic - in - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - - - - - 1 - - - - - 1 - - - - diff --git a/widgets/menus/gal-view-instance.c b/widgets/menus/gal-view-instance.c deleted file mode 100644 index 97ba252a0b..0000000000 --- a/widgets/menus/gal-view-instance.c +++ /dev/null @@ -1,503 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Chris Lahey - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include "e-util/e-util.h" -#include "libevolution-utils/e-xml-utils.h" -#include "e-util/e-unicode.h" - -#include "gal-define-views-dialog.h" -#include "gal-view-instance.h" -#include "gal-view-instance-save-as-dialog.h" - -G_DEFINE_TYPE (GalViewInstance, gal_view_instance, G_TYPE_OBJECT) - -#define d(x) - -enum { - DISPLAY_VIEW, - CHANGED, - LOADED, - LAST_SIGNAL -}; - -static guint gal_view_instance_signals[LAST_SIGNAL] = { 0, }; - -static void -gal_view_instance_changed (GalViewInstance *instance) -{ - g_return_if_fail (instance != NULL); - g_return_if_fail (GAL_IS_VIEW_INSTANCE (instance)); - - g_signal_emit ( - instance, - gal_view_instance_signals[CHANGED], 0); -} - -static void -gal_view_instance_display_view (GalViewInstance *instance, - GalView *view) -{ - g_return_if_fail (instance != NULL); - g_return_if_fail (GAL_IS_VIEW_INSTANCE (instance)); - - g_signal_emit ( - instance, - gal_view_instance_signals[DISPLAY_VIEW], 0, - view); -} - -static void -save_current_view (GalViewInstance *instance) -{ - xmlDoc *doc; - xmlNode *root; - - doc = xmlNewDoc ((const guchar *)"1.0"); - root = xmlNewNode (NULL, (const guchar *)"GalViewCurrentView"); - xmlDocSetRootElement (doc, root); - - if (instance->current_id) - e_xml_set_string_prop_by_name (root, (const guchar *)"current_view", instance->current_id); - if (instance->current_type) - e_xml_set_string_prop_by_name (root, (const guchar *)"current_view_type", instance->current_type); - - if (e_xml_save_file (instance->current_view_filename, doc) == -1) - g_warning ("Unable to save view to %s - %s", instance->current_view_filename, g_strerror (errno)); - xmlFreeDoc (doc); -} - -static void -view_changed (GalView *view, - GalViewInstance *instance) -{ - if (instance->current_id != NULL) { - g_free (instance->current_id); - instance->current_id = NULL; - save_current_view (instance); - gal_view_instance_changed (instance); - } - - gal_view_save (view, instance->custom_filename); -} - -static void -disconnect_view (GalViewInstance *instance) -{ - if (instance->current_view) { - if (instance->view_changed_id) { - g_signal_handler_disconnect ( - instance->current_view, - instance->view_changed_id); - } - - g_object_unref (instance->current_view); - } - g_free (instance->current_type); - g_free (instance->current_title); - instance->current_title = NULL; - instance->current_type = NULL; - instance->view_changed_id = 0; - instance->current_view = NULL; -} - -static void -connect_view (GalViewInstance *instance, - GalView *view) -{ - if (instance->current_view) - disconnect_view (instance); - instance->current_view = view; - - instance->current_title = g_strdup (gal_view_get_title (view)); - instance->current_type = g_strdup (gal_view_get_type_code (view)); - instance->view_changed_id = g_signal_connect ( - instance->current_view, "changed", - G_CALLBACK (view_changed), instance); - - gal_view_instance_display_view (instance, instance->current_view); -} - -static void -gal_view_instance_dispose (GObject *object) -{ - GalViewInstance *instance = GAL_VIEW_INSTANCE (object); - - if (instance->collection) { - if (instance->collection_changed_id) { - g_signal_handler_disconnect ( - instance->collection, - instance->collection_changed_id); - } - g_object_unref (instance->collection); - } - - g_free (instance->instance_id); - g_free (instance->custom_filename); - g_free (instance->current_view_filename); - - g_free (instance->current_id); - disconnect_view (instance); - - g_free (instance->default_view); - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (gal_view_instance_parent_class)->dispose (object); -} - -static void -gal_view_instance_class_init (GalViewInstanceClass *class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (class); - - object_class->dispose = gal_view_instance_dispose; - - gal_view_instance_signals[DISPLAY_VIEW] = g_signal_new ( - "display_view", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GalViewInstanceClass, display_view), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, - GAL_TYPE_VIEW); - - gal_view_instance_signals[CHANGED] = g_signal_new ( - "changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GalViewInstanceClass, changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - gal_view_instance_signals[LOADED] = g_signal_new ( - "loaded", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GalViewInstanceClass, loaded), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - class->display_view = NULL; - class->changed = NULL; -} - -static void -gal_view_instance_init (GalViewInstance *instance) -{ - instance->collection = NULL; - - instance->instance_id = NULL; - instance->custom_filename = NULL; - instance->current_view_filename = NULL; - - instance->current_title = NULL; - instance->current_type = NULL; - instance->current_id = NULL; - instance->current_view = NULL; - - instance->view_changed_id = 0; - instance->collection_changed_id = 0; - - instance->loaded = FALSE; - instance->default_view = NULL; -} - -static void -collection_changed (GalView *view, - GalViewInstance *instance) -{ - if (instance->current_id) { - gchar *view_id = instance->current_id; - instance->current_id = NULL; - gal_view_instance_set_current_view_id (instance, view_id); - g_free (view_id); - } -} - -static void -load_current_view (GalViewInstance *instance) -{ - xmlDoc *doc = NULL; - xmlNode *root; - GalView *view = NULL; - - if (g_file_test (instance->current_view_filename, G_FILE_TEST_IS_REGULAR)) { -#ifdef G_OS_WIN32 - gchar *locale_filename = g_win32_locale_filename_from_utf8 (instance->current_view_filename); - if (locale_filename != NULL) - doc = xmlParseFile (locale_filename); - g_free (locale_filename); -#else - doc = xmlParseFile (instance->current_view_filename); -#endif - } - - if (doc == NULL) { - instance->current_id = g_strdup (gal_view_instance_get_default_view (instance)); - - if (instance->current_id) { - gint index = gal_view_collection_get_view_index_by_id ( - instance->collection, - instance->current_id); - - if (index != -1) { - view = gal_view_collection_get_view ( - instance->collection, index); - view = gal_view_clone (view); - connect_view (instance, view); - } - } - return; - } - - root = xmlDocGetRootElement (doc); - instance->current_id = e_xml_get_string_prop_by_name_with_default (root, (const guchar *)"current_view", NULL); - - if (instance->current_id != NULL) { - gint index = gal_view_collection_get_view_index_by_id ( - instance->collection, - instance->current_id); - - if (index != -1) { - view = gal_view_collection_get_view ( - instance->collection, index); - view = gal_view_clone (view); - } - } - if (view == NULL) { - gchar *type; - type = e_xml_get_string_prop_by_name_with_default (root, (const guchar *)"current_view_type", NULL); - view = gal_view_collection_load_view_from_file ( - instance->collection, type, - instance->custom_filename); - g_free (type); - } - - connect_view (instance, view); - - xmlFreeDoc (doc); -} - -/** - * gal_view_instance_new: - * @collection: This %GalViewCollection should be loaded before being passed to this function. - * @instance_id: Which instance of this type of object is this (for most of evo, this is the folder id.) - * - * Create a new %GalViewInstance. - * - * Return value: The new %GalViewInstance. - **/ -GalViewInstance * -gal_view_instance_new (GalViewCollection *collection, - const gchar *instance_id) -{ - GalViewInstance *instance = g_object_new (GAL_VIEW_INSTANCE_TYPE, NULL); - if (gal_view_instance_construct (instance, collection, instance_id)) - return instance; - else { - g_object_unref (instance); - return NULL; - } -} - -GalViewInstance * -gal_view_instance_construct (GalViewInstance *instance, - GalViewCollection *collection, - const gchar *instance_id) -{ - gchar *filename; - gchar *safe_id; - - g_return_val_if_fail (gal_view_collection_loaded (collection), NULL); - - instance->collection = collection; - if (collection) - g_object_ref (collection); - instance->collection_changed_id = g_signal_connect ( - collection, "changed", - G_CALLBACK (collection_changed), instance); - - if (instance_id) - instance->instance_id = g_strdup (instance_id); - else - instance->instance_id = g_strdup (""); - - safe_id = g_strdup (instance->instance_id); - e_filename_make_safe (safe_id); - - filename = g_strdup_printf ("custom_view-%s.xml", safe_id); - instance->custom_filename = g_build_filename (instance->collection->local_dir, filename, NULL); - g_free (filename); - - filename = g_strdup_printf ("current_view-%s.xml", safe_id); - instance->current_view_filename = g_build_filename (instance->collection->local_dir, filename, NULL); - g_free (filename); - - g_free (safe_id); - - return instance; -} - -/* Manipulate the current view. */ -gchar * -gal_view_instance_get_current_view_id (GalViewInstance *instance) -{ - if (instance->current_id && gal_view_collection_get_view_index_by_id (instance->collection, instance->current_id) != -1) - return g_strdup (instance->current_id); - else - return NULL; -} - -void -gal_view_instance_set_current_view_id (GalViewInstance *instance, - const gchar *view_id) -{ - GalView *view; - gint index; - - g_return_if_fail (instance != NULL); - g_return_if_fail (GAL_IS_VIEW_INSTANCE (instance)); - - d (g_print ("%s: view_id set to %s\n", G_STRFUNC, view_id)); - - if (instance->current_id && !strcmp (instance->current_id, view_id)) - return; - - g_free (instance->current_id); - instance->current_id = g_strdup (view_id); - - index = gal_view_collection_get_view_index_by_id (instance->collection, view_id); - if (index != -1) { - view = gal_view_collection_get_view (instance->collection, index); - connect_view (instance, gal_view_clone (view)); - } - - if (instance->loaded) - save_current_view (instance); - gal_view_instance_changed (instance); -} - -GalView * -gal_view_instance_get_current_view (GalViewInstance *instance) -{ - return instance->current_view; -} - -void -gal_view_instance_set_custom_view (GalViewInstance *instance, - GalView *view) -{ - g_free (instance->current_id); - instance->current_id = NULL; - - view = gal_view_clone (view); - connect_view (instance, view); - gal_view_save (view, instance->custom_filename); - save_current_view (instance); - gal_view_instance_changed (instance); -} - -static void -dialog_response (GtkWidget *dialog, - gint id, - GalViewInstance *instance) -{ - if (id == GTK_RESPONSE_OK) { - gal_view_instance_save_as_dialog_save (GAL_VIEW_INSTANCE_SAVE_AS_DIALOG (dialog)); - } - gtk_widget_destroy (dialog); -} - -void -gal_view_instance_save_as (GalViewInstance *instance) -{ - GtkWidget *dialog; - - g_return_if_fail (instance != NULL); - - dialog = gal_view_instance_save_as_dialog_new (instance); - g_signal_connect ( - dialog, "response", - G_CALLBACK (dialog_response), instance); - gtk_widget_show (dialog); -} - -/* This is idempotent. Once it's been called once, the rest of the calls are ignored. */ -void -gal_view_instance_load (GalViewInstance *instance) -{ - if (!instance->loaded) { - load_current_view (instance); - instance->loaded = TRUE; - g_signal_emit (instance, gal_view_instance_signals[LOADED], 0); - } -} - -/* These only mean anything before gal_view_instance_load is called the first time. */ -const gchar * -gal_view_instance_get_default_view (GalViewInstance *instance) -{ - if (instance->default_view) - return instance->default_view; - else - return gal_view_collection_get_default_view (instance->collection); -} - -void -gal_view_instance_set_default_view (GalViewInstance *instance, - const gchar *id) -{ - g_free (instance->default_view); - instance->default_view = g_strdup (id); -} - -gboolean -gal_view_instance_exists (GalViewInstance *instance) -{ - struct stat st; - - if (instance->current_view_filename && g_stat (instance->current_view_filename, &st) == 0 && st.st_size > 0 && S_ISREG (st.st_mode)) - return TRUE; - else - return FALSE; - -} diff --git a/widgets/menus/gal-view-instance.h b/widgets/menus/gal-view-instance.h deleted file mode 100644 index 7495f0fa8f..0000000000 --- a/widgets/menus/gal-view-instance.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Chris Lahey - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef _GAL_VIEW_INSTANCE_H_ -#define _GAL_VIEW_INSTANCE_H_ - -#include - -G_BEGIN_DECLS - -#define GAL_VIEW_INSTANCE_TYPE (gal_view_instance_get_type ()) -#define GAL_VIEW_INSTANCE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GAL_VIEW_INSTANCE_TYPE, GalViewInstance)) -#define GAL_VIEW_INSTANCE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GAL_VIEW_INSTANCE_TYPE, GalViewInstanceClass)) -#define GAL_IS_VIEW_INSTANCE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GAL_VIEW_INSTANCE_TYPE)) -#define GAL_IS_VIEW_INSTANCE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GAL_VIEW_INSTANCE_TYPE)) - -typedef struct { - GObject base; - - GalViewCollection *collection; - - gchar *instance_id; - gchar *current_view_filename; - gchar *custom_filename; - - gchar *current_title; - gchar *current_type; - gchar *current_id; - - GalView *current_view; - - guint view_changed_id; - guint collection_changed_id; - - guint loaded : 1; - gchar *default_view; -} GalViewInstance; - -typedef struct { - GObjectClass parent_class; - - /* - * Signals - */ - void (*display_view) (GalViewInstance *instance, - GalView *view); - void (*changed) (GalViewInstance *instance); - void (*loaded) (GalViewInstance *instance); -} GalViewInstanceClass; - -/* Standard functions */ -GType gal_view_instance_get_type (void); - -/* */ -/*collection should be loaded when you call this. - instance_id: Which instance of this type of object is this (for most of evo, this is the folder id.) */ -GalViewInstance *gal_view_instance_new (GalViewCollection *collection, - const gchar *instance_id); -GalViewInstance *gal_view_instance_construct (GalViewInstance *instance, - GalViewCollection *collection, - const gchar *instance_id); - -/* Manipulate the current view. */ -gchar *gal_view_instance_get_current_view_id (GalViewInstance *instance); -void gal_view_instance_set_current_view_id (GalViewInstance *instance, - const gchar *view_id); -GalView *gal_view_instance_get_current_view (GalViewInstance *instance); - -/* Sets the current view to the given custom view. */ -void gal_view_instance_set_custom_view (GalViewInstance *instance, - GalView *view); - -/* Returns true if this instance has ever been used before. */ -gboolean gal_view_instance_exists (GalViewInstance *instance); - -/* Manipulate the view collection */ -/* void gal_view_instance_set_as_default (GalViewInstance *instance); */ -void gal_view_instance_save_as (GalViewInstance *instance); - -/* This is idempotent. Once it's been called once, the rest of the calls are ignored. */ -void gal_view_instance_load (GalViewInstance *instance); - -/* These only mean anything before gal_view_instance_load is called the first time. */ -const gchar *gal_view_instance_get_default_view (GalViewInstance *instance); -void gal_view_instance_set_default_view (GalViewInstance *instance, - const gchar *id); - -G_END_DECLS - -#endif /* _GAL_VIEW_INSTANCE_H_ */ diff --git a/widgets/menus/gal-view-new-dialog.c b/widgets/menus/gal-view-new-dialog.c deleted file mode 100644 index b0de7156dc..0000000000 --- a/widgets/menus/gal-view-new-dialog.c +++ /dev/null @@ -1,290 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Chris Lahey - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include "e-util/e-util.h" -#include "e-util/e-util-private.h" -#include "e-util/e-unicode.h" - -#include "gal-define-views-model.h" -#include "gal-view-new-dialog.h" - -enum { - PROP_0, - PROP_NAME, - PROP_FACTORY -}; - -G_DEFINE_TYPE (GalViewNewDialog, gal_view_new_dialog, GTK_TYPE_DIALOG) - -static void -gal_view_new_dialog_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - GalViewNewDialog *dialog; - GtkWidget *entry; - - dialog = GAL_VIEW_NEW_DIALOG (object); - - switch (property_id) { - case PROP_NAME: - entry = e_builder_get_widget (dialog->builder, "entry-name"); - if (entry && GTK_IS_ENTRY (entry)) { - gtk_entry_set_text (GTK_ENTRY (entry), g_value_get_string (value)); - } - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - return; - } -} - -static void -gal_view_new_dialog_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - GalViewNewDialog *dialog; - GtkWidget *entry; - - dialog = GAL_VIEW_NEW_DIALOG (object); - - switch (property_id) { - case PROP_NAME: - entry = e_builder_get_widget (dialog->builder, "entry-name"); - if (entry && GTK_IS_ENTRY (entry)) { - g_value_set_string (value, gtk_entry_get_text (GTK_ENTRY (entry))); - } - break; - case PROP_FACTORY: - g_value_set_object (value, dialog->selected_factory); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -gal_view_new_dialog_dispose (GObject *object) -{ - GalViewNewDialog *gal_view_new_dialog = GAL_VIEW_NEW_DIALOG (object); - - if (gal_view_new_dialog->builder) - g_object_unref (gal_view_new_dialog->builder); - gal_view_new_dialog->builder = NULL; - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (gal_view_new_dialog_parent_class)->dispose (object); -} - -static void -gal_view_new_dialog_class_init (GalViewNewDialogClass *class) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (class); - object_class->set_property = gal_view_new_dialog_set_property; - object_class->get_property = gal_view_new_dialog_get_property; - object_class->dispose = gal_view_new_dialog_dispose; - - g_object_class_install_property ( - object_class, - PROP_NAME, - g_param_spec_string ( - "name", - "Name", - NULL, - NULL, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - object_class, - PROP_FACTORY, - g_param_spec_object ( - "factory", - "Factory", - NULL, - GAL_TYPE_VIEW_FACTORY, - G_PARAM_READWRITE)); -} - -static void -gal_view_new_dialog_init (GalViewNewDialog *dialog) -{ - GtkWidget *content_area; - GtkWidget *parent; - GtkWidget *widget; - - dialog->builder = gtk_builder_new (); - e_load_ui_builder_definition ( - dialog->builder, "gal-view-new-dialog.ui"); - - widget = e_builder_get_widget (dialog->builder, "table-top"); - if (!widget) { - return; - } - - g_object_ref (widget); - - parent = gtk_widget_get_parent (widget); - gtk_container_remove (GTK_CONTAINER (parent), widget); - - content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); - gtk_box_pack_start (GTK_BOX (content_area), widget, TRUE, TRUE, 0); - - g_object_unref (widget); - - gtk_dialog_add_buttons ( - GTK_DIALOG (dialog), - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); - - gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE); - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - gtk_window_set_title (GTK_WINDOW (dialog), _("Define New View")); - - dialog->collection = NULL; - dialog->selected_factory = NULL; -} - -GtkWidget * -gal_view_new_dialog_new (GalViewCollection *collection) -{ - GtkWidget *widget = - gal_view_new_dialog_construct ( - g_object_new (GAL_VIEW_NEW_DIALOG_TYPE, NULL), - collection); - return widget; -} - -static void -sensitize_ok_response (GalViewNewDialog *dialog) -{ - gboolean ok = TRUE; - const gchar *text; - - text = gtk_entry_get_text (GTK_ENTRY (dialog->entry)); - if (!text || !text[0]) - ok = FALSE; - - if (!dialog->selected_factory) - ok = FALSE; - - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, ok); -} - -static gboolean -selection_func (GtkTreeSelection *selection, - GtkTreeModel *model, - GtkTreePath *path, - gboolean path_currently_selected, - gpointer data) -{ - GtkTreeIter iter; - GalViewNewDialog *dialog = data; - - if (path_currently_selected) - return TRUE; - - model = GTK_TREE_MODEL (dialog->list_store); - - gtk_tree_model_get_iter (model, &iter, path); - gtk_tree_model_get (model, &iter, 1, &dialog->selected_factory, -1); - - sensitize_ok_response (dialog); - - return TRUE; -} - -static void -entry_changed (GtkWidget *entry, - gpointer data) -{ - GalViewNewDialog *dialog = data; - - sensitize_ok_response (dialog); -} - -GtkWidget * -gal_view_new_dialog_construct (GalViewNewDialog *dialog, - GalViewCollection *collection) -{ - GList *iterator; - GtkTreeSelection *selection; - GtkTreeViewColumn *column; - GtkCellRenderer *rend; - - dialog->collection = collection; - dialog->list = e_builder_get_widget (dialog->builder,"list-type-list"); - dialog->entry = e_builder_get_widget (dialog->builder, "entry-name"); - - dialog->list_store = gtk_list_store_new ( - 2, G_TYPE_STRING, G_TYPE_POINTER); - - rend = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes ( - "factory title", rend, "text", 0, NULL); - - gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->list), column); - - iterator = dialog->collection->factory_list; - for (; iterator; iterator = g_list_next (iterator)) { - GalViewFactory *factory = iterator->data; - GtkTreeIter iter; - - g_object_ref (factory); - gtk_list_store_append ( - dialog->list_store, &iter); - gtk_list_store_set ( - dialog->list_store, &iter, - 0, gal_view_factory_get_title (factory), - 1, factory, - -1); - } - - gtk_tree_view_set_model ( - GTK_TREE_VIEW (dialog->list), - GTK_TREE_MODEL (dialog->list_store)); - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->list)); - - gtk_tree_selection_set_select_function ( - selection, selection_func, dialog, NULL); - - g_signal_connect ( - dialog->entry, "changed", - G_CALLBACK (entry_changed), dialog); - - sensitize_ok_response (dialog); - - return GTK_WIDGET (dialog); -} - diff --git a/widgets/menus/gal-view-new-dialog.h b/widgets/menus/gal-view-new-dialog.h deleted file mode 100644 index 6b7d2b0335..0000000000 --- a/widgets/menus/gal-view-new-dialog.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Chris Lahey - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __GAL_VIEW_NEW_DIALOG_H__ -#define __GAL_VIEW_NEW_DIALOG_H__ - -#include -#include - -G_BEGIN_DECLS - -/* GalViewNewDialog - A dialog displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - */ - -#define GAL_VIEW_NEW_DIALOG_TYPE (gal_view_new_dialog_get_type ()) -#define GAL_VIEW_NEW_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_VIEW_NEW_DIALOG_TYPE, GalViewNewDialog)) -#define GAL_VIEW_NEW_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_VIEW_NEW_DIALOG_TYPE, GalViewNewDialogClass)) -#define GAL_IS_VIEW_NEW_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_VIEW_NEW_DIALOG_TYPE)) -#define GAL_IS_VIEW_NEW_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GAL_VIEW_NEW_DIALOG_TYPE)) - -typedef struct _GalViewNewDialog GalViewNewDialog; -typedef struct _GalViewNewDialogClass GalViewNewDialogClass; - -struct _GalViewNewDialog -{ - GtkDialog parent; - - /* item specific fields */ - GtkBuilder *builder; - - GalViewCollection *collection; - GalViewFactory *selected_factory; - - GtkListStore *list_store; - - GtkWidget *entry; - GtkWidget *list; -}; - -struct _GalViewNewDialogClass -{ - GtkDialogClass parent_class; -}; - -GtkWidget *gal_view_new_dialog_new (GalViewCollection *collection); -GType gal_view_new_dialog_get_type (void); - -GtkWidget *gal_view_new_dialog_construct (GalViewNewDialog *dialog, - GalViewCollection *collection); - -G_END_DECLS - -#endif /* __GAL_VIEW_NEW_DIALOG_H__ */ diff --git a/widgets/menus/gal-view-new-dialog.ui b/widgets/menus/gal-view-new-dialog.ui deleted file mode 100644 index 227e3954d8..0000000000 --- a/widgets/menus/gal-view-new-dialog.ui +++ /dev/null @@ -1,177 +0,0 @@ - - - - - - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - - - True - False - 8 - - - True - GTK_BUTTONBOX_END - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - - - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - True - - - - - 0 - False - True - GTK_PACK_END - - - - - True - 4 - 1 - False - 6 - 6 - - - True - Name of new view: - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - entry-name - - - 0 - 1 - 0 - 1 - fill - - - - - - True - True - True - True - 0 - - True - False - - - 0 - 1 - 1 - 2 - fill - - - - - True - Type of view: - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 2 - 3 - fill - - - - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - True - True - False - False - False - True - - - - - - Type of View - - - - - - - 0 - 1 - 3 - 4 - fill - - - - - 0 - True - True - - - - - - button1 - button3 - - - diff --git a/widgets/menus/gal-view.c b/widgets/menus/gal-view.c deleted file mode 100644 index b24be56e83..0000000000 --- a/widgets/menus/gal-view.c +++ /dev/null @@ -1,282 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Chris Lahey - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "gal-view.h" - -#include - -#define d(x) - -enum { - PROP_0, - PROP_TITLE, - PROP_TYPE_CODE -}; - -enum { - CHANGED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL]; - -G_DEFINE_ABSTRACT_TYPE (GalView, gal_view, G_TYPE_OBJECT) - -static void -view_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_TITLE: - gal_view_set_title ( - GAL_VIEW (object), - g_value_get_string (value)); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -view_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_TITLE: - g_value_set_string ( - value, gal_view_get_title ( - GAL_VIEW (object))); - return; - - case PROP_TYPE_CODE: - g_value_set_string ( - value, gal_view_get_type_code ( - GAL_VIEW (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -gal_view_class_init (GalViewClass *class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (class); - - object_class = G_OBJECT_CLASS (class); - object_class->set_property = view_set_property; - object_class->get_property = view_get_property; - - g_object_class_install_property ( - object_class, - PROP_TITLE, - g_param_spec_string ( - "title", - NULL, - NULL, - NULL, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - object_class, - PROP_TYPE_CODE, - g_param_spec_string ( - "type-code", - NULL, - NULL, - NULL, - G_PARAM_READABLE)); - - signals[CHANGED] = g_signal_new ( - "changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GalViewClass, changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} - -static void -gal_view_init (GalView *view) -{ -} - -/** - * gal_view_edit - * @view: The view to edit - * @parent: the parent window. - */ -void -gal_view_edit (GalView *view, - GtkWindow *parent) -{ - GalViewClass *class; - - g_return_if_fail (GAL_IS_VIEW (view)); - g_return_if_fail (GTK_IS_WINDOW (parent)); - - class = GAL_VIEW_GET_CLASS (view); - g_return_if_fail (class->edit != NULL); - - class->edit (view, parent); -} - -/** - * gal_view_load - * @view: The view to load to - * @filename: The file to load from - */ -void -gal_view_load (GalView *view, - const gchar *filename) -{ - GalViewClass *class; - - g_return_if_fail (GAL_IS_VIEW (view)); - g_return_if_fail (filename != NULL); - - class = GAL_VIEW_GET_CLASS (view); - g_return_if_fail (class->load != NULL); - - class->load (view, filename); -} - -/** - * gal_view_save - * @view: The view to save - * @filename: The file to save to - */ -void -gal_view_save (GalView *view, - const gchar *filename) -{ - GalViewClass *class; - - g_return_if_fail (GAL_IS_VIEW (view)); - g_return_if_fail (filename != NULL); - - class = GAL_VIEW_GET_CLASS (view); - g_return_if_fail (class->save != NULL); - - class->save (view, filename); -} - -/** - * gal_view_get_title - * @view: The view to query. - * - * Returns: The title of the view. - */ -const gchar * -gal_view_get_title (GalView *view) -{ - GalViewClass *class; - - g_return_val_if_fail (GAL_IS_VIEW (view), NULL); - - class = GAL_VIEW_GET_CLASS (view); - g_return_val_if_fail (class->get_title != NULL, NULL); - - return class->get_title (view); -} - -/** - * gal_view_set_title - * @view: The view to set. - * @title: The new title value. - */ -void -gal_view_set_title (GalView *view, - const gchar *title) -{ - GalViewClass *class; - - g_return_if_fail (GAL_IS_VIEW (view)); - - class = GAL_VIEW_GET_CLASS (view); - g_return_if_fail (class->set_title != NULL); - - class->set_title (view, title); - - g_object_notify (G_OBJECT (view), "title"); -} - -/** - * gal_view_get_type_code - * @view: The view to get. - * - * Returns: The type of the view. - */ -const gchar * -gal_view_get_type_code (GalView *view) -{ - GalViewClass *class; - - g_return_val_if_fail (GAL_IS_VIEW (view), NULL); - - class = GAL_VIEW_GET_CLASS (view); - g_return_val_if_fail (class->get_type_code != NULL, NULL); - - return class->get_type_code (view); -} - -/** - * gal_view_clone - * @view: The view to clone. - * - * Returns: The clone. - */ -GalView * -gal_view_clone (GalView *view) -{ - GalViewClass *class; - - g_return_val_if_fail (GAL_IS_VIEW (view), NULL); - - class = GAL_VIEW_GET_CLASS (view); - g_return_val_if_fail (class->clone != NULL, NULL); - - return class->clone (view); -} - -/** - * gal_view_changed - * @view: The view that changed. - */ -void -gal_view_changed (GalView *view) -{ - g_return_if_fail (GAL_IS_VIEW (view)); - - g_signal_emit (view, signals[CHANGED], 0); -} - diff --git a/widgets/menus/gal-view.h b/widgets/menus/gal-view.h deleted file mode 100644 index 84c26ba77f..0000000000 --- a/widgets/menus/gal-view.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Chris Lahey - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef GAL_VIEW_H -#define GAL_VIEW_H - -#include -#include - -/* Standard GObject macros */ -#define GAL_TYPE_VIEW \ - (gal_view_get_type ()) -#define GAL_VIEW(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), GAL_TYPE_VIEW, GalView)) -#define GAL_VIEW_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), GAL_TYPE_VIEW, GalViewClass)) -#define GAL_IS_VIEW(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), GAL_TYPE_VIEW)) -#define GAL_IS_VIEW_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), GAL_TYPE_VIEW)) -#define GAL_VIEW_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), GAL_TYPE_VIEW, GalViewClass)) - -G_BEGIN_DECLS - -typedef struct _GalView GalView; -typedef struct _GalViewClass GalViewClass; - -struct _GalView { - GObject parent; -}; - -struct _GalViewClass { - GObjectClass parent_class; - - /* Methods */ - void (*edit) (GalView *view, - GtkWindow *parent_window); - void (*load) (GalView *view, - const gchar *filename); - void (*save) (GalView *view, - const gchar *filename); - const gchar * (*get_title) (GalView *view); - void (*set_title) (GalView *view, - const gchar *title); - const gchar * (*get_type_code) (GalView *view); - GalView * (*clone) (GalView *view); - - /* Signals */ - void (*changed) (GalView *view); -}; - -GType gal_view_get_type (void); -void gal_view_edit (GalView *view, - GtkWindow *parent); -void gal_view_load (GalView *view, - const gchar *filename); -void gal_view_save (GalView *view, - const gchar *filename); -const gchar * gal_view_get_title (GalView *view); -void gal_view_set_title (GalView *view, - const gchar *title); -const gchar * gal_view_get_type_code (GalView *view); -GalView * gal_view_clone (GalView *view); -void gal_view_changed (GalView *view); - -G_END_DECLS - -#endif /* GAL_VIEW_H */ -- cgit v1.2.3