diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-11-12 05:45:24 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-11-12 05:45:24 +0800 |
commit | 2d64058a8f7c03d1035504eaacc219730b5cd3c6 (patch) | |
tree | c8a0537fe8db3b3685413e0ab2914b20ee7f8e9f /widgets | |
parent | 618515cd0beaed45af59994d84592b5d513bd979 (diff) | |
download | gsoc2013-evolution-2d64058a8f7c03d1035504eaacc219730b5cd3c6.tar.gz gsoc2013-evolution-2d64058a8f7c03d1035504eaacc219730b5cd3c6.tar.zst gsoc2013-evolution-2d64058a8f7c03d1035504eaacc219730b5cd3c6.zip |
Added a bunch of .lo s from the menus directory.
2000-11-11 Christopher James Lahey <clahey@helixcode.com>
* gal/Makefile.am: Added a bunch of .lo s from the menus
directory.
From gal/menus:
2000-11-11 Christopher James Lahey <clahey@helixcode.com>
* Makefile.am: Added gal-define-views-model.c,
gal-define-views-model.h, gal-view-new-dialog.c,
gal-view-new-dialog.h, gal-view-new-dialog.glade,
gal-view-new-dialog.glade.h, gal-view.c, and gal-view.h.
* gal-define-views-dialog.c, gal-define-views-dialog.h: Connect up
the New button. Use an ETable.
* gal-define-views.glade, gal-define-views.glade.h: Put in custom
object for the ETable
* gal-define-views-model.c, gal-define-views-model.h: New model
for list of views.
* gal-view-menus.c: Close the define views dialog when it's done.
* gal-view-new-dialog.c, gal-view-new-dialog.glade,
gal-view-new-dialog.glade.h, gal-view-new-dialog.h: New class for
creating a new view.
* gal-view.c, gal-view.h: New class for representing a single view
in the define views model.
svn path=/trunk/; revision=6544
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/menus/gal-define-views-dialog.c | 87 | ||||
-rw-r--r-- | widgets/menus/gal-define-views-dialog.h | 2 | ||||
-rw-r--r-- | widgets/menus/gal-define-views-model.c | 259 | ||||
-rw-r--r-- | widgets/menus/gal-define-views-model.h | 43 | ||||
-rw-r--r-- | widgets/menus/gal-define-views.glade | 15 | ||||
-rw-r--r-- | widgets/menus/gal-view-menus.c | 11 | ||||
-rw-r--r-- | widgets/menus/gal-view-new-dialog.c | 184 | ||||
-rw-r--r-- | widgets/menus/gal-view-new-dialog.glade | 148 | ||||
-rw-r--r-- | widgets/menus/gal-view-new-dialog.h | 70 | ||||
-rw-r--r-- | widgets/menus/gal-view.c | 97 | ||||
-rw-r--r-- | widgets/menus/gal-view.h | 27 |
11 files changed, 929 insertions, 14 deletions
diff --git a/widgets/menus/gal-define-views-dialog.c b/widgets/menus/gal-define-views-dialog.c index 7afe99f647..cf34ac8e90 100644 --- a/widgets/menus/gal-define-views-dialog.c +++ b/widgets/menus/gal-define-views-dialog.c @@ -22,7 +22,9 @@ #include <config.h> #include <gnome.h> #include "gal-define-views-dialog.h" -#include <gal/e-table/e-table-simple.h> +#include "gal-define-views-model.h" +#include "gal-view-new-dialog.h" +#include <gal/e-table/e-table-scrolled.h> static void gal_define_views_dialog_init (GalDefineViewsDialog *card); static void gal_define_views_dialog_class_init (GalDefineViewsDialogClass *klass); @@ -82,14 +84,79 @@ gal_define_views_dialog_class_init (GalDefineViewsDialogClass *klass) object_class->destroy = gal_define_views_dialog_destroy; } +/* ETable creation */ +#define SPEC "<ETableSpecification cursor-mode=\"line\" draw-grid=\"true\">" \ + "<ETableColumn model_col= \"0\" _tite=\"Name\" expansion=\"1.0\" minimum_width=\"18\" resizable=\"true\" cell=\"string\" compare=\"string\"/>" \ + "<ETableState> <column source=\"0\"/> <grouping> </grouping> </ETableState>" \ + "</ETableSpecification>" + +/* For use from libglade. */ +GtkWidget *gal_define_views_dialog_create_etable(char *name, char *string1, char *string2, int int1, int int2); + +GtkWidget * +gal_define_views_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(table, "GalDefineViewsDialog::model", model); + return table; +} + +/* Button callbacks */ + +static void +gdvd_button_new_dialog_callback(GtkWidget *widget, int button, GalDefineViewsDialog *dialog) +{ + gchar *name; + GalView *view; + switch (button) { + case 0: + gtk_object_get(GTK_OBJECT(widget), + "name", &name, + NULL); + view = gal_view_new(); + gtk_object_set(GTK_OBJECT(widget), + "name", name, + NULL); + gal_define_views_model_append(GAL_DEFINE_VIEWS_MODEL(dialog->model), view); + gtk_object_unref(GTK_OBJECT(view)); + break; + } + gnome_dialog_close(GNOME_DIALOG(widget)); +} + +static void +gdvd_button_new_callback(GtkWidget *widget, GalDefineViewsDialog *dialog) +{ + GtkWidget *view_new_dialog = gal_view_new_dialog_new(); + gtk_signal_connect(GTK_OBJECT(view_new_dialog), "clicked", + GTK_SIGNAL_FUNC(gdvd_button_new_dialog_callback), dialog); + gtk_widget_show(GTK_WIDGET(view_new_dialog)); +} + static void -gal_define_views_dialog_init (GalDefineViewsDialog *gal_define_views_dialog) +gdvd_connect_signal(GalDefineViewsDialog *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); +} + +static void +gal_define_views_dialog_init (GalDefineViewsDialog *dialog) { GladeXML *gui; GtkWidget *widget; + GtkWidget *etable; + ETableModel *model; gui = glade_xml_new (GAL_GLADEDIR "/gal-define-views.glade", NULL); - gal_define_views_dialog->gui = gui; + dialog->gui = gui; widget = glade_xml_get_widget(gui, "table-top"); if (!widget) { @@ -97,15 +164,23 @@ gal_define_views_dialog_init (GalDefineViewsDialog *gal_define_views_dialog) } gtk_widget_ref(widget); gtk_widget_unparent(widget); - gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(gal_define_views_dialog)->vbox), widget, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(dialog)->vbox), widget, TRUE, TRUE, 0); gtk_widget_unref(widget); - gnome_dialog_append_buttons(GNOME_DIALOG(gal_define_views_dialog), + gnome_dialog_append_buttons(GNOME_DIALOG(dialog), GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL); + + gdvd_connect_signal(dialog, "button-new", "clicked", GTK_SIGNAL_FUNC(gdvd_button_new_callback)); + + dialog->model = NULL; + etable = glade_xml_get_widget(dialog->gui, "custom-table"); + if (etable) { + dialog->model = gtk_object_get_data(GTK_OBJECT(etable), "GalDefineViewsDialog::model"); + } - gtk_window_set_policy(GTK_WINDOW(gal_define_views_dialog), FALSE, TRUE, FALSE); + gtk_window_set_policy(GTK_WINDOW(dialog), FALSE, TRUE, FALSE); } static void diff --git a/widgets/menus/gal-define-views-dialog.h b/widgets/menus/gal-define-views-dialog.h index aaa3ce06a1..7979d5042e 100644 --- a/widgets/menus/gal-define-views-dialog.h +++ b/widgets/menus/gal-define-views-dialog.h @@ -23,6 +23,7 @@ #include <gnome.h> #include <glade/glade.h> +#include <gal/e-table/e-table-model.h> #ifdef __cplusplus extern "C" { @@ -52,6 +53,7 @@ struct _GalDefineViewsDialog /* item specific fields */ GladeXML *gui; + ETableModel *model; }; struct _GalDefineViewsDialogClass diff --git a/widgets/menus/gal-define-views-model.c b/widgets/menus/gal-define-views-model.c new file mode 100644 index 0000000000..1e64857faf --- /dev/null +++ b/widgets/menus/gal-define-views-model.c @@ -0,0 +1,259 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * + * Author: + * Christopher James Lahey <clahey@helixcode.com> + * + * (C) 1999 Helix Code, Inc. + */ + +#include <config.h> +#include "gal-define-views-model.h" +#include <gnome-xml/tree.h> +#include <gnome-xml/parser.h> +#include <gnome-xml/xmlmemory.h> +#include <gnome.h> + +#define PARENT_TYPE e_table_model_get_type() +ETableModelClass *parent_class; + +/* + * GalDefineViewsModel callbacks + * These are the callbacks that define the behavior of our custom model. + */ +static void gal_define_views_model_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); +static void gal_define_views_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); + + +enum { + ARG_0, + ARG_EDITABLE, +}; + +static void +gdvm_destroy(GtkObject *object) +{ + GalDefineViewsModel *model = GAL_DEFINE_VIEWS_MODEL(object); + int i; + + for ( i = 0; i < model->data_count; i++ ) { + gtk_object_unref(GTK_OBJECT(model->data[i])); + } + g_free(model->data); +} + +/* This function returns the number of columns in our ETableModel. */ +static int +gdvm_col_count (ETableModel *etc) +{ + return 1; +} + +/* This function returns the number of rows in our ETableModel. */ +static int +gdvm_row_count (ETableModel *etc) +{ + GalDefineViewsModel *views = GAL_DEFINE_VIEWS_MODEL(etc); + return views->data_count; +} + +/* This function returns the value at a particular point in our ETableModel. */ +static void * +gdvm_value_at (ETableModel *etc, int col, int row) +{ + GalDefineViewsModel *views = GAL_DEFINE_VIEWS_MODEL(etc); + const char *value; + if (col != 0 || row < 0 || row > views->data_count) + return NULL; + + value = views->data[row]->name; + + return (void *)(value ? value : ""); +} + +/* This function sets the value at a particular point in our ETableModel. */ +static void +gdvm_set_value_at (ETableModel *etc, int col, int row, const void *val) +{ + GalDefineViewsModel *views = GAL_DEFINE_VIEWS_MODEL(etc); + if (views->editable) { + if (col != 0 || row < 0 || row > views->data_count) + return; + gtk_object_set(GTK_OBJECT(views->data[row]), + "name", val, + NULL); + 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, int col, int row) +{ + return GAL_DEFINE_VIEWS_MODEL(etc)->editable; +} + +static void +gdvm_append_row (ETableModel *etm, ETableModel *source, gint row) +{ + GalDefineViewsModel *views = GAL_DEFINE_VIEWS_MODEL(etm); + GalView *view; + const void *val = e_table_model_value_at(source, 0, row); + + e_table_model_pre_change(etm); + view = gal_view_new(); + gtk_object_set(GTK_OBJECT(view), + "name", val, + NULL); + views->data = g_renew(GalView *, views->data, views->data_count + 1); + views->data[views->data_count] = view; + views->data_count++; + e_table_model_row_inserted(etm, views->data_count - 1); +} + +/* This function duplicates the value passed to it. */ +static void * +gdvm_duplicate_value (ETableModel *etc, int col, const void *value) +{ + return g_strdup(value); +} + +/* This function frees the value passed to it. */ +static void +gdvm_free_value (ETableModel *etc, int col, void *value) +{ + g_free(value); +} + +static void * +gdvm_initialize_value (ETableModel *etc, int col) +{ + return g_strdup(""); +} + +static gboolean +gdvm_value_is_empty (ETableModel *etc, int col, const void *value) +{ + return !(value && *(char *)value); +} + +static char * +gdvm_value_to_string (ETableModel *etc, int col, const void *value) +{ + return g_strdup(value); +} + +void +gal_define_views_model_append (GalDefineViewsModel *model, + GalView *view) +{ + ETableModel *etm = E_TABLE_MODEL(model); + + 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++; + gtk_object_ref(GTK_OBJECT(view)); + e_table_model_row_inserted(etm, model->data_count - 1); +} + +static void +gal_define_views_model_class_init (GtkObjectClass *object_class) +{ + ETableModelClass *model_class = (ETableModelClass *) object_class; + + parent_class = gtk_type_class (PARENT_TYPE); + + object_class->destroy = gdvm_destroy; + object_class->set_arg = gal_define_views_model_set_arg; + object_class->get_arg = gal_define_views_model_get_arg; + + 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; + 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 (GtkObject *object) +{ + GalDefineViewsModel *model = GAL_DEFINE_VIEWS_MODEL(object); + + model->data = NULL; + model->data_count = 0; + model->editable = TRUE; +} + +static void +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); + break; + } +} + +static void +gal_define_views_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) +{ + GalDefineViewsModel *gal_define_views_model; + + gal_define_views_model = GAL_DEFINE_VIEWS_MODEL (object); + + switch (arg_id) { + case ARG_EDITABLE: + GTK_VALUE_BOOL (*arg) = gal_define_views_model->editable; + break; + default: + arg->type = GTK_TYPE_INVALID; + break; + } +} + +GtkType +gal_define_views_model_get_type (void) +{ + static GtkType type = 0; + + if (!type){ + GtkTypeInfo info = { + "GalDefineViewsModel", + sizeof (GalDefineViewsModel), + sizeof (GalDefineViewsModelClass), + (GtkClassInitFunc) gal_define_views_model_class_init, + (GtkObjectInitFunc) gal_define_views_model_init, + NULL, /* reserved 1 */ + NULL, /* reserved 2 */ + (GtkClassInitFunc) NULL + }; + + type = gtk_type_unique (PARENT_TYPE, &info); + } + + return type; +} + +ETableModel * +gal_define_views_model_new (void) +{ + GalDefineViewsModel *et; + + et = gtk_type_new (gal_define_views_model_get_type ()); + + return E_TABLE_MODEL(et); +} diff --git a/widgets/menus/gal-define-views-model.h b/widgets/menus/gal-define-views-model.h new file mode 100644 index 0000000000..cdd729eef0 --- /dev/null +++ b/widgets/menus/gal-define-views-model.h @@ -0,0 +1,43 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +#ifndef _GAL_DEFINE_VIEWS_MODEL_H_ +#define _GAL_DEFINE_VIEWS_MODEL_H_ + +#include <gal/e-table/e-table-model.h> +#include "gal-view.h" + +#define GAL_DEFINE_VIEWS_MODEL_TYPE (gal_define_views_model_get_type ()) +#define GAL_DEFINE_VIEWS_MODEL(o) (GTK_CHECK_CAST ((o), GAL_DEFINE_VIEWS_MODEL_TYPE, GalDefineViewsModel)) +#define GAL_DEFINE_VIEWS_MODEL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), GAL_DEFINE_VIEWS_MODEL_TYPE, GalDefineViewsModelClass)) +#define GAL_IS_DEFINE_VIEWS_MODEL(o) (GTK_CHECK_TYPE ((o), GAL_DEFINE_VIEWS_MODEL_TYPE)) +#define GAL_IS_DEFINE_VIEWS_MODEL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), GAL_DEFINE_VIEWS_MODEL_TYPE)) + +/* Virtual Column list: + 0 Email + 1 Full Name + 2 Street + 3 Phone +*/ + +typedef struct { + ETableModel parent; + + /* item specific fields */ + GalView **data; + int data_count; + + guint editable : 1; +} GalDefineViewsModel; + + +typedef struct { + ETableModelClass parent_class; +} 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); + +#endif /* _GAL_DEFINE_VIEWS_MODEL_H_ */ diff --git a/widgets/menus/gal-define-views.glade b/widgets/menus/gal-define-views.glade index 32938fd030..c78d854e2d 100644 --- a/widgets/menus/gal-define-views.glade +++ b/widgets/menus/gal-define-views.glade @@ -147,11 +147,12 @@ </child> <widget> - <class>GtkButton</class> - <name>button4</name> - <can_focus>True</can_focus> - <label>Table HERE</label> - <relief>GTK_RELIEF_NORMAL</relief> + <class>Custom</class> + <name>custom-table</name> + <creation_function>gal_define_views_dialog_create_etable</creation_function> + <int1>0</int1> + <int2>0</int2> + <last_modification_time>Fri, 10 Nov 2000 16:37:39 GMT</last_modification_time> <child> <padding>0</padding> <expand>True</expand> @@ -172,7 +173,7 @@ <widget> <class>GtkButton</class> - <name>button11</name> + <name>button-new</name> <can_focus>True</can_focus> <label>_New...</label> <relief>GTK_RELIEF_NORMAL</relief> @@ -312,7 +313,7 @@ <widget> <class>GtkButton</class> - <name>button12</name> + <name>button-reset</name> <can_focus>True</can_focus> <label>Re_set to Factory Defaults...</label> <relief>GTK_RELIEF_NORMAL</relief> diff --git a/widgets/menus/gal-view-menus.c b/widgets/menus/gal-view-menus.c index 398c34d789..f511f8b61d 100644 --- a/widgets/menus/gal-view-menus.c +++ b/widgets/menus/gal-view-menus.c @@ -50,11 +50,20 @@ gal_view_menus_new (void) } static void +dialog_clicked(GtkWidget *dialog, int button, GalViewMenus *menus) +{ + gnome_dialog_close(GNOME_DIALOG(dialog)); +} + +static void define_views(BonoboUIComponent *component, GalViewMenus *menus, char *cname) { - gtk_widget_show(gal_define_views_dialog_new()); + GtkWidget *dialog = gal_define_views_dialog_new(); + gtk_signal_connect(GTK_OBJECT(dialog), "clicked", + GTK_SIGNAL_FUNC(dialog_clicked), menus); + gtk_widget_show(dialog); } static BonoboUIVerb verbs[] = { diff --git a/widgets/menus/gal-view-new-dialog.c b/widgets/menus/gal-view-new-dialog.c new file mode 100644 index 0000000000..ad682359db --- /dev/null +++ b/widgets/menus/gal-view-new-dialog.c @@ -0,0 +1,184 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* gal-view-new-dialog.c + * Copyright (C) 2000 Helix Code, Inc. + * Author: Chris Lahey <clahey@helixcode.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include <config.h> +#include <gnome.h> +#include "gal-view-new-dialog.h" +#include "gal-define-views-model.h" +#include <gal/widgets/e-unicode.h> +#include <gal/e-table/e-table-scrolled.h> + +static void gal_view_new_dialog_init (GalViewNewDialog *card); +static void gal_view_new_dialog_class_init (GalViewNewDialogClass *klass); +static void gal_view_new_dialog_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); +static void gal_view_new_dialog_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); +static void gal_view_new_dialog_destroy (GtkObject *object); + +static GnomeDialogClass *parent_class = NULL; +#define PARENT_TYPE gnome_dialog_get_type() + +/* The arguments we take */ +enum { + ARG_0, + ARG_NAME, +}; + +GtkType +gal_view_new_dialog_get_type (void) +{ + static GtkType type = 0; + + if (!type) { + static const GtkTypeInfo info = + { + "GalViewNewDialog", + sizeof (GalViewNewDialog), + sizeof (GalViewNewDialogClass), + (GtkClassInitFunc) gal_view_new_dialog_class_init, + (GtkObjectInitFunc) gal_view_new_dialog_init, + /* reserved_1 */ NULL, + /* reserved_2 */ NULL, + (GtkClassInitFunc) NULL, + }; + + type = gtk_type_unique (PARENT_TYPE, &info); + } + + return type; +} + +static void +gal_view_new_dialog_class_init (GalViewNewDialogClass *klass) +{ + GtkObjectClass *object_class; + + object_class = (GtkObjectClass*) klass; + + parent_class = gtk_type_class (PARENT_TYPE); + + object_class->set_arg = gal_view_new_dialog_set_arg; + object_class->get_arg = gal_view_new_dialog_get_arg; + object_class->destroy = gal_view_new_dialog_destroy; + + gtk_object_add_arg_type ("GalViewNewDialog::name", GTK_TYPE_STRING, + GTK_ARG_READWRITE, ARG_NAME); +} + +#if 0 +#define SPEC "<ETableSpecification cursor-mode=\"line\" draw-grid=\"true\">" \ + "<ETableColumn model_col= \"0\" _tite=\"Name\" expansion=\"1.0\" minimum_width=\"18\" resizable=\"true\" cell=\"string\" compare=\"string\"/>" \ + "<ETableState> <column source=\"0\"/> <grouping> </grouping> </ETableState>" \ + "</ETableSpecification>" + +/* For use from libglade. */ +GtkWidget *gal_view_new_dialog_create_etable(char *name, char *string1, char *string2, int int1, int int2); + +GtkWidget * +gal_view_new_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); + return table; +} +#endif + +static void +gal_view_new_dialog_init (GalViewNewDialog *gal_view_new_dialog) +{ + GladeXML *gui; + GtkWidget *widget; + + gui = glade_xml_new (GAL_GLADEDIR "/gal-view-new-diallog.glade", NULL); + gal_view_new_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(gal_view_new_dialog)->vbox), widget, TRUE, TRUE, 0); + gtk_widget_unref(widget); + + gnome_dialog_append_buttons(GNOME_DIALOG(gal_view_new_dialog), + GNOME_STOCK_BUTTON_OK, + GNOME_STOCK_BUTTON_CANCEL, + NULL); + + gtk_window_set_policy(GTK_WINDOW(gal_view_new_dialog), FALSE, TRUE, FALSE); +} + +static void +gal_view_new_dialog_destroy (GtkObject *object) { + GalViewNewDialog *gal_view_new_dialog = GAL_VIEW_NEW_DIALOG(object); + + gtk_object_unref(GTK_OBJECT(gal_view_new_dialog->gui)); +} + +GtkWidget* +gal_view_new_dialog_new (void) +{ + GtkWidget *widget = GTK_WIDGET (gtk_type_new (gal_view_new_dialog_get_type ())); + return widget; +} + +static void +gal_view_new_dialog_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) +{ + GalViewNewDialog *dialog; + GtkWidget *entry; + + dialog = GAL_VIEW_NEW_DIALOG (o); + + switch (arg_id){ + case ARG_NAME: + entry = glade_xml_get_widget(dialog->gui, "entry-name"); + if (entry && GTK_IS_EDITABLE(entry)) { + e_utf8_gtk_editable_set_text(GTK_EDITABLE(entry), GTK_VALUE_STRING(*arg)); + } + break; + default: + return; + } +} + +static void +gal_view_new_dialog_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) +{ + GalViewNewDialog *dialog; + GtkWidget *entry; + + dialog = GAL_VIEW_NEW_DIALOG (object); + + switch (arg_id) { + case ARG_NAME: + entry = glade_xml_get_widget(dialog->gui, "entry-name"); + if (entry && GTK_IS_EDITABLE(entry)) { + GTK_VALUE_STRING(*arg) = e_utf8_gtk_editable_get_text(GTK_EDITABLE(entry)); + } + break; + default: + arg->type = GTK_TYPE_INVALID; + break; + } +} diff --git a/widgets/menus/gal-view-new-dialog.glade b/widgets/menus/gal-view-new-dialog.glade new file mode 100644 index 0000000000..aba8dc6b0f --- /dev/null +++ b/widgets/menus/gal-view-new-dialog.glade @@ -0,0 +1,148 @@ +<?xml version="1.0"?> +<GTK-Interface> + +<project> + <name>gal-view-new-dialog</name> + <program_name>gal-view-new-dialog</program_name> + <directory></directory> + <source_directory>src</source_directory> + <pixmaps_directory>pixmaps</pixmaps_directory> + <language>C</language> + <gnome_support>True</gnome_support> + <gettext_support>True</gettext_support> + <use_widget_names>True</use_widget_names> + <output_main_file>False</output_main_file> + <output_support_files>False</output_support_files> + <output_build_files>False</output_build_files> + <gnome_help_support>True</gnome_help_support> + <output_translatable_strings>True</output_translatable_strings> + <translatable_strings_file>gal-view-new-dialog.glade.h</translatable_strings_file> +</project> + +<widget> + <class>GnomeDialog</class> + <name>dialog1</name> + <visible>False</visible> + <type>GTK_WINDOW_TOPLEVEL</type> + <position>GTK_WIN_POS_NONE</position> + <modal>False</modal> + <allow_shrink>False</allow_shrink> + <allow_grow>True</allow_grow> + <auto_shrink>False</auto_shrink> + <auto_close>False</auto_close> + <hide_on_close>False</hide_on_close> + + <widget> + <class>GtkVBox</class> + <child_name>GnomeDialog:vbox</child_name> + <name>dialog-vbox1</name> + <homogeneous>False</homogeneous> + <spacing>8</spacing> + <child> + <padding>4</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkHButtonBox</class> + <child_name>GnomeDialog:action_area</child_name> + <name>dialog-action_area1</name> + <layout_style>GTK_BUTTONBOX_END</layout_style> + <spacing>8</spacing> + <child_min_width>85</child_min_width> + <child_min_height>27</child_min_height> + <child_ipad_x>7</child_ipad_x> + <child_ipad_y>0</child_ipad_y> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>True</fill> + <pack>GTK_PACK_END</pack> + </child> + + <widget> + <class>GtkButton</class> + <name>button1</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <stock_button>GNOME_STOCK_BUTTON_OK</stock_button> + </widget> + + <widget> + <class>GtkButton</class> + <name>button3</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button> + </widget> + </widget> + + <widget> + <class>GtkTable</class> + <name>table-top</name> + <rows>2</rows> + <columns>1</columns> + <homogeneous>False</homogeneous> + <row_spacing>6</row_spacing> + <column_spacing>6</column_spacing> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkLabel</class> + <name>label1</name> + <label>_Name of new view:</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + <child> + <left_attach>0</left_attach> + <right_attach>1</right_attach> + <top_attach>0</top_attach> + <bottom_attach>1</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GtkEntry</class> + <name>entry-name</name> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text></text> + <child> + <left_attach>0</left_attach> + <right_attach>1</right_attach> + <top_attach>1</top_attach> + <bottom_attach>2</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>True</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>True</yfill> + </child> + </widget> + </widget> + </widget> +</widget> + +</GTK-Interface> diff --git a/widgets/menus/gal-view-new-dialog.h b/widgets/menus/gal-view-new-dialog.h new file mode 100644 index 0000000000..79f04d06b4 --- /dev/null +++ b/widgets/menus/gal-view-new-dialog.h @@ -0,0 +1,70 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* gal-view-new-dialog.h + * Copyright (C) 2000 Helix Code, Inc. + * Author: Chris Lahey <clahey@helixcode.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ +#ifndef __GAL_VIEW_NEW_DIALOG_H__ +#define __GAL_VIEW_NEW_DIALOG_H__ + +#include <gnome.h> +#include <glade/glade.h> + +#ifdef __cplusplus +extern "C" { +#pragma } +#endif /* __cplusplus */ + +/* 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) (GTK_CHECK_CAST ((obj), GAL_VIEW_NEW_DIALOG_TYPE, GalViewNewDialog)) +#define GAL_VIEW_NEW_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GAL_VIEW_NEW_DIALOG_TYPE, GalViewNewDialogClass)) +#define GAL_IS_VIEW_NEW_DIALOG(obj) (GTK_CHECK_TYPE ((obj), GAL_VIEW_NEW_DIALOG_TYPE)) +#define GAL_IS_VIEW_NEW_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), GAL_VIEW_NEW_DIALOG_TYPE)) + +typedef struct _GalViewNewDialog GalViewNewDialog; +typedef struct _GalViewNewDialogClass GalViewNewDialogClass; + +struct _GalViewNewDialog +{ + GnomeDialog parent; + + /* item specific fields */ + GladeXML *gui; +}; + +struct _GalViewNewDialogClass +{ + GnomeDialogClass parent_class; +}; + +GtkWidget *gal_view_new_dialog_new (void); +GtkType gal_view_new_dialog_get_type (void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __GAL_VIEW_NEW_DIALOG_H__ */ diff --git a/widgets/menus/gal-view.c b/widgets/menus/gal-view.c new file mode 100644 index 0000000000..19c9d50f85 --- /dev/null +++ b/widgets/menus/gal-view.c @@ -0,0 +1,97 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * gal-view-menus.c: Savable state of a table. + * + * Author: + * Chris Lahey <clahey@helixcode.com> + * + * (C) 2000 Helix Code, Inc. + */ +#include <config.h> +#include <stdlib.h> +#include <gtk/gtksignal.h> +#include "gal-view.h" +#include <gal/util/e-util.h> + +static void gal_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); +static void gal_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); + +#define PARENT_TYPE (gtk_object_get_type()) + +static GtkObjectClass *gv_parent_class; + +enum { + ARG_0, + ARG_NAME, +}; + +static void +gv_destroy (GtkObject *object) +{ + GalView *gv = GAL_VIEW (object); + + g_free(gv->name); + + GTK_OBJECT_CLASS (gv_parent_class)->destroy (object); +} + +static void +gal_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) +{ + GalView *view; + + view = GAL_VIEW (o); + + switch (arg_id){ + case ARG_NAME: + g_free(view->name); + view->name = g_strdup(GTK_VALUE_STRING (*arg)); + break; + } +} + +static void +gal_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) +{ + GalView *view; + + view = GAL_VIEW (object); + + switch (arg_id) { + case ARG_NAME: + GTK_VALUE_STRING (*arg) = g_strdup(view->name); + break; + default: + arg->type = GTK_TYPE_INVALID; + break; + } +} + +static void +gv_init (GalView *view) +{ + view->name = NULL; +} + +static void +gv_class_init (GtkObjectClass *klass) +{ + gv_parent_class = gtk_type_class (PARENT_TYPE); + + klass->destroy = gv_destroy; + klass->set_arg = gal_view_set_arg; + klass->get_arg = gal_view_get_arg; + + gtk_object_add_arg_type ("GalView::name", GTK_TYPE_STRING, + GTK_ARG_READWRITE, ARG_NAME); +} + +E_MAKE_TYPE(gal_view, "GalView", GalView, gv_class_init, gv_init, PARENT_TYPE); + +GalView * +gal_view_new (void) +{ + GalView *gv = gtk_type_new (GAL_VIEW_TYPE); + + return (GalView *) gv; +} diff --git a/widgets/menus/gal-view.h b/widgets/menus/gal-view.h new file mode 100644 index 0000000000..0e1a49e1ca --- /dev/null +++ b/widgets/menus/gal-view.h @@ -0,0 +1,27 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +#ifndef _GAL_VIEW_H_ +#define _GAL_VIEW_H_ + +#include <gtk/gtkobject.h> +#include <gnome-xml/tree.h> +#include <bonobo/bonobo-ui-component.h> + +#define GAL_VIEW_TYPE (gal_view_get_type ()) +#define GAL_VIEW(o) (GTK_CHECK_CAST ((o), GAL_VIEW_TYPE, GalView)) +#define GAL_VIEW_CLASS(k) (GTK_CHECK_CLASS_CAST((k), GAL_VIEW_TYPE, GalViewClass)) +#define GAL_IS_VIEW(o) (GTK_CHECK_TYPE ((o), GAL_VIEW_TYPE)) +#define GAL_IS_VIEW_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), GAL_VIEW_TYPE)) + +typedef struct { + GtkObject base; + char *name; +} GalView; + +typedef struct { + GtkObjectClass parent_class; +} GalViewClass; + +GtkType gal_view_get_type (void); +GalView *gal_view_new (void); + +#endif /* _GAL_VIEW_H_ */ |