118
115
static void panel_run_dialog_disconnect_pixmap (PanelRunDialog *dialog);
120
#define PANEL_RUN_HISTORY_KEY "/apps/gnome-settings/gnome-panel/history-gnome-run"
121
#define PANEL_RUN_MAX_HISTORY 10
117
#define PANEL_RUN_MAX_HISTORY 20
123
119
static GtkTreeModel *
124
_panel_run_get_recent_programs_list (void)
120
_panel_run_get_recent_programs_list (PanelRunDialog *dialog)
131
126
list = gtk_list_store_new (1, G_TYPE_STRING);
133
gconf_items = gconf_client_get_list (panel_gconf_get_client (),
134
PANEL_RUN_HISTORY_KEY,
135
GCONF_VALUE_STRING, NULL);
128
commands = g_settings_get_strv (dialog->run_settings,
129
PANEL_RUN_HISTORY_KEY);
137
for (command = gconf_items;
138
command && i < PANEL_RUN_MAX_HISTORY;
139
command = command->next) {
131
for (i = 0; commands[i] != NULL; i++) {
140
132
GtkTreeIter iter;
141
133
gtk_list_store_prepend (list, &iter);
142
gtk_list_store_set (list, &iter, 0, command->data, -1);
134
gtk_list_store_set (list, &iter, 0, commands[i], -1);
146
g_slist_free (gconf_items);
137
g_strfreev (commands);
148
139
return GTK_TREE_MODEL (list);
152
_panel_run_save_recent_programs_list (GtkComboBoxEntry *entry,
143
_panel_run_save_recent_programs_list (PanelRunDialog *dialog,
157
GSList *gconf_items = NULL;
160
gconf_items = g_slist_prepend (gconf_items, lastcommand);
163
model = gtk_combo_box_get_model (GTK_COMBO_BOX (entry));
165
if (gtk_tree_model_get_iter_first (model, &iter)) {
169
gtk_tree_model_get (model, &iter, 0, &command, -1);
171
if (strcmp (command, lastcommand) == 0)
174
gconf_items = g_slist_prepend (gconf_items, command);
176
} while (gtk_tree_model_iter_next (model, &iter) &&
177
i < PANEL_RUN_MAX_HISTORY);
180
gconf_client_set_list (panel_gconf_get_client (),
181
PANEL_RUN_HISTORY_KEY,
182
GCONF_VALUE_STRING, gconf_items,
185
g_slist_free (gconf_items);
151
commands = g_settings_get_strv (dialog->run_settings,
152
PANEL_RUN_HISTORY_KEY);
154
/* do not save the same command twice in a row */
155
if (g_strcmp0 (commands[0], last_command) == 0)
158
for (i = 0; commands[i] != NULL; i++);
159
size = MIN (i + 1, PANEL_RUN_MAX_HISTORY);
161
new_commands = g_new (char *, size + 1);
163
new_commands[0] = last_command;
164
new_commands[size] = NULL; /* last item */
166
for (i = 1; i < size; i++)
167
new_commands[i] = commands[i-1];
169
g_settings_set_strv (dialog->run_settings,
170
PANEL_RUN_HISTORY_KEY,
171
(const char **) new_commands);
173
g_free (new_commands); /* we don't own the strings */
174
g_strfreev (commands);
358
* Set the DISPLAY variable, to be use by g_spawn_async.
361
set_environment (gpointer display)
363
g_setenv ("DISPLAY", display, TRUE);
360
367
panel_run_dialog_launch_command (PanelRunDialog *dialog,
361
368
const char *command,
362
369
const char *locale_command)
364
371
GdkScreen *screen;
366
373
GError *error = NULL;
370
378
if (!command_is_executable (locale_command, &argc, &argv))
373
screen = gtk_window_get_screen (GTK_WINDOW (dialog->run_dialog));
381
screen = gtk_window_get_screen (GTK_WINDOW (dialog->run_dialog));
375
383
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->terminal_checkbox)))
376
384
gnome_desktop_prepend_terminal_to_vector (&argc, &argv);
378
result = gdk_spawn_on_screen (screen,
379
NULL, /* working directory */
383
NULL, /* child setup func */
384
NULL, /* user data */
385
NULL, /* child pid */
386
display = gdk_screen_make_display_name (screen);
388
result = g_spawn_async (NULL, /* working directory */
1128
1130
GtkTreeSelection *selection;
1130
1132
dialog->program_list = PANEL_GTK_BUILDER_GET (gui, "program_list");
1131
dialog->program_list_box = PANEL_GTK_BUILDER_GET (gui, "program_list_box");
1132
1133
dialog->program_label = PANEL_GTK_BUILDER_GET (gui, "program_label");
1133
1134
dialog->main_box = PANEL_GTK_BUILDER_GET (gui, "main_box");
1135
/* Ref the box so it doesn't get destroyed when it is
1136
* removed from the visible area of the dialog box.
1138
g_object_ref (dialog->program_list_box);
1140
if (panel_profile_get_enable_program_list ()) {
1141
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->program_list));
1142
gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
1144
g_signal_connect (selection, "changed",
1145
G_CALLBACK (program_list_selection_changed),
1148
g_signal_connect (dialog->program_list, "row-activated",
1149
G_CALLBACK (program_list_selection_activated),
1152
/* start loading the list of applications */
1153
dialog->add_items_idle_id =
1154
g_idle_add_full (G_PRIORITY_LOW, (GSourceFunc) panel_run_dialog_add_items_idle,
1160
panel_run_dialog_update_content (PanelRunDialog *dialog,
1163
if (!panel_profile_get_enable_program_list ()) {
1166
parent = gtk_widget_get_parent (dialog->list_expander);
1136
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->program_list));
1137
gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
1139
g_signal_connect (selection, "changed",
1140
G_CALLBACK (program_list_selection_changed),
1143
g_signal_connect (dialog->program_list, "row-activated",
1144
G_CALLBACK (program_list_selection_activated),
1149
panel_run_dialog_setup_list_expander (PanelRunDialog *dialog,
1152
dialog->list_expander = PANEL_GTK_BUILDER_GET (gui, "list_expander");
1154
/* Ref the expander so it doesn't get destroyed when it is
1155
* removed from the visible area of the dialog box. */
1156
g_object_ref (dialog->list_expander);
1158
g_settings_bind (dialog->run_settings,
1159
PANEL_RUN_SHOW_LIST_KEY,
1160
dialog->list_expander,
1162
G_SETTINGS_BIND_DEFAULT);
1166
panel_run_dialog_update_program_list (GSettings *settings,
1168
PanelRunDialog *dialog)
1174
enabled = g_settings_get_boolean (dialog->run_settings,
1175
PANEL_RUN_ENABLE_LIST_KEY);
1177
parent = gtk_widget_get_parent (dialog->list_expander);
1180
if (dialog->program_list_store == NULL) {
1181
/* start loading the list of applications */
1182
dialog->add_items_idle_id =
1183
g_idle_add_full (G_PRIORITY_LOW,
1184
(GSourceFunc) panel_run_dialog_add_items_idle,
1189
gtk_box_pack_end (GTK_BOX (dialog->main_box),
1190
dialog->list_expander,
1168
1194
gtk_container_remove (GTK_CONTAINER (parent),
1169
1195
dialog->list_expander);
1171
gtk_window_set_resizable (GTK_WINDOW (dialog->run_dialog), FALSE);
1172
gtk_widget_grab_focus (dialog->combobox);
1174
} else if (show_list) {
1198
shown = g_settings_get_boolean (dialog->run_settings,
1199
PANEL_RUN_SHOW_LIST_KEY);
1201
if (enabled && shown) {
1175
1202
gtk_window_resize (GTK_WINDOW (dialog->run_dialog), 100, 300);
1176
1203
gtk_window_set_resizable (GTK_WINDOW (dialog->run_dialog), TRUE);
1177
1204
gtk_widget_grab_focus (dialog->program_list);
1179
} else if (!show_list) {
1180
1206
gtk_window_set_resizable (GTK_WINDOW (dialog->run_dialog), FALSE);
1181
1207
gtk_widget_grab_focus (dialog->combobox);
1186
panel_run_dialog_content_notify (GConfClient *client,
1189
PanelRunDialog *dialog)
1191
panel_run_dialog_update_content (dialog, gconf_value_get_bool (entry->value));
1195
list_expander_toggled (GtkExpander *expander,
1197
PanelRunDialog *dialog)
1199
panel_profile_set_show_program_list (gtk_expander_get_expanded (expander));
1203
panel_run_dialog_setup_list_expander (PanelRunDialog *dialog,
1206
GConfClient *client;
1209
dialog->list_expander = PANEL_GTK_BUILDER_GET (gui, "list_expander");
1211
if (panel_profile_get_enable_program_list ()) {
1212
gtk_expander_set_expanded (GTK_EXPANDER (dialog->list_expander),
1213
panel_profile_get_show_program_list ());
1215
if ( ! panel_profile_is_writable_show_program_list ())
1216
gtk_widget_set_sensitive (dialog->list_expander, FALSE);
1218
g_signal_connect (dialog->list_expander, "notify::expanded",
1219
G_CALLBACK (list_expander_toggled),
1222
client = panel_gconf_get_client ();
1223
key = panel_gconf_general_key ("show_program_list");
1225
dialog->content_notify_id =
1226
gconf_client_notify_add (client, key,
1227
(GConfClientNotifyFunc) panel_run_dialog_content_notify,
1228
dialog, NULL, NULL);
1230
if (!dialog->content_notify_id)
1231
g_warning ("error setting up content change notification");