summaryrefslogtreecommitdiff
path: root/mate-panel/panel-run-dialog.c
diff options
context:
space:
mode:
authorMoritz Bruder <[email protected]>2017-04-18 04:52:36 +0200
committerMoritz Bruder <[email protected]>2017-04-18 22:47:15 +0200
commit3171e41dcd4e0eea310acdb9c1d18c3a3adbd5fa (patch)
treef5807a95e22cdb1d9c95bb0b69a32f825ca5130d /mate-panel/panel-run-dialog.c
parent5661e088e300173c64331c5350710b69774b4a99 (diff)
downloadmate-panel-3171e41dcd4e0eea310acdb9c1d18c3a3adbd5fa.tar.bz2
mate-panel-3171e41dcd4e0eea310acdb9c1d18c3a3adbd5fa.tar.xz
Run dialog: Fix wrong history len with max size 1
In a special case where the history size was 1, the actual history saved had length 2. In addition history is always written with new entries. One could also connect a signal to the max size property to force writing history (i.e., to shorten it).
Diffstat (limited to 'mate-panel/panel-run-dialog.c')
-rw-r--r--mate-panel/panel-run-dialog.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/mate-panel/panel-run-dialog.c b/mate-panel/panel-run-dialog.c
index d867ed58..fc95d256 100644
--- a/mate-panel/panel-run-dialog.c
+++ b/mate-panel/panel-run-dialog.c
@@ -155,31 +155,30 @@ _panel_run_save_recent_programs_list (PanelRunDialog *dialog,
history_max_size = g_settings_get_uint (dialog->settings, PANEL_RUN_HISTORY_MAX_SIZE_KEY);
+ items = g_array_new (TRUE, TRUE, sizeof (gchar *));
if (history_max_size > 0) {
- items = g_array_new (TRUE, TRUE, sizeof (gchar *));
g_array_append_val (items, lastcommand);
i++;
model = gtk_combo_box_get_model (GTK_COMBO_BOX (entry));
- if (gtk_tree_model_get_iter_first (model, &iter)) {
- char *command;
- do {
- gtk_tree_model_get (model, &iter, 0, &command, -1);
- if (g_strcmp0 (command, lastcommand) == 0)
- continue;
- g_array_append_val (items, command);
- i++;
- } while (gtk_tree_model_iter_next (model, &iter) &&
- i < history_max_size);
+ if (history_max_size > 1) {
+ if (gtk_tree_model_get_iter_first (model, &iter)) {
+ char *command;
+ do {
+ gtk_tree_model_get (model, &iter, 0, &command, -1);
+ if (g_strcmp0 (command, lastcommand) == 0)
+ continue;
+ g_array_append_val (items, command);
+ i++;
+ } while (gtk_tree_model_iter_next (model, &iter) &&
+ i < history_max_size);
+ }
}
-
- g_settings_set_strv (dialog->settings, PANEL_RUN_HISTORY_KEY,
- (const gchar **) items->data);
-
- g_array_free (items, TRUE);
-
}
+ g_settings_set_strv (dialog->settings, PANEL_RUN_HISTORY_KEY,
+ (const gchar **) items->data);
+ g_array_free (items, TRUE);
}
static void