diff options
-rw-r--r-- | widgets/menus/gal-view-instance-save-as-dialog.c | 4 | ||||
-rw-r--r-- | widgets/menus/gal-view-new-dialog.c | 106 | ||||
-rw-r--r-- | widgets/menus/gal-view-new-dialog.glade | 344 | ||||
-rw-r--r-- | widgets/menus/gal-view-new-dialog.h | 6 |
4 files changed, 252 insertions, 208 deletions
diff --git a/widgets/menus/gal-view-instance-save-as-dialog.c b/widgets/menus/gal-view-instance-save-as-dialog.c index 11099f0b1c..ee61fe8edb 100644 --- a/widgets/menus/gal-view-instance-save-as-dialog.c +++ b/widgets/menus/gal-view-instance-save-as-dialog.c @@ -214,7 +214,7 @@ gal_view_instance_save_as_dialog_init (GalViewInstanceSaveAsDialog *dialog) dialog->model = NULL; etable = glade_xml_get_widget(dialog->gui, "custom-replace"); if (etable) { - dialog->model = g_object_get_data(etable, "GalViewInstanceSaveAsDialog::model"); + dialog->model = g_object_get_data(G_OBJECT (etable), "GalViewInstanceSaveAsDialog::model"); g_object_set(dialog->model, "collection", dialog->instance ? dialog->instance->collection : NULL, NULL); @@ -241,7 +241,7 @@ gal_view_instance_save_as_dialog_create_etable(char *name, char *string1, char * ETableModel *model; model = gal_define_views_model_new(); table = e_table_scrolled_new(model, NULL, SPEC, NULL); - g_object_set_data(table, "GalViewInstanceSaveAsDialog::model", model); + g_object_set_data(G_OBJECT (table), "GalViewInstanceSaveAsDialog::model", model); return table; } diff --git a/widgets/menus/gal-view-new-dialog.c b/widgets/menus/gal-view-new-dialog.c index 2677f2a415..52342ce773 100644 --- a/widgets/menus/gal-view-new-dialog.c +++ b/widgets/menus/gal-view-new-dialog.c @@ -24,6 +24,7 @@ #include <config.h> #include <libgnomeui/gnome-dialog.h> #include <gtk/gtk.h> +#include <gtk/gtktreeselection.h> #include "gal-view-new-dialog.h" #include "gal-define-views-model.h" #include <gal/widgets/e-unicode.h> @@ -65,7 +66,7 @@ gal_view_new_dialog_class_init (GalViewNewDialogClass *klass) 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_FACTORY, + g_object_class_install_property (object_class, PROP_NAME, g_param_spec_string ("name", _("Name"), /*_( */"XXX blurb" /*)*/, @@ -131,44 +132,107 @@ gal_view_new_dialog_new (GalViewCollection *collection) return widget; } +static void +sensitize_ok_response (GalViewNewDialog *dialog) +{ + gboolean ok = TRUE; + const char *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; + + gtk_tree_model_get_iter (GTK_TREE_MODEL (dialog->list_store), + &iter, + (GtkTreePath*)path); + + gtk_tree_model_get (GTK_TREE_MODEL (dialog->list_store), + &iter, + 1, &dialog->selected_factory, + -1); + + printf ("%s factory selected\n", gal_view_factory_get_title(dialog->selected_factory)); + + sensitize_ok_response (dialog); + + return TRUE; +} static void -gal_view_new_dialog_select_row_callback(GtkCList *list, - gint row, - gint column, - GdkEventButton *event, - GalViewNewDialog *dialog) +entry_changed (GtkWidget *entry, gpointer data) { - dialog->selected_factory = gtk_clist_get_row_data(list, - row); + GalViewNewDialog *dialog = data; + + sensitize_ok_response (dialog); } GtkWidget* gal_view_new_dialog_construct (GalViewNewDialog *dialog, GalViewCollection *collection) { - GtkWidget *list = glade_xml_get_widget(dialog->gui, - "clist-type-list"); GList *iterator; + GtkTreeSelection *selection; + GtkTreeViewColumn *column; + GtkCellRenderer *rend; + dialog->collection = collection; + dialog->list = glade_xml_get_widget(dialog->gui,"list-type-list"); + dialog->entry = glade_xml_get_widget(dialog->gui, "entry-name"); + dialog->list_store = gtk_list_store_new (2, + G_TYPE_STRING, + G_TYPE_POINTER); - iterator = dialog->collection->factory_list; + 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; - char *text[1]; - int row; + GtkTreeIter iter; g_object_ref(factory); - text[0] = (char *) gal_view_factory_get_title(factory); - row = gtk_clist_append(GTK_CLIST(list), text); - gtk_clist_set_row_data(GTK_CLIST(list), row, 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); } - g_signal_connect(list, - "select_row", - G_CALLBACK(gal_view_new_dialog_select_row_callback), - dialog); + 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); } @@ -183,7 +247,7 @@ gal_view_new_dialog_set_property (GObject *object, guint prop_id, const GValue * switch (prop_id){ case PROP_NAME: - entry = glade_xml_get_widget(dialog->gui, "entry-name"); + if (entry && GTK_IS_ENTRY(entry)) { gtk_entry_set_text(GTK_ENTRY(entry), g_value_get_string (value)); } diff --git a/widgets/menus/gal-view-new-dialog.glade b/widgets/menus/gal-view-new-dialog.glade index eac107fc00..70922f5dc5 100644 --- a/widgets/menus/gal-view-new-dialog.glade +++ b/widgets/menus/gal-view-new-dialog.glade @@ -1,201 +1,175 @@ <?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd" > +<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> <glade-interface> - <widget class="GtkDialog" id="dialog1"> - <property name="visible">no</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="modal">no</property> - <property name="allow_shrink">no</property> - <property name="allow_grow">yes</property> - <property name="window-position">GTK_WIN_POS_NONE</property> - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox1"> - <property name="homogeneous">no</property> - <property name="spacing">8</property> - <property name="visible">yes</property> +<widget class="GtkDialog" id="dialog1"> + <property name="title" translatable="yes"></property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="has_separator">True</property> - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area1"> - <property name="layout_style">GTK_BUTTONBOX_END</property> - <property name="spacing">8</property> - <property name="visible">yes</property> + <child internal-child="vbox"> + <widget class="GtkVBox" id="dialog-vbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">8</property> - <child> - <widget class="GtkButton" id="button1"> - <property name="can_default">yes</property> - <property name="can_focus">yes</property> - <property name="visible">yes</property> - <property name="label">gtk-ok</property> - <property name="use_stock">yes</property> - <property name="use_underline">yes</property> - </widget> - </child> + <child internal-child="action_area"> + <widget class="GtkHButtonBox" id="dialog-action_area1"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> - <child> - <widget class="GtkButton" id="button3"> - <property name="can_default">yes</property> - <property name="can_focus">yes</property> - <property name="visible">yes</property> - <property name="label">gtk-cancel</property> - <property name="use_stock">yes</property> - <property name="use_underline">yes</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">yes</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> + <child> + <widget class="GtkButton" id="button1"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-ok</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="response_id">0</property> + </widget> + </child> - <child> - <widget class="GtkTable" id="table-top"> - <property name="homogeneous">no</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - <property name="n-rows">4</property> - <property name="n-columns">1</property> - <property name="visible">yes</property> + <child> + <widget class="GtkButton" id="button3"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-cancel</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="response_id">0</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">GTK_PACK_END</property> + </packing> + </child> - <child> - <widget class="GtkLabel" id="label1"> - <property name="label" translatable="yes">Name of new view:</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">no</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">entry-name</property> - <property name="visible">yes</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_padding">0</property> - <property name="y_padding">0</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> + <child> + <widget class="GtkTable" id="table-top"> + <property name="visible">True</property> + <property name="n_rows">4</property> + <property name="n_columns">1</property> + <property name="homogeneous">False</property> + <property name="row_spacing">6</property> + <property name="column_spacing">6</property> - <child> - <widget class="GtkEntry" id="entry-name"> - <property name="can_focus">yes</property> - <property name="editable">yes</property> - <property name="text" translatable="yes"></property> - <property name="max-length">0</property> - <property name="visibility">yes</property> - <property name="visible">yes</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_padding">0</property> - <property name="y_padding">0</property> - <property name="x_options">expand|fill</property> - <property name="y_options">fill</property> - </packing> - </child> + <child> + <widget class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Name of new view:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_CENTER</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="mnemonic_widget">entry-name</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> - <child> - <widget class="GtkLabel" id="label2"> - <property name="label" translatable="yes">Type of view:</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">no</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="visible">yes</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_padding">0</property> - <property name="y_padding">0</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> + <child> + <widget class="GtkEntry" id="entry-name"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char" translatable="yes">*</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="y_options">fill</property> + </packing> + </child> - <child> - <widget class="GtkScrolledWindow" id="scrolledwindow1"> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <property name="visible">yes</property> + <child> + <widget class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="label" translatable="yes">Type of view:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_CENTER</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> - <child> - <widget class="GtkTreeView" id="clist-type-list"> - <property name="can_focus">yes</property> - <property name="headers-visible">no</property> - <property name="visible">yes</property> + <child> + <widget class="GtkScrolledWindow" id="scrolledwindow1"> + <property name="visible">True</property> + <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="shadow_type">GTK_SHADOW_IN</property> + <property name="window_placement">GTK_CORNER_TOP_LEFT</property> - <child> - <widget class="GtkLabel" id="label5"> - <property name="child_name">CList:title</property> - <property name="label" translatable="yes">label5</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">no</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="visible">yes</property> - </widget> - </child> - </widget> - </child> + <child> + <widget class="GtkTreeView" id="list-type-list"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="headers_visible">False</property> + <property name="rules_hint">False</property> + <property name="reorderable">False</property> + <property name="enable_search">True</property> + </widget> + </child> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_options">fill</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> +</widget> - <child internal-child="hscrollbar"> - <widget class="GtkHScrollbar" id="convertwidget1"> - <property name="update_policy">GTK_UPDATE_CONTINUOUS</property> - <property name="visible">yes</property> - </widget> - </child> - - <child internal-child="vscrollbar"> - <widget class="GtkVScrollbar" id="convertwidget2"> - <property name="update_policy">GTK_UPDATE_CONTINUOUS</property> - <property name="visible">yes</property> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_padding">0</property> - <property name="y_padding">0</property> - <property name="x_options">fill</property> - <property name="y_options">expand|fill</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">4</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - </widget> </glade-interface> diff --git a/widgets/menus/gal-view-new-dialog.h b/widgets/menus/gal-view-new-dialog.h index d7d7912ea2..cd523a2476 100644 --- a/widgets/menus/gal-view-new-dialog.h +++ b/widgets/menus/gal-view-new-dialog.h @@ -25,6 +25,7 @@ #define __GAL_VIEW_NEW_DIALOG_H__ #include <gtk/gtkdialog.h> +#include <gtk/gtkliststore.h> #include <glade/glade.h> #include <gal-view-collection.h> @@ -59,6 +60,11 @@ struct _GalViewNewDialog GalViewCollection *collection; GalViewFactory *selected_factory; + + GtkListStore *list_store; + + GtkWidget *entry; + GtkWidget *list; }; struct _GalViewNewDialogClass |