summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoritz Bruder <[email protected]>2017-04-18 04:52:36 +0200
committerraveit65 <[email protected]>2017-04-25 12:26:54 +0200
commitb89a1bd6f2ca16055a68fb2b262b4d231297e16e (patch)
tree2fec2fc20853a1453de10fb9c11a38ef36e8ce63
parent94cd1e26f4729f5ff116cf079170fa58450b7f53 (diff)
downloadmate-panel-b89a1bd6f2ca16055a68fb2b262b4d231297e16e.tar.bz2
mate-panel-b89a1bd6f2ca16055a68fb2b262b4d231297e16e.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).
-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