Implement
2002-01-11 Bradford Hovinen <hovinen@ximian.com> * service-info.c (get_apps_for_service_type): Implement * service-edit-dialog.c (program_changed_cb): Implement (service_edit_dialog_init): Connect program_select changed signal (populate_app_list): Fill app menu with results from get_apps_for_service_type * service-info.c (fill_service_apps): Implement
This commit is contained in:
parent
caa4385d60
commit
9cd12bb3c2
7 changed files with 96 additions and 3 deletions
|
@ -1,5 +1,14 @@
|
|||
2002-01-11 Bradford Hovinen <hovinen@ximian.com>
|
||||
|
||||
* service-info.c (get_apps_for_service_type): Implement
|
||||
|
||||
* service-edit-dialog.c (program_changed_cb): Implement
|
||||
(service_edit_dialog_init): Connect program_select changed signal
|
||||
(populate_app_list): Fill app menu with results from
|
||||
get_apps_for_service_type
|
||||
|
||||
* service-info.c (fill_service_apps): Implement
|
||||
|
||||
* service-edit-dialog.c (store_data): Retrieve app info from
|
||||
option menu
|
||||
|
||||
|
|
|
@ -16,3 +16,4 @@ CVS Surgery
|
|||
- Rename .glade files in standard convention (gnome-xxx-properties.glade)
|
||||
- Rename primary .c files in standard convention (gnome-xxx-properties.c)
|
||||
- Kill url-properties, preferably with extreme prejudice
|
||||
- Kill unused files in file-types
|
|
@ -998,7 +998,7 @@
|
|||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox12">
|
||||
<widget class="GtkHBox" id="program_entry_box">
|
||||
<property name="homogeneous">no</property>
|
||||
<property name="spacing">4</property>
|
||||
<property name="visible">yes</property>
|
||||
|
|
|
@ -953,7 +953,7 @@
|
|||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>hbox12</name>
|
||||
<name>program_entry_box</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>4</spacing>
|
||||
<child>
|
||||
|
|
|
@ -69,6 +69,8 @@ static void store_data (ServiceEditDialog *dialog);
|
|||
|
||||
static void program_sensitive_cb (ServiceEditDialog *dialog,
|
||||
GtkToggleButton *tb);
|
||||
static void program_changed_cb (ServiceEditDialog *dialog,
|
||||
GtkOptionMenu *option_menu);
|
||||
|
||||
static void response_cb (ServiceEditDialog *dialog,
|
||||
gint response_id);
|
||||
|
@ -123,6 +125,7 @@ service_edit_dialog_init (ServiceEditDialog *dialog, ServiceEditDialogClass *cla
|
|||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog->p->dialog_win)->vbox), WID ("service_edit_widget"), TRUE, TRUE, 0);
|
||||
|
||||
g_signal_connect_swapped (G_OBJECT (WID ("run_program_toggle")), "toggled", (GCallback) program_sensitive_cb, dialog);
|
||||
g_signal_connect_swapped (G_OBJECT (WID ("program_select")), "changed", (GCallback) program_changed_cb, dialog);
|
||||
|
||||
g_signal_connect_swapped (G_OBJECT (dialog->p->dialog_win), "response", (GCallback) response_cb, dialog);
|
||||
}
|
||||
|
@ -278,9 +281,21 @@ populate_app_list (ServiceEditDialog *dialog)
|
|||
GtkMenu *menu;
|
||||
GtkWidget *item;
|
||||
|
||||
option_menu = GTK_OPTION_MENU (WID ("program_select"));
|
||||
const GList *service_apps;
|
||||
GnomeVFSMimeApplication *app;
|
||||
|
||||
option_menu = GTK_OPTION_MENU (WID ("program_select"));
|
||||
menu = GTK_MENU (gtk_menu_new ());
|
||||
service_apps = get_apps_for_service_type (dialog->p->info->protocol);
|
||||
|
||||
while (service_apps != NULL) {
|
||||
app = service_apps->data;
|
||||
item = gtk_menu_item_new_with_label (app->name);
|
||||
g_object_set_data (G_OBJECT (item), "app", app);
|
||||
gtk_widget_show (item);
|
||||
gtk_menu_append (menu, item);
|
||||
service_apps = service_apps->next;
|
||||
}
|
||||
|
||||
item = gtk_menu_item_new_with_label (_("Custom"));
|
||||
gtk_widget_show (item);
|
||||
|
@ -330,6 +345,24 @@ program_sensitive_cb (ServiceEditDialog *dialog, GtkToggleButton *tb)
|
|||
gtk_widget_set_sensitive (WID ("program_frame"), FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
program_changed_cb (ServiceEditDialog *dialog, GtkOptionMenu *option_menu)
|
||||
{
|
||||
int id;
|
||||
GtkMenuShell *menu;
|
||||
|
||||
menu = GTK_MENU_SHELL (gtk_option_menu_get_menu (option_menu));
|
||||
id = gtk_option_menu_get_history (option_menu);
|
||||
|
||||
if (id == g_list_length (menu->children) - 1) {
|
||||
gtk_widget_set_sensitive (WID ("program_entry_box"), TRUE);
|
||||
gtk_widget_set_sensitive (WID ("needs_terminal_toggle"), TRUE);
|
||||
} else {
|
||||
gtk_widget_set_sensitive (WID ("program_entry_box"), FALSE);
|
||||
gtk_widget_set_sensitive (WID ("needs_terminal_toggle"), FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
response_cb (ServiceEditDialog *dialog, gint response_id)
|
||||
{
|
||||
|
|
|
@ -27,16 +27,55 @@
|
|||
#endif
|
||||
|
||||
#include <gconf/gconf-client.h>
|
||||
#include <libgnomevfs/gnome-vfs-application-registry.h>
|
||||
|
||||
#include "service-info.h"
|
||||
#include "mime-types-model.h"
|
||||
|
||||
/* This is a hash table of GLists indexed by protocol name; each entry in each
|
||||
* list is a GnomeVFSMimeApplication that can handle that protocol */
|
||||
|
||||
static GHashTable *service_apps = NULL;
|
||||
|
||||
static gchar *
|
||||
get_key_name (const ServiceInfo *info, gchar *end)
|
||||
{
|
||||
return g_strconcat ("/desktop/gnome/url-handlers/", info->protocol, "/", end, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
fill_service_apps (void)
|
||||
{
|
||||
GList *apps, *tmp, *tmp1;
|
||||
const gchar *uri_schemes_str;
|
||||
gchar **uri_schemes;
|
||||
int i;
|
||||
|
||||
if (service_apps == NULL)
|
||||
service_apps = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
/* FIXME: This currently returns NULL. We need a way to retrieve all
|
||||
apps in the registry */
|
||||
apps = gnome_vfs_application_registry_get_applications ("*/*");
|
||||
|
||||
for (tmp = apps; tmp != NULL; tmp = tmp->next) {
|
||||
uri_schemes_str = gnome_vfs_application_registry_peek_value (tmp->data, "supported_uri_schemes");
|
||||
uri_schemes = g_strsplit (uri_schemes_str, ",", -1);
|
||||
|
||||
for (i = 0; uri_schemes[i] != NULL; 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));
|
||||
g_hash_table_remove (service_apps, uri_schemes[i]);
|
||||
g_hash_table_insert (service_apps, uri_schemes[i], tmp1);
|
||||
}
|
||||
|
||||
g_strfreev (uri_schemes);
|
||||
}
|
||||
|
||||
g_list_foreach (apps, (GFunc) g_free, NULL);
|
||||
g_list_free (apps);
|
||||
}
|
||||
|
||||
static void
|
||||
set_string (const ServiceInfo *info, gchar *end, gchar *value, GConfChangeSet *changeset)
|
||||
{
|
||||
|
@ -183,3 +222,12 @@ service_info_free (ServiceInfo *info)
|
|||
gnome_vfs_mime_application_free (info->app);
|
||||
g_free (info->custom_line);
|
||||
}
|
||||
|
||||
const GList *
|
||||
get_apps_for_service_type (gchar *protocol)
|
||||
{
|
||||
if (service_apps == NULL)
|
||||
fill_service_apps ();
|
||||
|
||||
return g_hash_table_lookup (service_apps, protocol);
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ void service_info_save (const ServiceInfo *info);
|
|||
void service_info_update (ServiceInfo *info);
|
||||
void service_info_free (ServiceInfo *info);
|
||||
|
||||
const GList *get_apps_for_service_type (gchar *protocol);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __SERVICE_INFO_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue