Set custom program entry and needs terminal here
2002-01-28 Bradford Hovinen <hovinen@ximian.com> * service-edit-dialog.c (populate_app_list): Set custom program entry and needs terminal here * service-info.c (service_info_using_custom_app): Implement * service-edit-dialog.c (populate_app_list): Add destroy notify for app * service-info.[ch]: Eliminate custom_line and needs_terminal; use app for that
This commit is contained in:
parent
049ab3cb31
commit
66fa37fc6e
4 changed files with 105 additions and 24 deletions
|
@ -1,5 +1,16 @@
|
||||||
2002-01-28 Bradford Hovinen <hovinen@ximian.com>
|
2002-01-28 Bradford Hovinen <hovinen@ximian.com>
|
||||||
|
|
||||||
|
* service-edit-dialog.c (populate_app_list): Set custom program
|
||||||
|
entry and needs terminal here
|
||||||
|
|
||||||
|
* service-info.c (service_info_using_custom_app): Implement
|
||||||
|
|
||||||
|
* service-edit-dialog.c (populate_app_list): Add destroy notify
|
||||||
|
for app
|
||||||
|
|
||||||
|
* service-info.[ch]: Eliminate custom_line and needs_terminal; use
|
||||||
|
app for that
|
||||||
|
|
||||||
* mime-edit-dialog.c (populate_application_list): Use
|
* mime-edit-dialog.c (populate_application_list): Use
|
||||||
gnome_vfs_application_registry_get_applications
|
gnome_vfs_application_registry_get_applications
|
||||||
|
|
||||||
|
|
|
@ -339,9 +339,6 @@ fill_dialog (ServiceEditDialog *dialog)
|
||||||
if (!dialog->p->info->run_program && strcmp (dialog->p->info->protocol, "ftp"))
|
if (!dialog->p->info->run_program && strcmp (dialog->p->info->protocol, "ftp"))
|
||||||
gtk_widget_set_sensitive (WID ("program_frame"), FALSE);
|
gtk_widget_set_sensitive (WID ("program_frame"), FALSE);
|
||||||
|
|
||||||
if (dialog->p->info->custom_line != NULL)
|
|
||||||
gnome_file_entry_set_filename (GNOME_FILE_ENTRY (WID ("custom_program_entry")), dialog->p->info->custom_line);
|
|
||||||
|
|
||||||
populate_app_list (dialog);
|
populate_app_list (dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,6 +364,7 @@ populate_app_list (ServiceEditDialog *dialog)
|
||||||
GtkOptionMenu *option_menu;
|
GtkOptionMenu *option_menu;
|
||||||
GtkMenu *menu;
|
GtkMenu *menu;
|
||||||
GtkWidget *item;
|
GtkWidget *item;
|
||||||
|
gint found_idx = -1, i = 0;
|
||||||
|
|
||||||
const GList *service_apps;
|
const GList *service_apps;
|
||||||
GnomeVFSMimeApplication *app;
|
GnomeVFSMimeApplication *app;
|
||||||
|
@ -380,17 +378,36 @@ populate_app_list (ServiceEditDialog *dialog)
|
||||||
|
|
||||||
while (service_apps != NULL) {
|
while (service_apps != NULL) {
|
||||||
app = service_apps->data;
|
app = service_apps->data;
|
||||||
|
|
||||||
|
if (dialog->p->info->app != NULL &&
|
||||||
|
dialog->p->info->app->id != NULL &&
|
||||||
|
!strcmp (dialog->p->info->app->id, app->id))
|
||||||
|
found_idx = i;
|
||||||
|
|
||||||
item = gtk_menu_item_new_with_label (app->name);
|
item = gtk_menu_item_new_with_label (app->name);
|
||||||
g_object_set_data (G_OBJECT (item), "app", app);
|
g_object_set_data_full (G_OBJECT (item), "app", app, (GDestroyNotify) gnome_vfs_mime_application_free);
|
||||||
gtk_widget_show (item);
|
gtk_widget_show (item);
|
||||||
gtk_menu_append (menu, item);
|
gtk_menu_append (menu, item);
|
||||||
|
|
||||||
service_apps = service_apps->next;
|
service_apps = service_apps->next;
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
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_append (menu, item);
|
gtk_menu_append (menu, item);
|
||||||
|
|
||||||
|
if (found_idx < 0) {
|
||||||
|
if (dialog->p->info->app != NULL) {
|
||||||
|
if (dialog->p->info->app->command != NULL)
|
||||||
|
gnome_file_entry_set_filename (GNOME_FILE_ENTRY (WID ("custom_program_entry")),
|
||||||
|
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));
|
gtk_option_menu_set_menu (option_menu, GTK_WIDGET (menu));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,6 +419,8 @@ store_data (ServiceEditDialog *dialog)
|
||||||
GObject *menu_item;
|
GObject *menu_item;
|
||||||
gint idx;
|
gint idx;
|
||||||
|
|
||||||
|
GnomeVFSMimeApplication *app;
|
||||||
|
|
||||||
GtkTreePath *path;
|
GtkTreePath *path;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
|
||||||
|
@ -414,18 +433,29 @@ store_data (ServiceEditDialog *dialog)
|
||||||
dialog->p->info->run_program =
|
dialog->p->info->run_program =
|
||||||
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("run_program_toggle")));
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("run_program_toggle")));
|
||||||
|
|
||||||
g_free (dialog->p->info->custom_line);
|
|
||||||
dialog->p->info->custom_line =
|
|
||||||
g_strdup (gnome_file_entry_get_full_path (GNOME_FILE_ENTRY (WID ("custom_program_entry")), FALSE));
|
|
||||||
|
|
||||||
option_menu = GTK_OPTION_MENU (WID ("program_select"));
|
option_menu = GTK_OPTION_MENU (WID ("program_select"));
|
||||||
menu_shell = GTK_MENU_SHELL (gtk_option_menu_get_menu (option_menu));
|
menu_shell = GTK_MENU_SHELL (gtk_option_menu_get_menu (option_menu));
|
||||||
idx = gtk_option_menu_get_history (option_menu);
|
idx = gtk_option_menu_get_history (option_menu);
|
||||||
menu_item = (g_list_nth (menu_shell->children, idx))->data;
|
menu_item = (g_list_nth (menu_shell->children, idx))->data;
|
||||||
|
|
||||||
gnome_vfs_mime_application_free (dialog->p->info->app);
|
app = g_object_get_data (menu_item, "app");
|
||||||
dialog->p->info->app =
|
if (app != NULL) {
|
||||||
gnome_vfs_mime_application_copy (g_object_get_data (menu_item, "app"));
|
gnome_vfs_mime_application_free (dialog->p->info->app);
|
||||||
|
dialog->p->info->app = gnome_vfs_mime_application_copy (app);
|
||||||
|
} else {
|
||||||
|
if (!service_info_using_custom_app (dialog->p->info)) {
|
||||||
|
gnome_vfs_mime_application_free (dialog->p->info->app);
|
||||||
|
dialog->p->info->app = g_new0 (GnomeVFSMimeApplication, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (dialog->p->info->app->command);
|
||||||
|
dialog->p->info->app->command
|
||||||
|
= g_strdup (gtk_entry_get_text (GTK_ENTRY
|
||||||
|
(gnome_file_entry_gtk_entry
|
||||||
|
(GNOME_FILE_ENTRY (WID ("custom_program_entry"))))));
|
||||||
|
dialog->p->info->app->requires_terminal
|
||||||
|
= gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("needs_terminal_toggle")));
|
||||||
|
}
|
||||||
|
|
||||||
model_entry_append_to_dirty_list (MODEL_ENTRY (dialog->p->info));
|
model_entry_append_to_dirty_list (MODEL_ENTRY (dialog->p->info));
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#include <gconf/gconf-client.h>
|
#include <gconf/gconf-client.h>
|
||||||
#include <libgnomevfs/gnome-vfs-application-registry.h>
|
#include <libgnomevfs/gnome-vfs-application-registry.h>
|
||||||
|
|
||||||
|
#include "libuuid/uuid.h"
|
||||||
|
|
||||||
#include "service-info.h"
|
#include "service-info.h"
|
||||||
#include "mime-types-model.h"
|
#include "mime-types-model.h"
|
||||||
|
|
||||||
|
@ -119,15 +121,15 @@ service_info_load_all (ServiceInfo *info)
|
||||||
info->run_program = TRUE;
|
info->run_program = TRUE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (info->custom_line == NULL)
|
|
||||||
info->custom_line = get_string (info, "command");
|
|
||||||
|
|
||||||
info->need_terminal = get_bool (info, "need-terminal");
|
|
||||||
|
|
||||||
if (info->app == NULL) {
|
if (info->app == NULL) {
|
||||||
id = get_string (info, "command-id");
|
id = get_string (info, "command-id");
|
||||||
if (id != NULL)
|
if (id != NULL)
|
||||||
info->app = gnome_vfs_mime_application_new_from_id (id);
|
info->app = gnome_vfs_mime_application_new_from_id (id);
|
||||||
|
else {
|
||||||
|
info->app = g_new0 (GnomeVFSMimeApplication, 1);
|
||||||
|
info->app->command = get_string (info, "command");
|
||||||
|
info->app->requires_terminal = get_bool (info, "needs-terminal");
|
||||||
|
}
|
||||||
g_free (id);
|
g_free (id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,21 +153,61 @@ service_info_get_description (ServiceInfo *info)
|
||||||
return info->description;
|
return info->description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
service_info_using_custom_app (const ServiceInfo *info)
|
||||||
|
{
|
||||||
|
gchar *tmp;
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
|
if (info->app->name == NULL)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
tmp = g_strdup_printf ("Custom %s", info->protocol);
|
||||||
|
ret = !strcmp (tmp, info->app->name);
|
||||||
|
g_free (tmp);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
service_info_save (const ServiceInfo *info)
|
service_info_save (const ServiceInfo *info)
|
||||||
{
|
{
|
||||||
|
gchar *tmp;
|
||||||
|
uuid_t app_uuid;
|
||||||
|
gchar app_uuid_str[100];
|
||||||
|
|
||||||
set_string (info, "description", info->description);
|
set_string (info, "description", info->description);
|
||||||
|
|
||||||
if (info->app == NULL) {
|
if (info->app != NULL && info->app->command != NULL && *info->app->command != '\0') {
|
||||||
set_string (info, "command", info->custom_line);
|
tmp = g_strdup_printf ("Custom %s", info->protocol);
|
||||||
set_string (info, "command-id", "");
|
|
||||||
} else {
|
if (info->app->name == NULL)
|
||||||
|
info->app->name = tmp;
|
||||||
|
|
||||||
|
if (info->app->id == NULL) {
|
||||||
|
uuid_generate (app_uuid);
|
||||||
|
uuid_unparse (app_uuid, app_uuid_str);
|
||||||
|
|
||||||
|
info->app->id = g_strdup (app_uuid_str);
|
||||||
|
|
||||||
|
gnome_vfs_application_registry_save_mime_application (info->app);
|
||||||
|
gnome_vfs_application_registry_sync ();
|
||||||
|
}
|
||||||
|
else if (!strcmp (tmp, info->app->name)) {
|
||||||
|
gnome_vfs_application_registry_set_value (info->app->id, "command",
|
||||||
|
info->app->command);
|
||||||
|
gnome_vfs_application_registry_set_bool_value (info->app->id, "requires_terminal",
|
||||||
|
info->app->requires_terminal);
|
||||||
|
}
|
||||||
|
|
||||||
set_string (info, "command", info->app->command);
|
set_string (info, "command", info->app->command);
|
||||||
set_string (info, "command-id", info->app->id);
|
set_string (info, "command-id", info->app->id);
|
||||||
|
} else {
|
||||||
|
set_string (info, "command", NULL);
|
||||||
|
set_string (info, "command-id", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_bool (info, "type", info->run_program);
|
set_bool (info, "type", info->run_program);
|
||||||
set_bool (info, "need-terminal", info->need_terminal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -200,7 +242,6 @@ service_info_free (ServiceInfo *info)
|
||||||
g_free (info->protocol);
|
g_free (info->protocol);
|
||||||
g_free (info->description);
|
g_free (info->description);
|
||||||
gnome_vfs_mime_application_free (info->app);
|
gnome_vfs_mime_application_free (info->app);
|
||||||
g_free (info->custom_line);
|
|
||||||
g_free (info);
|
g_free (info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,8 +45,6 @@ struct _ServiceInfo {
|
||||||
gboolean run_program;
|
gboolean run_program;
|
||||||
|
|
||||||
GnomeVFSMimeApplication *app;
|
GnomeVFSMimeApplication *app;
|
||||||
gchar *custom_line;
|
|
||||||
gboolean need_terminal;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void load_all_services (GtkTreeModel *model);
|
void load_all_services (GtkTreeModel *model);
|
||||||
|
@ -55,6 +53,7 @@ ServiceInfo *service_info_new (const gchar *protocol,
|
||||||
GtkTreeModel *model);
|
GtkTreeModel *model);
|
||||||
void service_info_load_all (ServiceInfo *info);
|
void service_info_load_all (ServiceInfo *info);
|
||||||
const gchar *service_info_get_description (ServiceInfo *info);
|
const gchar *service_info_get_description (ServiceInfo *info);
|
||||||
|
gboolean service_info_using_custom_app (const ServiceInfo *info);
|
||||||
void service_info_save (const ServiceInfo *info);
|
void service_info_save (const ServiceInfo *info);
|
||||||
void service_info_delete (const ServiceInfo *info);
|
void service_info_delete (const ServiceInfo *info);
|
||||||
void service_info_free (ServiceInfo *info);
|
void service_info_free (ServiceInfo *info);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue