aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--widgets/menus/gal-define-views-dialog.c98
-rw-r--r--widgets/menus/gal-define-views-dialog.h4
-rw-r--r--widgets/menus/gal-define-views-model.c79
-rw-r--r--widgets/menus/gal-define-views-model.h16
-rw-r--r--widgets/menus/gal-view-collection.c42
-rw-r--r--widgets/menus/gal-view-etable.c56
-rw-r--r--widgets/menus/gal-view-etable.h6
-rw-r--r--widgets/menus/gal-view-factory-etable.c21
-rw-r--r--widgets/menus/gal-view-factory.c4
-rw-r--r--widgets/menus/gal-view.c21
-rw-r--r--widgets/menus/gal-view.h4
11 files changed, 315 insertions, 36 deletions
diff --git a/widgets/menus/gal-define-views-dialog.c b/widgets/menus/gal-define-views-dialog.c
index f92f1520c7..b1e5d6aba6 100644
--- a/widgets/menus/gal-define-views-dialog.c
+++ b/widgets/menus/gal-define-views-dialog.c
@@ -38,6 +38,7 @@ static GnomeDialogClass *parent_class = NULL;
/* The arguments we take */
enum {
ARG_0,
+ ARG_COLLECTION,
};
typedef struct {
@@ -82,10 +83,13 @@ gal_define_views_dialog_class_init (GalDefineViewsDialogClass *klass)
object_class->set_arg = gal_define_views_dialog_set_arg;
object_class->get_arg = gal_define_views_dialog_get_arg;
object_class->destroy = gal_define_views_dialog_destroy;
+
+ gtk_object_add_arg_type("GalDefineViewsDialog::collection", GTK_TYPE_OBJECT,
+ GTK_ARG_READWRITE, ARG_COLLECTION);
}
/* ETable creation */
-#define SPEC "<ETableSpecification cursor-mode=\"line\" draw-grid=\"true\">" \
+#define SPEC "<ETableSpecification cursor-mode=\"line\" draw-grid=\"true\" 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>"
@@ -139,6 +143,62 @@ gdvd_button_new_callback(GtkWidget *widget, GalDefineViewsDialog *dialog)
}
static void
+gdvd_button_modify_callback(GtkWidget *widget, GalDefineViewsDialog *dialog)
+{
+ int row;
+ GtkWidget *scrolled;
+ ETable *etable;
+
+ scrolled = glade_xml_get_widget(dialog->gui, "custom-table");
+ etable = e_table_scrolled_get_table(E_TABLE_SCROLLED(scrolled));
+ row = e_table_get_cursor_row (E_TABLE(etable));
+
+ if (row != -1) {
+ GalView *view;
+ view = gal_define_views_model_get_view(GAL_DEFINE_VIEWS_MODEL(dialog->model),
+ row);
+ gal_view_edit(view);
+ }
+
+}
+
+static void
+gdvd_button_delete_callback(GtkWidget *widget, GalDefineViewsDialog *dialog)
+{
+ int row;
+ GtkWidget *scrolled;
+ ETable *etable;
+
+ scrolled = glade_xml_get_widget(dialog->gui, "custom-table");
+ etable = e_table_scrolled_get_table(E_TABLE_SCROLLED(scrolled));
+ row = e_table_get_cursor_row (E_TABLE(etable));
+
+ if (row != -1) {
+ gal_define_views_model_delete_view(GAL_DEFINE_VIEWS_MODEL(dialog->model),
+ row);
+ }
+
+}
+
+static void
+gdvd_button_copy_callback(GtkWidget *widget, GalDefineViewsDialog *dialog)
+{
+ int row;
+ GtkWidget *scrolled;
+ ETable *etable;
+
+ scrolled = glade_xml_get_widget(dialog->gui, "custom-table");
+ etable = e_table_scrolled_get_table(E_TABLE_SCROLLED(scrolled));
+ row = e_table_get_cursor_row (E_TABLE(etable));
+
+ if (row != -1) {
+ gal_define_views_model_copy_view(GAL_DEFINE_VIEWS_MODEL(dialog->model),
+ row);
+ }
+
+}
+
+static void
gdvd_connect_signal(GalDefineViewsDialog *dialog, char *widget_name, char *signal, GtkSignalFunc handler)
{
GtkWidget *widget;
@@ -173,7 +233,10 @@ gal_define_views_dialog_init (GalDefineViewsDialog *dialog)
GNOME_STOCK_BUTTON_CANCEL,
NULL);
- gdvd_connect_signal(dialog, "button-new", "clicked", GTK_SIGNAL_FUNC(gdvd_button_new_callback));
+ gdvd_connect_signal(dialog, "button-new", "clicked", GTK_SIGNAL_FUNC(gdvd_button_new_callback));
+ gdvd_connect_signal(dialog, "button-modify", "clicked", GTK_SIGNAL_FUNC(gdvd_button_modify_callback));
+ gdvd_connect_signal(dialog, "button-delete", "clicked", GTK_SIGNAL_FUNC(gdvd_button_delete_callback));
+ gdvd_connect_signal(dialog, "button-copy", "clicked", GTK_SIGNAL_FUNC(gdvd_button_copy_callback));
dialog->model = NULL;
etable = glade_xml_get_widget(dialog->gui, "custom-table");
@@ -187,10 +250,17 @@ gal_define_views_dialog_init (GalDefineViewsDialog *dialog)
static void
gal_define_views_dialog_destroy (GtkObject *object) {
GalDefineViewsDialog *gal_define_views_dialog = GAL_DEFINE_VIEWS_DIALOG(object);
-
+
gtk_object_unref(GTK_OBJECT(gal_define_views_dialog->gui));
}
+/**
+ * gal_define_views_dialog_new
+ *
+ * Returns a new dialog for defining views.
+ *
+ * Returns: The GalDefineViewsDialog.
+ */
GtkWidget*
gal_define_views_dialog_new (void)
{
@@ -201,11 +271,18 @@ gal_define_views_dialog_new (void)
static void
gal_define_views_dialog_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
{
- GalDefineViewsDialog *editor;
+ GalDefineViewsDialog *dialog;
- editor = GAL_DEFINE_VIEWS_DIALOG (o);
+ dialog = GAL_DEFINE_VIEWS_DIALOG (o);
switch (arg_id){
+ case ARG_COLLECTION:
+ if (GTK_VALUE_OBJECT(*arg))
+ dialog->collection = GAL_VIEW_COLLECTION(GTK_VALUE_OBJECT(*arg));
+ else
+ dialog->collection = NULL;
+ break;
+
default:
return;
}
@@ -214,11 +291,18 @@ gal_define_views_dialog_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
static void
gal_define_views_dialog_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
{
- GalDefineViewsDialog *gal_define_views_dialog;
+ GalDefineViewsDialog *dialog;
- gal_define_views_dialog = GAL_DEFINE_VIEWS_DIALOG (object);
+ dialog = GAL_DEFINE_VIEWS_DIALOG (object);
switch (arg_id) {
+ case ARG_COLLECTION:
+ if (dialog->collection)
+ GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(dialog->collection);
+ else
+ GTK_VALUE_OBJECT(*arg) = NULL;
+ break;
+
default:
arg->type = GTK_TYPE_INVALID;
break;
diff --git a/widgets/menus/gal-define-views-dialog.h b/widgets/menus/gal-define-views-dialog.h
index 11daec5897..b4ac80c492 100644
--- a/widgets/menus/gal-define-views-dialog.h
+++ b/widgets/menus/gal-define-views-dialog.h
@@ -51,7 +51,7 @@ typedef struct _GalDefineViewsDialogClass GalDefineViewsDialogClass;
struct _GalDefineViewsDialog
{
GnomeDialog parent;
-
+
/* item specific fields */
GladeXML *gui;
ETableModel *model;
@@ -67,8 +67,6 @@ struct _GalDefineViewsDialogClass
GtkWidget *gal_define_views_dialog_new (void);
GtkType gal_define_views_dialog_get_type (void);
-void gal_define_views_dialog_add_section (GalDefineViewsDialog *gal_define_views_dialog);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/widgets/menus/gal-define-views-model.c b/widgets/menus/gal-define-views-model.c
index 79fbf56c4a..4f988c09bb 100644
--- a/widgets/menus/gal-define-views-model.c
+++ b/widgets/menus/gal-define-views-model.c
@@ -130,6 +130,13 @@ gdvm_value_to_string (ETableModel *etc, int col, const void *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)
@@ -157,7 +164,7 @@ gal_define_views_model_class_init (GtkObjectClass *object_class)
gtk_object_add_arg_type ("GalDefineViewsModel::editable", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_EDITABLE);
-
+
model_class->column_count = gdvm_col_count;
model_class->row_count = gdvm_row_count;
model_class->value_at = gdvm_value_at;
@@ -187,7 +194,7 @@ gal_define_views_model_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
GalDefineViewsModel *model;
model = GAL_DEFINE_VIEWS_MODEL (o);
-
+
switch (arg_id){
case ARG_EDITABLE:
model->editable = GTK_VALUE_BOOL (*arg);
@@ -235,12 +242,78 @@ gal_define_views_model_get_type (void)
return type;
}
+/**
+ * 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 = gtk_type_new (gal_define_views_model_get_type ());
-
+
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,
+ int n)
+{
+ return model->data[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,
+ int n)
+{
+ e_table_model_pre_change(E_TABLE_MODEL(model));
+ gtk_object_unref(GTK_OBJECT(model->data[n]));
+ model->data_count --;
+ memmove(model->data + n, model->data + n + 1, (model->data_count - n) * sizeof(*model->data));
+ model->data = g_renew(GalView *, model->data, model->data_count);
+ 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,
+ int n)
+{
+ ETableModel *etm = E_TABLE_MODEL(model);
+ GalView *view;
+
+ view = gal_view_clone (model->data[n]);
+
+ e_table_model_pre_change(etm);
+ model->data = g_renew(GalView *, model->data, model->data_count + 1);
+ model->data[model->data_count] = view;
+ model->data_count++;
+ e_table_model_row_inserted(etm, model->data_count - 1);
+}
diff --git a/widgets/menus/gal-define-views-model.h b/widgets/menus/gal-define-views-model.h
index cdd729eef0..4f1115d66a 100644
--- a/widgets/menus/gal-define-views-model.h
+++ b/widgets/menus/gal-define-views-model.h
@@ -34,10 +34,16 @@ typedef struct {
} GalDefineViewsModelClass;
-GtkType gal_define_views_model_get_type (void);
-ETableModel *gal_define_views_model_new (void);
-
-void gal_define_views_model_append (GalDefineViewsModel *model,
- GalView *view);
+GtkType 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,
+ int i);
+void gal_define_views_model_delete_view (GalDefineViewsModel *model,
+ int i);
+void gal_define_views_model_copy_view (GalDefineViewsModel *model,
+ int i);
#endif /* _GAL_DEFINE_VIEWS_MODEL_H_ */
diff --git a/widgets/menus/gal-view-collection.c b/widgets/menus/gal-view-collection.c
index 5b625c44f4..30652f064f 100644
--- a/widgets/menus/gal-view-collection.c
+++ b/widgets/menus/gal-view-collection.c
@@ -83,6 +83,10 @@ gal_view_collection_init (GalViewCollection *collection)
collection->factory_list = NULL;
}
+/**
+ * gal_view_collection_get_type:
+ *
+ */
guint
gal_view_collection_get_type (void)
{
@@ -108,20 +112,44 @@ gal_view_collection_get_type (void)
return type;
}
-GalViewCollection *gal_view_collection_new (void)
+/**
+ * gal_view_collection_new:
+ *
+ * A collection of views and view factories.
+ */
+GalViewCollection *
+gal_view_collection_new (void)
{
return gtk_type_new(gal_view_collection_get_type());
}
-/* Set up the view collection */
-void gal_view_collection_set_storage_directories (GalViewCollection *collection,
- char *system_dir,
- char *local_dir)
+/**
+ * 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,
+ char *system_dir,
+ char *local_dir)
{
}
-void gal_view_collection_add_factory (GalViewCollection *collection,
- GalViewFactory *factory)
+/**
+ * gal_view_collection_add_factory
+ * @collection: The view collection to add a factory to
+ * @factory: The factory to add
+ *
+ * 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)
{
gtk_object_ref(GTK_OBJECT(factory));
collection->factory_list = g_list_prepend(collection->factory_list, factory);
diff --git a/widgets/menus/gal-view-etable.c b/widgets/menus/gal-view-etable.c
index d990e29ff9..b748f66952 100644
--- a/widgets/menus/gal-view-etable.c
+++ b/widgets/menus/gal-view-etable.c
@@ -9,6 +9,7 @@
*/
#include <config.h>
#include "gal-view-etable.h"
+#include <gal/e-table/e-table-config.h>
#define PARENT_TYPE gal_view_get_type ()
@@ -17,7 +18,10 @@ static GalViewClass *gal_view_etable_parent_class;
static void
gal_view_etable_edit (GalView *view)
{
-
+ GalViewEtable *etable_view = GAL_VIEW_ETABLE(view);
+ e_table_config_new(etable_view->title,
+ etable_view->spec,
+ etable_view->state);
}
static void
@@ -40,6 +44,23 @@ gal_view_etable_get_title (GalView *view)
return GAL_VIEW_ETABLE(view)->title;
}
+static GalView *
+gal_view_etable_clone (GalView *view)
+{
+ GalViewEtable *gve, *new;
+
+ gve = GAL_VIEW_ETABLE(view);
+
+ new = gtk_type_new (gal_view_etable_get_type ());
+ new->spec = gve->spec;
+ new->title = g_strdup (gve->title);
+ new->state = e_table_state_duplicate(gve->state);
+
+ gtk_object_ref(GTK_OBJECT(new->spec));
+
+ return GAL_VIEW(new);
+}
+
static void
gal_view_etable_destroy (GtkObject *object)
{
@@ -61,6 +82,7 @@ gal_view_etable_class_init (GtkObjectClass *object_class)
gal_view_class->load_from_node = gal_view_etable_load_from_node;
gal_view_class->save_to_node = gal_view_etable_save_to_node ;
gal_view_class->get_title = gal_view_etable_get_title ;
+ gal_view_class->clone = gal_view_etable_clone ;
object_class->destroy = gal_view_etable_destroy ;
}
@@ -69,23 +91,47 @@ static void
gal_view_etable_init (GalViewEtable *gve)
{
gve->spec = NULL;
- gve->state = 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)
+gal_view_etable_new (ETableSpecification *spec,
+ const gchar *title)
{
- return gal_view_etable_construct (gtk_type_new (gal_view_etable_get_type ()), spec);
+ return gal_view_etable_construct (gtk_type_new (gal_view_etable_get_type ()), 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)
+ ETableSpecification *spec,
+ const gchar *title)
{
if (spec)
gtk_object_ref(GTK_OBJECT(spec));
view->spec = spec;
+ view->title = g_strdup(title);
return GAL_VIEW(view);
}
diff --git a/widgets/menus/gal-view-etable.h b/widgets/menus/gal-view-etable.h
index 5744da52ec..98a1ddc861 100644
--- a/widgets/menus/gal-view-etable.h
+++ b/widgets/menus/gal-view-etable.h
@@ -27,8 +27,10 @@ typedef struct {
/* Standard functions */
GtkType gal_view_etable_get_type (void);
-GalView *gal_view_etable_new (ETableSpecification *spec);
+GalView *gal_view_etable_new (ETableSpecification *spec,
+ const gchar *title);
GalView *gal_view_etable_construct (GalViewEtable *view,
- ETableSpecification *spec);
+ ETableSpecification *spec,
+ const gchar *title);
#endif /* _GAL_VIEW_ETABLE_H_ */
diff --git a/widgets/menus/gal-view-factory-etable.c b/widgets/menus/gal-view-factory-etable.c
index 918838050a..0a013c71e6 100644
--- a/widgets/menus/gal-view-factory-etable.c
+++ b/widgets/menus/gal-view-factory-etable.c
@@ -29,7 +29,7 @@ static GalView *
gal_view_factory_etable_new_view (GalViewFactory *factory,
const char *name)
{
- return gal_view_etable_new(GAL_VIEW_FACTORY_ETABLE(factory)->spec);
+ return gal_view_etable_new(GAL_VIEW_FACTORY_ETABLE(factory)->spec, name);
}
static void
@@ -59,12 +59,31 @@ gal_view_factory_etable_init (GalViewFactoryEtable *factory)
factory->spec = NULL;
}
+/**
+ * gal_view_etable_new
+ * @spec: 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 *spec)
{
return gal_view_factory_etable_construct (gtk_type_new (gal_view_factory_etable_get_type ()), spec);
}
+/**
+ * gal_view_etable_construct
+ * @factory: The factory to construct
+ * @spec: The spec to create GalViewEtables based upon.
+ *
+ * constructs the GalViewFactoryEtable. To be used by subclasses and
+ * language bindings.
+ *
+ * Returns: The GalViewFactoryEtable.
+ */
GalViewFactory *
gal_view_factory_etable_construct (GalViewFactoryEtable *factory,
ETableSpecification *spec)
diff --git a/widgets/menus/gal-view-factory.c b/widgets/menus/gal-view-factory.c
index 1ba3e061bf..32eb7ad016 100644
--- a/widgets/menus/gal-view-factory.c
+++ b/widgets/menus/gal-view-factory.c
@@ -30,7 +30,7 @@ const char *
gal_view_factory_get_title (GalViewFactory *factory)
{
g_return_val_if_fail (factory != NULL, 0);
- g_return_val_if_fail (GAL_IS_VIEW (factory), 0);
+ g_return_val_if_fail (GAL_IS_VIEW_FACTORY (factory), 0);
if (GVF_CLASS (factory)->get_title)
return GVF_CLASS (factory)->get_title (factory);
@@ -50,7 +50,7 @@ gal_view_factory_new_view (GalViewFactory *factory,
const char *name)
{
g_return_val_if_fail (factory != NULL, 0);
- g_return_val_if_fail (GAL_IS_VIEW (factory), 0);
+ g_return_val_if_fail (GAL_IS_VIEW_FACTORY (factory), 0);
if (GVF_CLASS (factory)->new_view)
return GVF_CLASS (factory)->new_view (factory, name);
diff --git a/widgets/menus/gal-view.c b/widgets/menus/gal-view.c
index 1ff9ffab16..a9a57b5443 100644
--- a/widgets/menus/gal-view.c
+++ b/widgets/menus/gal-view.c
@@ -85,16 +85,35 @@ gal_view_get_title (GalView *view)
return NULL;
}
+/**
+ * gal_view_clone
+ * @view: The view to clone.
+ *
+ * Returns: The clone.
+ */
+GalView *
+gal_view_clone (GalView *view)
+{
+ g_return_val_if_fail (view != NULL, NULL);
+ g_return_val_if_fail (GAL_IS_VIEW (view), NULL);
+
+ if (GV_CLASS (view)->clone)
+ return GV_CLASS (view)->clone (view);
+ else
+ return NULL;
+}
+
static void
gal_view_class_init (GtkObjectClass *object_class)
{
- GalViewClass *klass = GAL_VIEW_CLASS(object_class);
+ GalViewClass *klass = GAL_VIEW_CLASS(object_class);
gal_view_parent_class = gtk_type_class (PARENT_TYPE);
klass->edit = NULL;
klass->load_from_node = NULL;
klass->save_to_node = NULL;
klass->get_title = NULL;
+ klass->clone = NULL;
}
GtkType
diff --git a/widgets/menus/gal-view.h b/widgets/menus/gal-view.h
index 7894e043dc..7860f08da7 100644
--- a/widgets/menus/gal-view.h
+++ b/widgets/menus/gal-view.h
@@ -27,6 +27,7 @@ typedef struct {
void (*save_to_node) (GalView *view,
xmlNode *parent);
const char *(*get_title) (GalView *view);
+ GalView *(*clone) (GalView *view);
} GalViewClass;
/* Standard functions */
@@ -44,5 +45,8 @@ void gal_view_save_to_node (GalView *view,
/* Query functions */
const char *gal_view_get_title (GalView *view);
+/* Cloning the view */
+GalView *gal_view_clone (GalView *view);
+
#endif /* _GAL_VIEW_H_ */