[gnumeric] Solver: most merge run dialog and solver dialog.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Solver: most merge run dialog and solver dialog.
- Date: Sat, 2 May 2015 17:16:43 +0000 (UTC)
commit 6634237fbf8e13890a81a02f7b267e162787c13c
Author: Morten Welinder <terra gnome org>
Date: Sat May 2 13:15:42 2015 -0400
Solver: most merge run dialog and solver dialog.
This way there is only one dialog to dismiss when done.
src/dialogs/ChangeLog | 5 +
src/dialogs/dialog-solver.c | 86 +++++-----------
src/dialogs/solver.ui | 235 ++++++++++++++++++++++++++++++------------
3 files changed, 197 insertions(+), 129 deletions(-)
---
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index 8320c38..1fd822e 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,8 @@
+2015-05-02 Morten Welinder <terra gnome org>
+
+ * dialog-solver.c (run_solver): Move everything except the stop
+ button from the run dialog to the main dialog.
+
2015-04-16 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-analysis-tools.c (dialog_histogram_tool): set defaults
diff --git a/src/dialogs/dialog-solver.c b/src/dialogs/dialog-solver.c
index a1485f7..2983abf 100644
--- a/src/dialogs/dialog-solver.c
+++ b/src/dialogs/dialog-solver.c
@@ -58,6 +58,7 @@
typedef struct {
GtkBuilder *gui;
GtkWidget *dialog;
+ GtkWidget *notebook;
GnmExprEntry *target_entry;
GnmExprEntry *change_cell_entry;
GtkWidget *max_iter_entry;
@@ -87,7 +88,6 @@ typedef struct {
GtkWidget *problem_status_widget;
GtkWidget *objective_value_widget;
GtkWidget *stop_button;
- GtkWidget *ok_button;
gulong sig_notify_result;
gulong sig_notify_status;
gulong sig_notify_reason;
@@ -507,7 +507,6 @@ cb_notify_status (SolverState *state)
GnmSolver *sol = state->run.solver;
const char *text;
gboolean finished = gnm_solver_finished (sol);
- gboolean ok_ok = finished;
switch (sol->status) {
case GNM_SOLVER_STATUS_READY:
@@ -521,12 +520,6 @@ cb_notify_status (SolverState *state)
break;
case GNM_SOLVER_STATUS_RUNNING:
text = _("Running");
- if (sol->result) {
- GnmSolverResultQuality q = sol->result->quality;
- if (q == GNM_SOLVER_RESULT_FEASIBLE ||
- q == GNM_SOLVER_RESULT_OPTIMAL)
- ok_ok = TRUE;
- }
break;
case GNM_SOLVER_STATUS_DONE:
text = _("Done");
@@ -556,10 +549,8 @@ cb_notify_status (SolverState *state)
g_source_remove (state->run.timer_source);
state->run.timer_source = 0;
}
+ gtk_widget_destroy (GTK_WIDGET (state->run.dialog));
}
-
- gtk_widget_set_sensitive (state->run.stop_button, !finished);
- gtk_widget_set_sensitive (state->run.ok_button, ok_ok);
}
static void
@@ -643,7 +634,6 @@ static GnmSolverResult *
run_solver (SolverState *state, GnmSolverParameters *param)
{
GtkDialog *dialog;
- GtkWidget *grid;
int dialog_res;
GError *err = NULL;
gboolean ok;
@@ -653,7 +643,7 @@ run_solver (SolverState *state, GnmSolverParameters *param)
GnmValue const *vinput;
GtkWindow *top = GTK_WINDOW (gtk_widget_get_toplevel (state->dialog));
GnmSolverResult *res = NULL;
- int y;
+ char *txt;
sol = gnm_solver_factory_functional (param->options.algorithm,
state->wbcg)
@@ -665,6 +655,8 @@ run_solver (SolverState *state, GnmSolverParameters *param)
goto fail;
}
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (state->notebook), -1);
+
state->run.solver = sol;
vinput = gnm_solver_param_get_input (param);
@@ -676,6 +668,17 @@ run_solver (SolverState *state, GnmSolverParameters *param)
(_("Running Solver"),
wbcg_toplevel (state->wbcg), 0,
NULL, NULL);
+
+ /*
+ * Toss a label in there -- not because we have something to say,
+ * but because the title otherwise gets truncated.
+ */
+ txt = g_strdup_printf (_("Solver \"%s\" is running"),
+ param->options.algorithm->name);
+ gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (dialog)),
+ gtk_label_new (txt));
+ g_free (txt);
+
state->run.stop_button =
go_gtk_dialog_add_button (dialog,
_("Stop"),
@@ -688,50 +691,6 @@ run_solver (SolverState *state, GnmSolverParameters *param)
"clicked", G_CALLBACK (cb_stop_solver),
state);
- state->run.ok_button =
- go_gtk_dialog_add_button (dialog,
- GNM_STOCK_OK,
- GTK_STOCK_OK,
- GTK_RESPONSE_YES);
-
- grid = gtk_grid_new ();
- g_object_set (grid,
- "column-spacing", 12,
- "row-spacing", 6,
- "border-width", 6,
- NULL);
- for (y = 0; y < 4; y++) {
- static const char *ltxt[4] = {
- N_("Solver Status:"),
- N_("Problem Status:"),
- N_("Objective Value:"),
- N_("Elapsed Time:")
- };
- GtkWidget *w;
-
- w = gtk_label_new (_(ltxt[y]));
- g_object_set (w,
- "halign", GTK_ALIGN_END,
- "valign", GTK_ALIGN_CENTER,
- NULL);
- gtk_grid_attach (GTK_GRID (grid), w, 0, y, 1, 1);
- w = gtk_label_new ("");
- gtk_widget_set_size_request
- (w,
- gnm_widget_measure_string (w, "0") * (10 + GNM_DIG),
- -1);
- gtk_grid_attach (GTK_GRID (grid), w, 1, y, 1, 1);
- switch (y) {
- case 0: state->run.status_widget = w; break;
- case 1: state->run.problem_status_widget = w; break;
- case 2: state->run.objective_value_widget = w; break;
- case 3: state->run.timer_widget = w; break;
- default: g_assert_not_reached ();
- }
- }
-
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (dialog)),
- grid, TRUE, TRUE, 0);
gtk_widget_show_all (GTK_WIDGET (dialog));
state->run.sig_notify_status =
@@ -754,8 +713,6 @@ run_solver (SolverState *state, GnmSolverParameters *param)
cb_notify_result (state);
state->run.dialog = g_object_ref (dialog);
- g_object_ref (state->run.timer_widget);
- g_object_ref (state->run.status_widget);
state->run.timer_source = g_timeout_add_seconds
(1, (GSourceFunc)cb_timer_tick, state);
cb_timer_tick (state);
@@ -793,8 +750,6 @@ run_solver (SolverState *state, GnmSolverParameters *param)
g_source_remove (state->run.timer_source);
state->run.timer_source = 0;
}
- g_object_unref (state->run.status_widget);
- g_object_unref (state->run.timer_widget);
g_object_unref (state->run.dialog);
switch (dialog_res) {
@@ -982,6 +937,8 @@ dialog_init (SolverState *state)
if (state->dialog == NULL)
return TRUE;
+ state->notebook = go_gtk_builder_get_widget (state->gui, "solver_notebook");
+
/* buttons */
state->solve_button = go_gtk_builder_get_widget (state->gui, "solvebutton");
g_signal_connect (G_OBJECT (state->solve_button), "clicked",
@@ -1213,6 +1170,11 @@ dialog_init (SolverState *state)
gtk_entry_set_text (GTK_ENTRY (state->scenario_name_entry),
param->options.scenario_name);
+ state->run.status_widget = go_gtk_builder_get_widget (state->gui, "solver_status_label");
+ state->run.problem_status_widget = go_gtk_builder_get_widget (state->gui, "problem_status_label");
+ state->run.objective_value_widget = go_gtk_builder_get_widget (state->gui, "objective_value_label");
+ state->run.timer_widget = go_gtk_builder_get_widget (state->gui, "elapsed_time_label");
+
/* Done */
gnm_expr_entry_grab_focus (state->target_entry, FALSE);
wbcg_set_entry (state->wbcg, state->target_entry);
@@ -1295,7 +1257,7 @@ dialog_solver (WBCGtk *wbcg, Sheet *sheet)
GNM_DIALOG_DESTROY_SHEET_REMOVED);
gnm_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog),
- SOLVER_KEY);
+ SOLVER_KEY);
gtk_widget_show (state->dialog);
}
diff --git a/src/dialogs/solver.ui b/src/dialogs/solver.ui
index b0b82ce..bcdba05 100644
--- a/src/dialogs/solver.ui
+++ b/src/dialogs/solver.ui
@@ -1,6 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.16.1 -->
<interface>
- <!-- interface-requires gtk+ 3.0 -->
+ <requires lib="gtk+" version="3.8"/>
+ <object class="GtkAdjustment" id="adjustment1">
+ <property name="lower">1</property>
+ <property name="upper">36000</property>
+ <property name="value">30</property>
+ <property name="step_increment">10</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment2">
+ <property name="lower">1</property>
+ <property name="upper">10000000000</property>
+ <property name="value">100</property>
+ <property name="step_increment">10</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkListStore" id="model1">
+ <columns>
+ <!-- column-name gchararray -->
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0" translatable="yes">≤</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">≥</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">=</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Int</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Bool</col>
+ </row>
+ </data>
+ </object>
<object class="GtkDialog" id="Solver">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Solver</property>
@@ -24,7 +62,6 @@
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
@@ -41,7 +78,6 @@
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
@@ -59,7 +95,6 @@
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
</object>
<packing>
@@ -77,7 +112,7 @@
</packing>
</child>
<child>
- <object class="GtkNotebook" id="notebook1">
+ <object class="GtkNotebook" id="solver_notebook">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="border_width">10</property>
@@ -140,7 +175,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="active">True</property>
@@ -160,7 +194,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
@@ -212,7 +245,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
@@ -232,7 +264,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="active">True</property>
@@ -252,7 +283,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
@@ -284,7 +314,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="active">True</property>
@@ -304,7 +333,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
@@ -466,7 +494,6 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="valign">end</property>
- <property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
@@ -483,7 +510,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
<property name="relief">half</property>
<property name="use_stock">True</property>
</object>
@@ -501,7 +527,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
</object>
<packing>
@@ -586,7 +611,6 @@
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="invisible_char">●</property>
- <property name="invisible_char_set">True</property>
<property name="adjustment">adjustment2</property>
<property name="climb_rate">1</property>
</object>
@@ -602,7 +626,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
- <property name="invisible_char_set">True</property>
<property name="adjustment">adjustment1</property>
<property name="climb_rate">1</property>
</object>
@@ -620,7 +643,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
@@ -632,15 +654,6 @@
<property name="height">1</property>
</packing>
</child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
</object>
<packing>
<property name="position">3</property>
@@ -677,7 +690,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
@@ -726,7 +738,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
@@ -744,7 +755,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
@@ -811,6 +821,134 @@
<property name="tab_fill">False</property>
</packing>
</child>
+ <child>
+ <object class="GtkGrid" id="grid1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">center</property>
+ <property name="border_width">6</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Solver Status:</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Problem Status:</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Objective Value:</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Elapsed Time:</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="solver_status_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="problem_status_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="objective_value_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="elapsed_time_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">6</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Results</property>
+ </object>
+ <packing>
+ <property name="position">6</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -826,41 +964,4 @@
<action-widget response="0">solvebutton</action-widget>
</action-widgets>
</object>
- <object class="GtkAdjustment" id="adjustment1">
- <property name="lower">1</property>
- <property name="upper">36000</property>
- <property name="value">30</property>
- <property name="step_increment">10</property>
- <property name="page_increment">10</property>
- </object>
- <object class="GtkAdjustment" id="adjustment2">
- <property name="lower">1</property>
- <property name="upper">10000000000</property>
- <property name="value">100</property>
- <property name="step_increment">10</property>
- <property name="page_increment">10</property>
- </object>
- <object class="GtkListStore" id="model1">
- <columns>
- <!-- column-name gchararray -->
- <column type="gchararray"/>
- </columns>
- <data>
- <row>
- <col id="0" translatable="yes">≤</col>
- </row>
- <row>
- <col id="0" translatable="yes">≥</col>
- </row>
- <row>
- <col id="0" translatable="yes">=</col>
- </row>
- <row>
- <col id="0" translatable="yes">Int</col>
- </row>
- <row>
- <col id="0" translatable="yes">Bool</col>
- </row>
- </data>
- </object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]