aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/menus/gal-view-instance-save-as-dialog.c
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2002-02-07 18:22:59 +0800
committerChris Lahey <clahey@src.gnome.org>2002-02-07 18:22:59 +0800
commit9f1ac34671b0446c8eb8855e0aca62d5b69840b0 (patch)
treeca6f4d720aa6642ddd43c348adb92cb1e5ba0327 /widgets/menus/gal-view-instance-save-as-dialog.c
parent6190f4f6879d8533bdb97a7baba33773a6d71d6c (diff)
downloadgsoc2013-evolution-9f1ac34671b0446c8eb8855e0aca62d5b69840b0.tar
gsoc2013-evolution-9f1ac34671b0446c8eb8855e0aca62d5b69840b0.tar.gz
gsoc2013-evolution-9f1ac34671b0446c8eb8855e0aca62d5b69840b0.tar.bz2
gsoc2013-evolution-9f1ac34671b0446c8eb8855e0aca62d5b69840b0.tar.lz
gsoc2013-evolution-9f1ac34671b0446c8eb8855e0aca62d5b69840b0.tar.xz
gsoc2013-evolution-9f1ac34671b0446c8eb8855e0aca62d5b69840b0.tar.zst
gsoc2013-evolution-9f1ac34671b0446c8eb8855e0aca62d5b69840b0.zip
Bumped the version number to 0.19.99.5.
2002-02-07 Christopher James Lahey <clahey@ximian.com> * configure.in: Bumped the version number to 0.19.99.5. * gal/Makefile.am (libgal_la_LIBADD): Added menus/gal-view-instance-save-as-dialog.lo. * gal/e-text/e-text.c (next_word): Contains refactored code from the E_TEP_FORWARD_WORD case of e_text_command. (e_text_command): Implemented E_TEP_CAPS. From gal/menus/ChangeLog: 2002-02-07 Christopher James Lahey <clahey@ximian.com> * Makefile.am (glade_DATA): Added gal-view-instance-save-as-dialog.glade. (libgalmenus_la_SOURCES): Added gal-view-instance-save-as-dialog.c. (libgalmenusinclude_HEADERS): Added gal-view-instance-save-as-dialog.h. * gal-view-collection.c, gal-view-collection.h (gal_view_collection_append_with_title): Added this new version of the append function that sets the title and returns the new id as well. (gal_view_collection_set_nth_view): Added this function to save over another view. (gal_view_collection_get_default_view, gal_view_collection_set_default_view): Added the concept of a default view for GalViewCollections. * gal-view-etable.c, gal-view-etable.h (gal_view_etable_attach_table, gal_view_etable_attach_tree, gal_view_etable_detach): Added functions to set the state of a table or tree and then send GalView "changed" signals whenever that state changes. (gal_view_etable_set_state): New function to set the ETableState of a GalViewETable. * gal-view-instance-save-as-dialog.c, gal-view-instance-save-as-dialog.glade, gal-view-instance-save-as-dialog.h: New dialog to save the current custom view as a named view. * gal-view-instance.c, gal-view-instance.h (gal_view_instance_set_custom_view): New function to set the state of an instance to custom view and set the custom view to a particular GalView. (gal_view_instance_exists): New function to check if this particular instance has ever been opened before. Use before gal_view_instance_load. (gal_view_instance_save_as): New function to open a save as dialog. (gal_view_instance_load): Added this function which used to be part of _construct. This function can be called multiple times, and those extra times will be ignored. This is so you can set a default view before loading. (gal_view_instance_get_default_view, gal_view_instance_set_default_view): Set the default view for this instance. If unset, this falls back to the default view for the corresponding GalViewCollection. svn path=/trunk/; revision=15590
Diffstat (limited to 'widgets/menus/gal-view-instance-save-as-dialog.c')
-rw-r--r--widgets/menus/gal-view-instance-save-as-dialog.c309
1 files changed, 309 insertions, 0 deletions
diff --git a/widgets/menus/gal-view-instance-save-as-dialog.c b/widgets/menus/gal-view-instance-save-as-dialog.c
new file mode 100644
index 0000000000..329bc97e37
--- /dev/null
+++ b/widgets/menus/gal-view-instance-save-as-dialog.c
@@ -0,0 +1,309 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * gal-define-views-dialog.c
+ * Copyright 2000, 2001, Ximian, Inc.
+ *
+ * Authors:
+ * Chris Lahey <clahey@ximian.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <libgnomeui/gnome-dialog.h>
+#include <libgnomeui/gnome-stock.h>
+#include "gal-view-instance-save-as-dialog.h"
+#include "gal-define-views-model.h"
+#include "gal-view-new-dialog.h"
+#include <gal/e-table/e-table-scrolled.h>
+
+static GnomeDialogClass *parent_class = NULL;
+#define PARENT_TYPE gnome_dialog_get_type()
+
+/* The arguments we take */
+enum {
+ ARG_0,
+ ARG_INSTANCE,
+};
+
+typedef struct {
+ char *title;
+ ETableModel *model;
+ GalViewInstanceSaveAsDialog *names;
+} GalViewInstanceSaveAsDialogChild;
+
+
+/* Static functions */
+static void
+gal_view_instance_save_as_dialog_set_instance(GalViewInstanceSaveAsDialog *dialog,
+ GalViewInstance *instance)
+{
+ dialog->instance = instance;
+ if (dialog->model) {
+ gtk_object_set(GTK_OBJECT(dialog->model),
+ "collection", instance ? instance->collection : NULL,
+ NULL);
+ }
+}
+
+static void
+gvisad_setup_radio_buttons (GalViewInstanceSaveAsDialog *dialog)
+{
+ GtkWidget *radio_replace = glade_xml_get_widget (dialog->gui, "radiobutton-replace");
+ GtkWidget *radio_create = glade_xml_get_widget (dialog->gui, "radiobutton-create" );
+ GtkWidget *widget;
+ GtkNotebook *notebook = GTK_NOTEBOOK (glade_xml_get_widget (dialog->gui, "notebook-help"));
+
+ widget = glade_xml_get_widget (dialog->gui, "custom-replace");
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_replace))) {
+ gtk_widget_set_sensitive (widget, TRUE);
+ gtk_notebook_set_page (notebook, 0);
+ dialog->toggle = GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TOGGLE_REPLACE;
+ } else {
+ gtk_widget_set_sensitive (widget, FALSE);
+ }
+
+ widget = glade_xml_get_widget (dialog->gui, "entry-create");
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_create))) {
+ gtk_widget_set_sensitive (widget, TRUE);
+ gtk_notebook_set_page (notebook, 1);
+ dialog->toggle = GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TOGGLE_CREATE;
+ } else {
+ gtk_widget_set_sensitive (widget, FALSE);
+ }
+}
+
+static void
+gvisad_radio_toggled (GtkWidget *widget, GalViewInstanceSaveAsDialog *dialog)
+{
+ gvisad_setup_radio_buttons (dialog);
+}
+
+static void
+gvisad_connect_signal(GalViewInstanceSaveAsDialog *dialog, char *widget_name, char *signal, GtkSignalFunc handler)
+{
+ GtkWidget *widget;
+
+ widget = glade_xml_get_widget(dialog->gui, widget_name);
+
+ if (widget)
+ gtk_signal_connect(GTK_OBJECT(widget), signal, handler, dialog);
+}
+
+/* Method override implementations */
+static void
+gal_view_instance_save_as_dialog_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
+{
+ GalViewInstanceSaveAsDialog *dialog;
+
+ dialog = GAL_VIEW_INSTANCE_SAVE_AS_DIALOG (o);
+
+ switch (arg_id){
+ case ARG_INSTANCE:
+ if (GTK_VALUE_OBJECT(*arg))
+ gal_view_instance_save_as_dialog_set_instance(dialog, GAL_VIEW_INSTANCE(GTK_VALUE_OBJECT(*arg)));
+ else
+ gal_view_instance_save_as_dialog_set_instance(dialog, NULL);
+ break;
+
+ default:
+ return;
+ }
+}
+
+static void
+gal_view_instance_save_as_dialog_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
+{
+ GalViewInstanceSaveAsDialog *dialog;
+
+ dialog = GAL_VIEW_INSTANCE_SAVE_AS_DIALOG (object);
+
+ switch (arg_id) {
+ case ARG_INSTANCE:
+ if (dialog->instance)
+ GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(dialog->instance);
+ else
+ GTK_VALUE_OBJECT(*arg) = NULL;
+ break;
+
+ default:
+ arg->type = GTK_TYPE_INVALID;
+ break;
+ }
+}
+
+static void
+gal_view_instance_save_as_dialog_destroy (GtkObject *object)
+{
+ GalViewInstanceSaveAsDialog *gal_view_instance_save_as_dialog = GAL_VIEW_INSTANCE_SAVE_AS_DIALOG(object);
+
+ gtk_object_unref(GTK_OBJECT(gal_view_instance_save_as_dialog->gui));
+
+ if (GTK_OBJECT_CLASS (parent_class)->destroy)
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+}
+
+/* Init functions */
+static void
+gal_view_instance_save_as_dialog_class_init (GalViewInstanceSaveAsDialogClass *klass)
+{
+ GtkObjectClass *object_class;
+
+ object_class = (GtkObjectClass*) klass;
+
+ parent_class = gtk_type_class (PARENT_TYPE);
+
+ object_class->set_arg = gal_view_instance_save_as_dialog_set_arg;
+ object_class->get_arg = gal_view_instance_save_as_dialog_get_arg;
+ object_class->destroy = gal_view_instance_save_as_dialog_destroy;
+
+ gtk_object_add_arg_type("GalViewInstanceSaveAsDialog::instance", GAL_VIEW_INSTANCE_TYPE,
+ GTK_ARG_READWRITE, ARG_INSTANCE);
+}
+
+static void
+gal_view_instance_save_as_dialog_init (GalViewInstanceSaveAsDialog *dialog)
+{
+ GladeXML *gui;
+ GtkWidget *widget;
+ GtkWidget *etable;
+
+ dialog->instance = NULL;
+
+ gui = glade_xml_new_with_domain (GAL_GLADEDIR "/gal-view-instance-save-as-dialog.glade", NULL, PACKAGE);
+ dialog->gui = gui;
+
+ widget = glade_xml_get_widget(gui, "table-top");
+ if (!widget) {
+ return;
+ }
+ gtk_widget_ref(widget);
+ gtk_widget_unparent(widget);
+ gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(dialog)->vbox), widget, TRUE, TRUE, 0);
+ gtk_widget_unref(widget);
+
+ gnome_dialog_append_buttons(GNOME_DIALOG(dialog),
+ GNOME_STOCK_BUTTON_OK,
+ GNOME_STOCK_BUTTON_CANCEL,
+ NULL);
+
+ gvisad_connect_signal(dialog, "radiobutton-replace", "toggled", GTK_SIGNAL_FUNC(gvisad_radio_toggled));
+ gvisad_connect_signal(dialog, "radiobutton-create", "toggled", GTK_SIGNAL_FUNC(gvisad_radio_toggled));
+
+ dialog->model = NULL;
+ etable = glade_xml_get_widget(dialog->gui, "custom-replace");
+ if (etable) {
+ dialog->model = gtk_object_get_data(GTK_OBJECT(etable), "GalViewInstanceSaveAsDialog::model");
+ gtk_object_set(GTK_OBJECT(dialog->model),
+ "collection", dialog->instance ? dialog->instance->collection : NULL,
+ NULL);
+ }
+
+ gvisad_setup_radio_buttons (dialog);
+ gtk_window_set_policy(GTK_WINDOW(dialog), FALSE, TRUE, FALSE);
+}
+
+
+/* For use from libglade. */
+/* ETable creation */
+#define SPEC "<ETableSpecification no-header=\"true\" cursor-mode=\"line\" draw-grid=\"false\" selection-mode=\"single\">" \
+ "<ETableColumn model_col= \"0\" _title=\"Name\" expansion=\"1.0\" minimum_width=\"18\" resizable=\"true\" cell=\"string\" compare=\"string\"/>" \
+ "<ETableState> <column source=\"0\"/> <grouping> </grouping> </ETableState>" \
+ "</ETableSpecification>"
+
+GtkWidget *gal_view_instance_save_as_dialog_create_etable(char *name, char *string1, char *string2, int int1, int int2);
+
+GtkWidget *
+gal_view_instance_save_as_dialog_create_etable(char *name, char *string1, char *string2, int int1, int int2)
+{
+ GtkWidget *table;
+ ETableModel *model;
+ model = gal_define_views_model_new();
+ table = e_table_scrolled_new(model, NULL, SPEC, NULL);
+ gtk_object_set_data(GTK_OBJECT(table), "GalViewInstanceSaveAsDialog::model", model);
+ return table;
+}
+
+/* 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 = GTK_WIDGET (gtk_type_new (gal_view_instance_save_as_dialog_get_type ()));
+ gal_view_instance_save_as_dialog_set_instance(GAL_VIEW_INSTANCE_SAVE_AS_DIALOG (widget), instance);
+ return widget;
+}
+
+GtkType
+gal_view_instance_save_as_dialog_get_type (void)
+{
+ static GtkType type = 0;
+
+ if (!type) {
+ static const GtkTypeInfo info =
+ {
+ "GalViewInstanceSaveAsDialog",
+ sizeof (GalViewInstanceSaveAsDialog),
+ sizeof (GalViewInstanceSaveAsDialogClass),
+ (GtkClassInitFunc) gal_view_instance_save_as_dialog_class_init,
+ (GtkObjectInitFunc) gal_view_instance_save_as_dialog_init,
+ /* reserved_1 */ NULL,
+ /* reserved_2 */ NULL,
+ (GtkClassInitFunc) NULL,
+ };
+
+ type = gtk_type_unique (PARENT_TYPE, &info);
+ }
+
+ return type;
+}
+
+void
+gal_view_instance_save_as_dialog_save (GalViewInstanceSaveAsDialog *dialog)
+{
+ GalView *view = gal_view_instance_get_current_view (dialog->instance);
+ GtkWidget *widget;
+ char *title;
+ int n;
+ const char *id = NULL;
+ switch (dialog->toggle) {
+ case GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TOGGLE_REPLACE:
+ widget = glade_xml_get_widget(dialog->gui, "custom-replace");
+ if (widget && E_IS_TABLE_SCROLLED (widget)) {
+ n = e_table_get_cursor_row (e_table_scrolled_get_table (E_TABLE_SCROLLED (widget)));
+ 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:
+ widget = glade_xml_get_widget(dialog->gui, "entry-create");
+ if (widget && GTK_IS_ENTRY (widget)) {
+ title = gtk_entry_get_text (GTK_ENTRY (widget));
+ 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);
+ }
+}