always populate the details fields so a user can see what they selected.
2002-04-26 Jody Goldberg <jody@gnome.org> * service-edit-dialog.c (populate_app_list) : always populate the details fields so a user can see what they selected. (program_changed_cb) : ditto. * service-info.c (fill_service_apps) : fix to not use freed memory.
This commit is contained in:
parent
6bfc1ea23d
commit
8d5b6e6284
3 changed files with 41 additions and 25 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2002-04-26 Jody Goldberg <jody@gnome.org>
|
||||||
|
|
||||||
|
* service-edit-dialog.c (populate_app_list) : always populate the
|
||||||
|
details fields so a user can see what they selected.
|
||||||
|
(program_changed_cb) : ditto.
|
||||||
|
|
||||||
|
* service-info.c (fill_service_apps) : fix to not use freed memory.
|
||||||
|
|
||||||
2002-04-23 Jody Goldberg <jody@gnome.org>
|
2002-04-23 Jody Goldberg <jody@gnome.org>
|
||||||
|
|
||||||
* model-entry.c (model_entry_save) : wrap in vfs freeze/unfreeze.
|
* model-entry.c (model_entry_save) : wrap in vfs freeze/unfreeze.
|
||||||
|
|
|
@ -372,7 +372,7 @@ setup_add_dialog (ServiceEditDialog *dialog)
|
||||||
static void
|
static void
|
||||||
populate_app_list (ServiceEditDialog *dialog)
|
populate_app_list (ServiceEditDialog *dialog)
|
||||||
{
|
{
|
||||||
GtkOptionMenu *option_menu;
|
GtkOptionMenu *program_select;
|
||||||
GtkMenu *menu;
|
GtkMenu *menu;
|
||||||
GtkWidget *item;
|
GtkWidget *item;
|
||||||
gint found_idx = -1, i = 0;
|
gint found_idx = -1, i = 0;
|
||||||
|
@ -380,12 +380,12 @@ populate_app_list (ServiceEditDialog *dialog)
|
||||||
const GList *service_apps;
|
const GList *service_apps;
|
||||||
GnomeVFSMimeApplication *app;
|
GnomeVFSMimeApplication *app;
|
||||||
|
|
||||||
option_menu = GTK_OPTION_MENU (WID ("program_select"));
|
program_select = GTK_OPTION_MENU (WID ("program_select"));
|
||||||
menu = GTK_MENU (gtk_menu_new ());
|
menu = GTK_MENU (gtk_menu_new ());
|
||||||
service_apps = get_apps_for_service_type (dialog->p->info->protocol);
|
service_apps = get_apps_for_service_type (dialog->p->info->protocol);
|
||||||
|
|
||||||
if (service_apps == NULL)
|
if (service_apps == NULL)
|
||||||
gtk_widget_set_sensitive (WID ("program_select"), FALSE);
|
gtk_widget_set_sensitive (GTK_WIDGET (program_select), FALSE);
|
||||||
|
|
||||||
while (service_apps != NULL) {
|
while (service_apps != NULL) {
|
||||||
app = service_apps->data;
|
app = service_apps->data;
|
||||||
|
@ -407,19 +407,13 @@ populate_app_list (ServiceEditDialog *dialog)
|
||||||
item = gtk_menu_item_new_with_label (_("Custom"));
|
item = gtk_menu_item_new_with_label (_("Custom"));
|
||||||
gtk_widget_show (item);
|
gtk_widget_show (item);
|
||||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||||
|
if (found_idx < 0)
|
||||||
|
found_idx = i;
|
||||||
|
|
||||||
if (found_idx < 0) {
|
gtk_option_menu_set_menu (program_select, GTK_WIDGET (menu));
|
||||||
if (dialog->p->info->app != NULL) {
|
gtk_option_menu_set_history (program_select, found_idx);
|
||||||
if (dialog->p->info->app->command != NULL)
|
/* fire it again just in case we had selected the 1st element */
|
||||||
gnome_file_entry_set_filename (GNOME_FILE_ENTRY (WID ("custom_program_entry")),
|
program_changed_cb (dialog, program_select);
|
||||||
dialog->p->info->app->command);
|
|
||||||
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("needs_terminal_toggle")),
|
|
||||||
dialog->p->info->app->requires_terminal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_option_menu_set_menu (option_menu, GTK_WIDGET (menu));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -557,6 +551,8 @@ program_changed_cb (ServiceEditDialog *dialog, GtkOptionMenu *option_menu)
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
GtkMenuShell *menu;
|
GtkMenuShell *menu;
|
||||||
|
GnomeVFSMimeApplication *app;
|
||||||
|
GList *child;
|
||||||
|
|
||||||
menu = GTK_MENU_SHELL (gtk_option_menu_get_menu (option_menu));
|
menu = GTK_MENU_SHELL (gtk_option_menu_get_menu (option_menu));
|
||||||
id = gtk_option_menu_get_history (option_menu);
|
id = gtk_option_menu_get_history (option_menu);
|
||||||
|
@ -568,6 +564,19 @@ program_changed_cb (ServiceEditDialog *dialog, GtkOptionMenu *option_menu)
|
||||||
gtk_widget_set_sensitive (WID ("program_entry_box"), FALSE);
|
gtk_widget_set_sensitive (WID ("program_entry_box"), FALSE);
|
||||||
gtk_widget_set_sensitive (WID ("needs_terminal_toggle"), FALSE);
|
gtk_widget_set_sensitive (WID ("needs_terminal_toggle"), FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
child = g_list_nth (menu->children, id);
|
||||||
|
g_return_if_fail (child != NULL);
|
||||||
|
|
||||||
|
app = g_object_get_data (G_OBJECT (child->data), "app");
|
||||||
|
if (app == NULL)
|
||||||
|
app = dialog->p->info->app;
|
||||||
|
if (app->command != NULL)
|
||||||
|
gnome_file_entry_set_filename (GNOME_FILE_ENTRY (WID ("custom_program_entry")),
|
||||||
|
app->command);
|
||||||
|
|
||||||
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("needs_terminal_toggle")),
|
||||||
|
app->requires_terminal);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -292,17 +292,17 @@ get_key_name (const ServiceInfo *info, const gchar *end)
|
||||||
static void
|
static void
|
||||||
fill_service_apps (void)
|
fill_service_apps (void)
|
||||||
{
|
{
|
||||||
GList *apps, *tmp, *tmp1;
|
GList *app_list, *app, *tmp1;
|
||||||
const gchar *uri_schemes_str;
|
const gchar *uri_schemes_str;
|
||||||
gchar **uri_schemes;
|
gchar **uri_schemes;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (service_apps == NULL)
|
if (service_apps == NULL)
|
||||||
service_apps = g_hash_table_new (g_str_hash, g_str_equal);
|
service_apps = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||||
|
|
||||||
apps = gnome_vfs_application_registry_get_applications (NULL);
|
app_list = gnome_vfs_application_registry_get_applications (NULL);
|
||||||
for (tmp = apps; tmp != NULL; tmp = tmp->next) {
|
for (app = app_list; app != NULL; app = app->next) {
|
||||||
uri_schemes_str = gnome_vfs_application_registry_peek_value (tmp->data, "supported_uri_schemes");
|
uri_schemes_str = gnome_vfs_application_registry_peek_value (app->data, "supported_uri_schemes");
|
||||||
if (uri_schemes_str == NULL)
|
if (uri_schemes_str == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -312,16 +312,15 @@ fill_service_apps (void)
|
||||||
|
|
||||||
for (i = 0; uri_schemes[i] != NULL; i++) {
|
for (i = 0; uri_schemes[i] != NULL; i++) {
|
||||||
tmp1 = g_hash_table_lookup (service_apps, uri_schemes[i]);
|
tmp1 = g_hash_table_lookup (service_apps, uri_schemes[i]);
|
||||||
tmp1 = g_list_prepend (tmp1, gnome_vfs_application_registry_get_mime_application (tmp->data));
|
tmp1 = g_list_prepend (tmp1, gnome_vfs_application_registry_get_mime_application (app->data));
|
||||||
g_hash_table_remove (service_apps, uri_schemes[i]);
|
g_hash_table_replace (service_apps, g_strdup (uri_schemes[i]), tmp1);
|
||||||
g_hash_table_insert (service_apps, uri_schemes[i], tmp1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_strfreev (uri_schemes);
|
g_strfreev (uri_schemes);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_list_foreach (apps, (GFunc) g_free, NULL);
|
g_list_foreach (app_list, (GFunc) g_free, NULL);
|
||||||
g_list_free (apps);
|
g_list_free (app_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue