[mlview-list][mlview-app-refactoring] dialog for open view selection
- From: Stephane Bonhomme <s bonhomme wanadoo fr>
- To: mlview-list gnome org
- Subject: [mlview-list][mlview-app-refactoring] dialog for open view selection
- Date: Tue, 10 Feb 2004 00:22:18 +0100
Hi,
This patch adds a dialog window when activating the Open New view entry
of the Action Menu, Displaying and letting the user choose between the
avaiable types of views.
CAUTION : this patchs applies only to the mlview-app-refactoring CVS
branch
Sincerly,
Stephane.
--
Stéphane Bonhomme - Formations, Conseil et Réalisations
Ingénierie Documentaire - Technologies Web - Logiciels Libres
s bonhomme wanadoo fr - http://perso.wanadoo.fr/s.bonhomme
04 76 17 09 40 / 06 88 57 27 08
? Doxyfile
? diff.txt
? mlview.desktop
? schemas/Makefile
? schemas/Makefile.in
? src/mlv
Index: src/mlview-editor.c
===================================================================
RCS file: /cvs/gnome/mlview/src/mlview-editor.c,v
retrieving revision 1.70.4.8
diff -a -u -r1.70.4.8 mlview-editor.c
--- src/mlview-editor.c 4 Feb 2004 00:10:53 -0000 1.70.4.8
+++ src/mlview-editor.c 9 Feb 2004 23:09:05 -0000
@@ -498,6 +498,93 @@
*a_list = g_list_append (*a_list, a_key);
}
+static struct MlViewViewDesc *
+mlview_editor_sel_view_to_open ()
+{
+ GtkWidget *dialog;
+ GtkWidget *dialog_vbox;
+ GtkWidget *hbox1;
+ GtkWidget *label1;
+ GtkWidget *option_menu;
+ GtkWidget *menu;
+ GtkWidget *menu_item;
+ GtkWidget *dialog_action_area1;
+ GtkWidget *button5;
+ GtkWidget *button6;
+ GtkWidget *sel_menu_item;
+
+ enum MLVIEW_SELECTED_BUTTON button;
+ struct MlViewViewDesc *result = NULL;
+ struct MlViewViewDesc *view_desc_ptr = NULL ;
+ gchar *base_name;
+
+ dialog = gtk_dialog_new ();
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Select View"));
+
+ dialog_vbox = GTK_DIALOG (dialog)->vbox;
+ gtk_widget_show (dialog_vbox);
+
+ hbox1 = gtk_hbox_new (FALSE, 0);
+ gtk_widget_show (hbox1);
+ gtk_box_pack_start (GTK_BOX (dialog_vbox), hbox1, TRUE, TRUE, 0);
+ label1 = gtk_label_new (_("Select view to open"));
+ gtk_widget_show (label1);
+ gtk_box_pack_start (GTK_BOX (hbox1), label1, FALSE, FALSE, 10);
+
+ /* build select view menu */
+ option_menu = gtk_option_menu_new();
+ menu = gtk_menu_new();
+ gtk_option_menu_set_menu (GTK_OPTION_MENU(option_menu), menu);
+
+ gtk_widget_show (menu);
+ gtk_widget_show (option_menu);
+
+ gtk_box_pack_start (GTK_BOX (hbox1), option_menu, TRUE, TRUE, 0);
+ for (view_desc_ptr = gv_view_types;
+ view_desc_ptr && view_desc_ptr->view_type_name;
+ view_desc_ptr ++) {
+ base_name = view_desc_ptr->view_type_name;
+ menu_item = gtk_menu_item_new_with_label(base_name);
+ gtk_menu_shell_append (GTK_MENU_SHELL(menu), menu_item);
+ gtk_widget_show(menu_item);
+ g_object_set_data (G_OBJECT(menu_item), "mlview_view_desc", (gpointer)view_desc_ptr);
+ }
+ gtk_option_menu_set_history(GTK_OPTION_MENU(option_menu), 0);
+
+ /* dialog box buttons */
+ dialog_action_area1 = GTK_DIALOG (dialog)->action_area;
+ gtk_widget_show (dialog_action_area1);
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
+
+ button5 = gtk_button_new_from_stock ("gtk-cancel");
+ gtk_widget_show (button5);
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button5, GTK_RESPONSE_CANCEL);
+ GTK_WIDGET_SET_FLAGS (button5, GTK_CAN_DEFAULT);
+
+ button6 = gtk_button_new_from_stock ("gtk-ok");
+ gtk_widget_show (button6);
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button6, GTK_RESPONSE_OK);
+ GTK_WIDGET_SET_FLAGS (button6, GTK_CAN_DEFAULT);
+
+ /* show dialog */
+ button = gtk_dialog_run (GTK_DIALOG (dialog));
+
+
+ switch (button) {
+ case GTK_RESPONSE_OK:
+ sel_menu_item = gtk_menu_get_active(GTK_MENU(menu));
+
+ result = (struct MlViewViewDesc *)g_object_get_data (G_OBJECT(sel_menu_item), "mlview_view_desc");
+ break;
+
+ default:
+ return NULL ;
+ break;
+ }
+ gtk_widget_destroy (dialog);
+ return result;
+}
+
/*=================================================
*public methods
*=================================================*/
@@ -781,7 +868,7 @@
MlViewIView *result = NULL;
struct MlViewAppSettings *settings = NULL ;
struct MlViewViewDesc *view_descriptor = NULL ;
-
+
g_return_val_if_fail (a_this != NULL, NULL);
g_return_val_if_fail (MLVIEW_IS_EDITOR (a_this), NULL);
g_return_val_if_fail (PRIVATE (a_this) != NULL, NULL);
@@ -797,6 +884,9 @@
view_descriptor = mlview_editor_peek_editing_view_descriptor
(settings->general.default_editing_view_type) ;
+
+ view_descriptor = mlview_editor_sel_view_to_open ();
+
if (!view_descriptor
|| !view_descriptor->view_constructor) {
mlview_utils_trace_info
@@ -804,11 +894,12 @@
mlview_utils_trace_info (settings->general.default_editing_view_type) ;
return NULL ;
}
- result = MLVIEW_IVIEW (view_descriptor->view_constructor
- (a_xml_doc, NULL,
+ result = MLVIEW_IVIEW (view_descriptor->view_constructor
+ (a_xml_doc, NULL,
PRIVATE (a_this)->app_context)) ;
mlview_editor_add_xml_document_view (a_this, result) ;
- return result;
+ return result;
+
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]