summaryrefslogtreecommitdiff
path: root/mate-panel
diff options
context:
space:
mode:
authorMoritz Bruder <[email protected]>2017-04-12 18:27:06 +0200
committerraveit65 <[email protected]>2017-04-25 12:26:40 +0200
commit94cd1e26f4729f5ff116cf079170fa58450b7f53 (patch)
tree8d3230ff92aaf0006e0420a715c6d384bee08dc2 /mate-panel
parent82ded619a7d07651bfcbec7dfbdb02437ae5f522 (diff)
downloadmate-panel-94cd1e26f4729f5ff116cf079170fa58450b7f53.tar.bz2
mate-panel-94cd1e26f4729f5ff116cf079170fa58450b7f53.tar.xz
Run dialog: Allow changing history size
A key has been added to the gsettings schema that controls history size. The code of the run dialog has been changed to use that key.
Diffstat (limited to 'mate-panel')
-rw-r--r--mate-panel/panel-run-dialog.c59
1 files changed, 33 insertions, 26 deletions
diff --git a/mate-panel/panel-run-dialog.c b/mate-panel/panel-run-dialog.c
index e61f3ece..d867ed58 100644
--- a/mate-panel/panel-run-dialog.c
+++ b/mate-panel/panel-run-dialog.c
@@ -114,22 +114,23 @@ static void panel_run_dialog_disconnect_pixmap (PanelRunDialog *dialog);
#define PANEL_RUN_SCHEMA "org.mate.panel"
#define PANEL_RUN_HISTORY_KEY "history-mate-run"
+#define PANEL_RUN_HISTORY_MAX_SIZE_KEY "history-max-size-mate-run"
#define PANEL_RUN_SHOW_PROGRAM_LIST_KEY "show-program-list"
-#define PANEL_RUN_MAX_HISTORY 10
static GtkTreeModel *
_panel_run_get_recent_programs_list (PanelRunDialog *dialog)
{
GtkListStore *list;
gchar **items;
- int i = 0;
+ guint history_max_size;
+ guint i = 0;
list = gtk_list_store_new (1, G_TYPE_STRING);
+ history_max_size = g_settings_get_uint (dialog->settings, PANEL_RUN_HISTORY_MAX_SIZE_KEY);
items = g_settings_get_strv (dialog->settings, PANEL_RUN_HISTORY_KEY);
-
for (i = 0;
- items[i] && i < PANEL_RUN_MAX_HISTORY;
+ items[i] && i < history_max_size;
i++) {
GtkTreeIter iter;
gtk_list_store_append (list, &iter);
@@ -149,30 +150,36 @@ _panel_run_save_recent_programs_list (PanelRunDialog *dialog,
GtkTreeModel *model;
GtkTreeIter iter;
GArray *items;
- gint i = 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 < PANEL_RUN_MAX_HISTORY);
- }
+ guint history_max_size;
+ guint i = 0;
+
+ history_max_size = g_settings_get_uint (dialog->settings, PANEL_RUN_HISTORY_MAX_SIZE_KEY);
+
+ 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);
+ }
- g_settings_set_strv (dialog->settings, PANEL_RUN_HISTORY_KEY,
- (const gchar **) items->data);
+ g_settings_set_strv (dialog->settings, PANEL_RUN_HISTORY_KEY,
+ (const gchar **) items->data);
- g_array_free (items, TRUE);
+ g_array_free (items, TRUE);
+
+ }
}
static void