X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-dialog-action.c;h=a97421f7ea0bbfeddb40f307ae7ea118df76381e;hb=fc6620099bbc53762095569d5356b67a81a85402;hp=e2b15e03eba76085b90d9c5756ba8f6a493bf6b4;hpb=7466f9c7baaf5a5d4cc7b670be290395ccb20b65;p=pspp diff --git a/src/ui/gui/psppire-dialog-action.c b/src/ui/gui/psppire-dialog-action.c index e2b15e03eb..a97421f7ea 100644 --- a/src/ui/gui/psppire-dialog-action.c +++ b/src/ui/gui/psppire-dialog-action.c @@ -84,31 +84,74 @@ psppire_dialog_action_get_property (GObject *object, static void -psppire_dialog_action_activate (PsppireDialogAction *act) +set_toplevel (PsppireDialogAction *act) { - gint response; - - PsppireVarStore *vs; - PsppireDialogActionClass *class = PSPPIRE_DIALOG_ACTION_GET_CLASS (act); + if (act->toplevel) + return; GSList *sl = gtk_ui_manager_get_toplevels (act->uim, GTK_UI_MANAGER_MENUBAR | GTK_UI_MANAGER_TOOLBAR); g_return_if_fail (sl); - + act->toplevel = gtk_widget_get_toplevel (GTK_WIDGET (sl->data)); g_slist_free (sl); +} - vs = PSPPIRE_DATA_WINDOW(act->toplevel)->var_store; +static void +on_destroy_dataset (GObject *w) +{ + GHashTable *t = g_object_get_data (w, "thing-table"); + GSList *dl = g_object_get_data (w, "widget-list"); - g_object_get (vs, "dictionary", &act->dict, NULL); + g_slist_free_full (dl, (GDestroyNotify) gtk_widget_destroy); + g_hash_table_unref (t); +} + +GHashTable * +psppire_dialog_action_get_pointer (PsppireDialogAction *act) +{ + set_toplevel (act); - g_object_set (act->source, "model", act->dict, NULL); + GHashTable *thing = g_object_get_data (G_OBJECT (act->toplevel), "thing-table"); + if (thing == NULL) + { + thing = g_hash_table_new_full (g_direct_hash, g_direct_equal, 0, g_object_unref); + g_object_set_data (G_OBJECT (act->toplevel), "thing-table", thing); + g_object_set_data (G_OBJECT (act->toplevel), "widget-list", NULL); + g_signal_connect (act->toplevel, "destroy", G_CALLBACK (on_destroy_dataset), NULL); + } + + return thing; +} + +static void +psppire_dialog_action_activate (PsppireDialogAction *act) +{ + gint response; + + PsppireDialogActionClass *class = PSPPIRE_DIALOG_ACTION_GET_CLASS (act); + + gboolean first_time = ! act->toplevel; + + set_toplevel (act); + + act->dict = PSPPIRE_DATA_WINDOW(act->toplevel)->dict; - gtk_window_set_transient_for (GTK_WINDOW (act->dialog), GTK_WINDOW (act->toplevel)); + g_object_set (act->source, "model", act->dict, NULL); + + GSList *wl = g_object_get_data (G_OBJECT (act->toplevel), "widget-list"); + wl = g_slist_prepend (wl, act->dialog); + g_object_set_data (G_OBJECT (act->toplevel), "widget-list", wl); + gtk_window_set_transient_for (GTK_WINDOW (act->dialog), GTK_WINDOW (act->toplevel)); if (GTK_ACTION_CLASS (psppire_dialog_action_parent_class)->activate) GTK_ACTION_CLASS (psppire_dialog_action_parent_class)->activate ( GTK_ACTION (act)); + gtk_widget_grab_focus (act->source); + + if (first_time) + psppire_dialog_reload (PSPPIRE_DIALOG (act->dialog)); + response = psppire_dialog_run (PSPPIRE_DIALOG (act->dialog)); if ( class->generate_syntax ) @@ -138,7 +181,7 @@ psppire_dialog_action_class_init (PsppireDialogActionClass *class) "Manager", "The GtkUIManager which created this object", GTK_TYPE_UI_MANAGER, - G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE); + G_PARAM_READWRITE); GParamSpec *toplevel_spec = g_param_spec_object ("top-level", @@ -187,3 +230,10 @@ psppire_dialog_action_set_refresh (PsppireDialogAction *pda, g_signal_connect_swapped (pda->dialog, "refresh", G_CALLBACK (refresh), pda); } + +void +psppire_dialog_action_set_activation (gpointer class, activation activate) +{ + GTK_ACTION_CLASS (class)->activate = activate; +} +