mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-09 13:02:01 +03:00
more work.
also minor fix in gnome-edit-properties. off to go see cruel intentions.
This commit is contained in:
parent
26556bcf3b
commit
903f57ef76
@ -6,7 +6,7 @@ INCLUDES = -I. -I$(srcdir) \
|
|||||||
|
|
||||||
bin_PROGRAMS = mime-type-capplet
|
bin_PROGRAMS = mime-type-capplet
|
||||||
|
|
||||||
mime_type_capplet_SOURCES = mime-type-capplet.c mime-data.c edit-window.c
|
mime_type_capplet_SOURCES = mime-type-capplet.c mime-data.c edit-window.c mime-info.c
|
||||||
|
|
||||||
mime_type_capplet_LDADD = ../../control-center/libcapplet.la \
|
mime_type_capplet_LDADD = ../../control-center/libcapplet.la \
|
||||||
$(GNOME_LIBDIR) $(ORB_LIBS) \
|
$(GNOME_LIBDIR) $(ORB_LIBS) \
|
||||||
|
@ -1,23 +1,279 @@
|
|||||||
#include "edit-window.h"
|
#include "edit-window.h"
|
||||||
|
#include "capplet-widget.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern GtkWidget *capplet;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
|
GtkWidget *icon_entry;
|
||||||
|
GtkWidget *mime_type;
|
||||||
|
GtkWidget *ext_label;
|
||||||
|
GtkWidget *regexp1_label;
|
||||||
|
GtkWidget *regexp2_label;
|
||||||
|
GtkWidget *open_entry;
|
||||||
|
GtkWidget *edit_entry;
|
||||||
|
GtkWidget *view_entry;
|
||||||
|
GtkWidget *open_cbox;
|
||||||
|
GtkWidget *edit_cbox;
|
||||||
|
GtkWidget *view_cbox;
|
||||||
} edit_window;
|
} edit_window;
|
||||||
static edit_window *main_win = NULL;
|
static edit_window *main_win = NULL;
|
||||||
|
static gboolean changing = TRUE;
|
||||||
|
static void
|
||||||
|
destruction_handler (GtkWidget *widget, gpointer data)
|
||||||
|
{
|
||||||
|
g_free (main_win);
|
||||||
|
main_win = NULL;
|
||||||
|
}
|
||||||
|
static void
|
||||||
|
entry_changed (GtkWidget *widget, gpointer data)
|
||||||
|
{
|
||||||
|
if (changing == FALSE)
|
||||||
|
capplet_widget_state_changed (CAPPLET_WIDGET (capplet),
|
||||||
|
TRUE);
|
||||||
|
}
|
||||||
|
static void
|
||||||
|
apply_entry_change (GtkWidget *entry, gchar *key, MimeInfo *mi)
|
||||||
|
{
|
||||||
|
gchar *buf;
|
||||||
|
gchar *text;
|
||||||
|
|
||||||
|
/* buf is the value that existed before when we
|
||||||
|
* started the capplet */
|
||||||
|
buf = local_mime_get_value (mi->mime_type, key);
|
||||||
|
if (buf == NULL)
|
||||||
|
buf = gnome_mime_get_value (mi->mime_type, key);
|
||||||
|
text = gtk_entry_get_text (GTK_ENTRY (entry));
|
||||||
|
if (text && !*text)
|
||||||
|
text = NULL;
|
||||||
|
|
||||||
|
/* First we see if they've added something. */
|
||||||
|
if (buf == NULL && text)
|
||||||
|
set_mime_key_value (mi->mime_type, key, text);
|
||||||
|
else {
|
||||||
|
/* Has the value changed? */
|
||||||
|
if (text && strcmp (text, buf))
|
||||||
|
set_mime_key_value (mi->mime_type, key, text);
|
||||||
|
else
|
||||||
|
/* We _REALLY_ need a way to specify in
|
||||||
|
* user.keys not to use the system defaults.
|
||||||
|
* (ie. override the system default and
|
||||||
|
* query it).
|
||||||
|
* If we could then we'd set it here. */
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static void
|
||||||
|
apply_changes (MimeInfo *mi)
|
||||||
|
{
|
||||||
|
apply_entry_change (main_win->open_entry, "open", mi);
|
||||||
|
apply_entry_change (main_win->view_entry, "view", mi);
|
||||||
|
apply_entry_change (main_win->edit_entry, "edit", mi);
|
||||||
|
}
|
||||||
static void
|
static void
|
||||||
initialize_main_win ()
|
initialize_main_win ()
|
||||||
{
|
{
|
||||||
|
GtkWidget *align, *vbox, *hbox, *vbox2;
|
||||||
|
GtkWidget *frame, *table, *label;
|
||||||
|
GtkWidget *button;
|
||||||
|
GString *extension;
|
||||||
|
|
||||||
main_win = g_new (edit_window, 1);
|
main_win = g_new (edit_window, 1);
|
||||||
main_win->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
main_win->window = gnome_dialog_new ("",
|
||||||
|
GNOME_STOCK_BUTTON_OK,
|
||||||
|
GNOME_STOCK_BUTTON_CANCEL,
|
||||||
|
NULL);
|
||||||
|
gtk_signal_connect (GTK_OBJECT (main_win->window),
|
||||||
|
"destroy",
|
||||||
|
destruction_handler,
|
||||||
|
NULL);
|
||||||
|
vbox = GNOME_DIALOG (main_win->window)->vbox;
|
||||||
|
|
||||||
|
/* icon box */
|
||||||
|
main_win->icon_entry = gnome_icon_entry_new ("mime_icon_entry", _("Select an icon..."));
|
||||||
|
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
||||||
|
gtk_container_add (GTK_CONTAINER (align), main_win->icon_entry);
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("Mime Type: ")), FALSE, FALSE, 0);
|
||||||
|
main_win->mime_type = gtk_label_new ("");
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), main_win->mime_type, FALSE, FALSE, 0);
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
/* extension/regexp */
|
||||||
|
vbox2 = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
|
||||||
|
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
|
||||||
|
main_win->ext_label = gtk_label_new ("");
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("Extension: ")),
|
||||||
|
FALSE, FALSE, 0);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), main_win->ext_label, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
|
||||||
|
main_win->regexp1_label = gtk_label_new ("");
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("First Regular Expresion: ")),
|
||||||
|
FALSE, FALSE, 0);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), main_win->regexp1_label, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
|
||||||
|
main_win->regexp2_label = gtk_label_new ("");
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("Second Regular Expresion: ")),
|
||||||
|
FALSE, FALSE, 0);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), main_win->regexp2_label, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
/* Actions box */
|
||||||
|
frame = gtk_frame_new (_("Mime-Type Actions"));
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
|
||||||
|
table = gtk_table_new (8, 3, FALSE);
|
||||||
|
gtk_table_set_row_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
|
||||||
|
gtk_container_set_border_width (GTK_CONTAINER (table), GNOME_PAD_SMALL/2);
|
||||||
|
gtk_container_add (GTK_CONTAINER (frame), table);
|
||||||
|
label = gtk_label_new (_("Open"));
|
||||||
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
||||||
|
gtk_misc_set_padding (GTK_MISC (label), 2, 0);
|
||||||
|
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||||
|
label,
|
||||||
|
0, 1, 0, 1);
|
||||||
|
main_win->open_entry = gtk_entry_new ();
|
||||||
|
gtk_signal_connect (GTK_OBJECT (main_win->open_entry),
|
||||||
|
"changed",
|
||||||
|
entry_changed,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||||
|
main_win->open_entry,
|
||||||
|
1, 2, 0, 1);
|
||||||
|
button = gtk_button_new_with_label ("Browse...");
|
||||||
|
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||||
|
button,
|
||||||
|
2, 3, 0, 1);
|
||||||
|
|
||||||
|
main_win->open_cbox = gtk_check_button_new_with_label (_("Use default Open action"));
|
||||||
|
/* gtk_table_attach_defaults (GTK_TABLE (table),
|
||||||
|
main_win->open_cbox,
|
||||||
|
0, 2, 1, 2);*/
|
||||||
|
|
||||||
|
label = gtk_label_new (_("View"));
|
||||||
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
||||||
|
gtk_misc_set_padding (GTK_MISC (label), 2, 0);
|
||||||
|
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||||
|
label,
|
||||||
|
0, 1, 3, 4);
|
||||||
|
main_win->view_entry = gtk_entry_new ();
|
||||||
|
gtk_signal_connect (GTK_OBJECT (main_win->view_entry),
|
||||||
|
"changed",
|
||||||
|
entry_changed,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||||
|
main_win->view_entry,
|
||||||
|
1, 2, 3, 4);
|
||||||
|
button = gtk_button_new_with_label ("Browse...");
|
||||||
|
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||||
|
button,
|
||||||
|
2, 3, 3, 4);
|
||||||
|
|
||||||
|
main_win->open_cbox = gtk_check_button_new_with_label (_("Use default View action"));
|
||||||
|
/* gtk_table_attach_defaults (GTK_TABLE (table),
|
||||||
|
main_win->open_cbox,
|
||||||
|
0, 2, 4, 5);*/
|
||||||
|
label = gtk_label_new (_("Edit"));
|
||||||
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
||||||
|
gtk_misc_set_padding (GTK_MISC (label), 2, 0);
|
||||||
|
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||||
|
label,
|
||||||
|
0, 1, 6, 7);
|
||||||
|
main_win->edit_entry = gtk_entry_new ();
|
||||||
|
gtk_signal_connect (GTK_OBJECT (main_win->edit_entry),
|
||||||
|
"changed",
|
||||||
|
entry_changed,
|
||||||
|
NULL);
|
||||||
|
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||||
|
main_win->edit_entry,
|
||||||
|
1, 2, 6, 7);
|
||||||
|
button = gtk_button_new_with_label ("Browse...");
|
||||||
|
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||||
|
button,
|
||||||
|
2, 3, 6, 7);
|
||||||
|
|
||||||
|
main_win->edit_cbox = gtk_check_button_new_with_label (_("Use default Edit action"));
|
||||||
|
/* gtk_table_attach_defaults (GTK_TABLE (table),
|
||||||
|
main_win->edit_cbox,
|
||||||
|
0, 2, 7, 8);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup_entry (gchar *key, GtkWidget *entry, MimeInfo *mi)
|
||||||
|
{
|
||||||
|
gchar *buf;
|
||||||
|
buf = local_mime_get_value (mi->mime_type, key);
|
||||||
|
if (buf == NULL)
|
||||||
|
buf = gnome_mime_get_value (mi->mime_type, key);
|
||||||
|
if (buf)
|
||||||
|
gtk_entry_set_text (GTK_ENTRY (entry), buf);
|
||||||
|
else
|
||||||
|
gtk_entry_set_text (GTK_ENTRY (entry), "");
|
||||||
|
}
|
||||||
void
|
void
|
||||||
launch_edit_window (MimeInfo *mi)
|
launch_edit_window (MimeInfo *mi)
|
||||||
{
|
{
|
||||||
|
gint size;
|
||||||
|
|
||||||
|
changing = TRUE;
|
||||||
if (main_win == NULL)
|
if (main_win == NULL)
|
||||||
initialize_main_win ();
|
initialize_main_win ();
|
||||||
gtk_widget_show_all (main_win->window);
|
/* now we fill in the fields with the mi stuff. */
|
||||||
|
gtk_label_set_text (GTK_LABEL (main_win->mime_type), mi->mime_type);
|
||||||
|
gnome_icon_entry_set_icon (GNOME_ICON_ENTRY (main_win->icon_entry),
|
||||||
|
gnome_mime_get_value (mi->mime_type,
|
||||||
|
"icon-filename"));
|
||||||
|
|
||||||
|
/* we initialize everything */
|
||||||
|
if (mi->ext[0]) {
|
||||||
|
GString *extension;
|
||||||
|
extension = g_string_new (mi->ext_readable[0]);
|
||||||
|
if (mi->ext[1]) {
|
||||||
|
g_string_append (extension, ", ");
|
||||||
|
g_string_append (extension, (mi->ext_readable[1]));
|
||||||
|
}
|
||||||
|
gtk_label_set_text (GTK_LABEL (main_win->ext_label),
|
||||||
|
extension->str);
|
||||||
|
g_string_free (extension, TRUE);
|
||||||
|
} else if (mi->ext[1])
|
||||||
|
gtk_label_set_text (GTK_LABEL (main_win->ext_label),
|
||||||
|
mi->ext_readable[1]);
|
||||||
|
else
|
||||||
|
gtk_label_set_text (GTK_LABEL (main_win->ext_label),
|
||||||
|
_("<No extention>"));
|
||||||
|
if (mi->regex_readable[0])
|
||||||
|
gtk_label_set_text (GTK_LABEL (main_win->regexp1_label),
|
||||||
|
mi->regex_readable[0]);
|
||||||
|
else
|
||||||
|
gtk_label_set_text (GTK_LABEL (main_win->regexp1_label),
|
||||||
|
_("<No Regular Expression>"));
|
||||||
|
if (mi->regex_readable[1])
|
||||||
|
gtk_label_set_text (GTK_LABEL (main_win->regexp2_label),
|
||||||
|
mi->regex_readable[1]);
|
||||||
|
else
|
||||||
|
gtk_label_set_text (GTK_LABEL (main_win->regexp2_label),
|
||||||
|
_("<No Regular Expression>"));
|
||||||
|
/* initialize the entries */
|
||||||
|
setup_entry ("open", main_win->open_entry, mi);
|
||||||
|
setup_entry ("view", main_win->view_entry, mi);
|
||||||
|
setup_entry ("edit", main_win->edit_entry, mi);
|
||||||
|
|
||||||
|
changing = FALSE;
|
||||||
|
|
||||||
|
gtk_widget_show_all (GNOME_DIALOG (main_win->window)->vbox);
|
||||||
|
if ((gnome_dialog_run (GNOME_DIALOG (main_win->window))) == 0) {
|
||||||
|
apply_changes (mi);
|
||||||
|
}
|
||||||
|
gtk_widget_hide (main_win->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,20 +11,17 @@
|
|||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "mime-data.h"
|
#include "mime-data.h"
|
||||||
|
#include "mime-info.h"
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
static void mime_fill_from_file (const char *filename);
|
static void mime_fill_from_file (const char *filename);
|
||||||
static void mime_load_from_dir (const char *mime_info_dir);
|
static void mime_load_from_dir (const char *mime_info_dir, gboolean system_dir);
|
||||||
static void add_to_key (char *mime_type, char *def);
|
static void add_to_key (char *mime_type, char *def);
|
||||||
static char *get_priority (char *def, int *priority);
|
static char *get_priority (char *def, int *priority);
|
||||||
|
|
||||||
|
|
||||||
/* Global variables */
|
/* Global variables */
|
||||||
static char *current_lang;
|
static char *current_lang;
|
||||||
/* Our original purpose for having
|
|
||||||
* the hash table seems to have dissappeared.
|
|
||||||
* Oh well... must-fix-later */
|
|
||||||
static GHashTable *mime_types = NULL;
|
static GHashTable *mime_types = NULL;
|
||||||
|
|
||||||
/* Initialization functions */
|
/* Initialization functions */
|
||||||
static char *
|
static char *
|
||||||
get_priority (char *def, int *priority)
|
get_priority (char *def, int *priority)
|
||||||
@ -63,6 +60,10 @@ add_to_key (char *mime_type, char *def)
|
|||||||
info->regex[1] = NULL;
|
info->regex[1] = NULL;
|
||||||
info->ext[0] = NULL;
|
info->ext[0] = NULL;
|
||||||
info->ext[1] = NULL;
|
info->ext[1] = NULL;
|
||||||
|
info->regex_readable[0] = NULL;
|
||||||
|
info->regex_readable[1] = NULL;
|
||||||
|
info->ext_readable[0] = NULL;
|
||||||
|
info->ext_readable[1] = NULL;
|
||||||
info->keys = gnome_mime_get_keys (mime_type);
|
info->keys = gnome_mime_get_keys (mime_type);
|
||||||
g_hash_table_insert (mime_types, mime_type, info);
|
g_hash_table_insert (mime_types, mime_type, info);
|
||||||
}
|
}
|
||||||
@ -76,8 +77,8 @@ add_to_key (char *mime_type, char *def)
|
|||||||
used = 0;
|
used = 0;
|
||||||
|
|
||||||
while ((ext = strtok_r (s, " \t\n\r,", &tokp)) != NULL){
|
while ((ext = strtok_r (s, " \t\n\r,", &tokp)) != NULL){
|
||||||
|
/* FIXME: We really need to check for duplicates before entering this. */
|
||||||
info->ext[priority] = g_list_prepend (info->ext[priority], ext);
|
info->ext[priority] = g_list_prepend (info->ext[priority], ext);
|
||||||
g_print ("inserting:%s:\n", ext);
|
|
||||||
used = 1;
|
used = 1;
|
||||||
s = NULL;
|
s = NULL;
|
||||||
}
|
}
|
||||||
@ -99,8 +100,11 @@ add_to_key (char *mime_type, char *def)
|
|||||||
return;
|
return;
|
||||||
if (regcomp (regex, def, REG_EXTENDED | REG_NOSUB))
|
if (regcomp (regex, def, REG_EXTENDED | REG_NOSUB))
|
||||||
g_free (regex);
|
g_free (regex);
|
||||||
else
|
else {
|
||||||
info->regex[priority] = regex;
|
info->regex[priority] = regex;
|
||||||
|
g_free (info->regex_readable[priority]);
|
||||||
|
info->regex_readable[priority] = g_strdup (def);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void
|
static void
|
||||||
@ -163,18 +167,22 @@ mime_fill_from_file (const char *filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mime_load_from_dir (const char *mime_info_dir)
|
mime_load_from_dir (const char *mime_info_dir, gboolean system_dir)
|
||||||
{
|
{
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *dent;
|
struct dirent *dent;
|
||||||
const int extlen = sizeof (".mime") - 1;
|
const int extlen = sizeof (".mime") - 1;
|
||||||
|
char *filename;
|
||||||
|
|
||||||
dir = opendir (mime_info_dir);
|
dir = opendir (mime_info_dir);
|
||||||
if (!dir)
|
if (!dir)
|
||||||
return;
|
return;
|
||||||
|
if (system_dir) {
|
||||||
|
filename = g_concat_dir_and_file (mime_info_dir, "gnome.mime");
|
||||||
|
mime_fill_from_file (filename);
|
||||||
|
g_free (filename);
|
||||||
|
}
|
||||||
while ((dent = readdir (dir)) != NULL){
|
while ((dent = readdir (dir)) != NULL){
|
||||||
char *filename;
|
|
||||||
|
|
||||||
int len = strlen (dent->d_name);
|
int len = strlen (dent->d_name);
|
||||||
|
|
||||||
@ -183,41 +191,69 @@ mime_load_from_dir (const char *mime_info_dir)
|
|||||||
|
|
||||||
if (strcmp (dent->d_name + len - extlen, ".mime"))
|
if (strcmp (dent->d_name + len - extlen, ".mime"))
|
||||||
continue;
|
continue;
|
||||||
|
if (system_dir && !strcmp (dent->d_name, "gnome.mime"))
|
||||||
|
continue;
|
||||||
|
if (!system_dir && !strcmp (dent->d_name, "user.mime"))
|
||||||
|
continue;
|
||||||
|
|
||||||
filename = g_concat_dir_and_file (mime_info_dir, dent->d_name);
|
filename = g_concat_dir_and_file (mime_info_dir, dent->d_name);
|
||||||
mime_fill_from_file (filename);
|
mime_fill_from_file (filename);
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
}
|
}
|
||||||
|
if (!system_dir) {
|
||||||
|
filename = g_concat_dir_and_file (mime_info_dir, "user.mime");
|
||||||
|
mime_fill_from_file (filename);
|
||||||
|
g_free (filename);
|
||||||
|
}
|
||||||
closedir (dir);
|
closedir (dir);
|
||||||
}
|
}
|
||||||
static void
|
static void
|
||||||
add_mime_vals_to_clist (gchar *mime_type, gpointer mi, gpointer clist)
|
add_mime_vals_to_clist (gchar *mime_type, gpointer mi, gpointer clist)
|
||||||
{
|
{
|
||||||
|
/* we also finalize the MimeInfo structure here, now that we're done
|
||||||
|
* loading it */
|
||||||
static gchar *text[2];
|
static gchar *text[2];
|
||||||
GList *list;
|
GList *list;
|
||||||
GString *extension;
|
GString *extension;
|
||||||
gint row;
|
gint row;
|
||||||
|
|
||||||
extension = g_string_new ("");
|
extension = g_string_new ("");
|
||||||
|
|
||||||
for (list = ((MimeInfo *) mi)->ext[0];list; list=list->next) {
|
for (list = ((MimeInfo *) mi)->ext[0];list; list=list->next) {
|
||||||
g_string_append (extension, (gchar *) list->data);
|
g_string_append (extension, (gchar *) list->data);
|
||||||
if (list->next != NULL)
|
if (list->next != NULL)
|
||||||
g_string_append (extension, ", ");
|
g_string_append (extension, ", ");
|
||||||
else if (((MimeInfo *) mi)->ext[1] != NULL)
|
|
||||||
g_string_append (extension, ", ");
|
|
||||||
}
|
}
|
||||||
|
((MimeInfo *) mi)->ext_readable[0] = extension->str;
|
||||||
|
g_string_free (extension, FALSE);
|
||||||
|
|
||||||
|
extension = g_string_new ("");
|
||||||
for (list = ((MimeInfo *) mi)->ext[1];list; list=list->next) {
|
for (list = ((MimeInfo *) mi)->ext[1];list; list=list->next) {
|
||||||
g_string_append (extension, (gchar *) list->data);
|
g_string_append (extension, (gchar *) list->data);
|
||||||
if (list->next)
|
if (list->next)
|
||||||
g_string_append (extension, ", ");
|
g_string_append (extension, ", ");
|
||||||
}
|
}
|
||||||
|
((MimeInfo *) mi)->ext_readable[1] = extension->str;
|
||||||
|
g_string_free (extension, FALSE);
|
||||||
|
|
||||||
|
if (((MimeInfo *) mi)->ext[0]) {
|
||||||
|
extension = g_string_new ((((MimeInfo *) mi)->ext_readable[0]));
|
||||||
|
if (((MimeInfo *) mi)->ext[1]) {
|
||||||
|
g_string_append (extension, ", ");
|
||||||
|
g_string_append (extension, (((MimeInfo *) mi)->ext_readable[1]));
|
||||||
|
}
|
||||||
|
} else if (((MimeInfo *) mi)->ext[1])
|
||||||
|
extension = g_string_new ((((MimeInfo *) mi)->ext_readable[1]));
|
||||||
|
else
|
||||||
|
extension = g_string_new ("");
|
||||||
|
|
||||||
text[0] = ((MimeInfo *) mi)->mime_type;
|
text[0] = ((MimeInfo *) mi)->mime_type;
|
||||||
text[1] = extension->str;
|
text[1] = extension->str;
|
||||||
|
|
||||||
row = gtk_clist_insert (GTK_CLIST (clist), 1, text);
|
row = gtk_clist_insert (GTK_CLIST (clist), 1, text);
|
||||||
gtk_clist_set_row_data (GTK_CLIST (clist), row, mi);
|
gtk_clist_set_row_data (GTK_CLIST (clist), row, mi);
|
||||||
g_string_free (extension, TRUE);
|
g_string_free (extension, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
selected_row_callback (GtkWidget *widget, gint row, gint column, GdkEvent *event, gpointer data)
|
selected_row_callback (GtkWidget *widget, gint row, gint column, GdkEvent *event, gpointer data)
|
||||||
{
|
{
|
||||||
@ -273,11 +309,11 @@ init_mime_type ()
|
|||||||
mime_types = g_hash_table_new (g_str_hash, g_str_equal);
|
mime_types = g_hash_table_new (g_str_hash, g_str_equal);
|
||||||
|
|
||||||
mime_info_dir = gnome_unconditional_datadir_file ("mime-info");
|
mime_info_dir = gnome_unconditional_datadir_file ("mime-info");
|
||||||
mime_load_from_dir (mime_info_dir);
|
mime_load_from_dir (mime_info_dir, TRUE);
|
||||||
g_free (mime_info_dir);
|
g_free (mime_info_dir);
|
||||||
|
|
||||||
mime_info_dir = g_concat_dir_and_file (gnome_util_user_home (), ".gnome/mime-info");
|
mime_info_dir = g_concat_dir_and_file (gnome_util_user_home (), ".gnome/mime-info");
|
||||||
mime_load_from_dir (mime_info_dir);
|
mime_load_from_dir (mime_info_dir, FALSE);
|
||||||
g_free (mime_info_dir);
|
g_free (mime_info_dir);
|
||||||
|
init_mime_info ();
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@ typedef struct {
|
|||||||
char *mime_type;
|
char *mime_type;
|
||||||
regex_t *regex[2];
|
regex_t *regex[2];
|
||||||
GList *ext[2];
|
GList *ext[2];
|
||||||
|
char *ext_readable[2];
|
||||||
|
char *regex_readable[2];
|
||||||
char *file_name;
|
char *file_name;
|
||||||
GList *keys;
|
GList *keys;
|
||||||
} MimeInfo;
|
} MimeInfo;
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "mime-data.h"
|
#include "mime-data.h"
|
||||||
|
#include "mime-info.h"
|
||||||
|
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
static void try_callback ();
|
static void try_callback ();
|
||||||
@ -18,11 +19,13 @@ static void revert_callback ();
|
|||||||
static void ok_callback ();
|
static void ok_callback ();
|
||||||
static void cancel_callback ();
|
static void cancel_callback ();
|
||||||
static void help_callback ();
|
static void help_callback ();
|
||||||
|
GtkWidget *capplet;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
try_callback ()
|
try_callback ()
|
||||||
{
|
{
|
||||||
|
g_print ("testing...\n");
|
||||||
|
write_user_keys ();
|
||||||
}
|
}
|
||||||
static void
|
static void
|
||||||
revert_callback ()
|
revert_callback ()
|
||||||
@ -47,7 +50,6 @@ help_callback ()
|
|||||||
static void
|
static void
|
||||||
init_mime_capplet ()
|
init_mime_capplet ()
|
||||||
{
|
{
|
||||||
GtkWidget *capplet;
|
|
||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
GtkWidget *hbox;
|
GtkWidget *hbox;
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
|
Loading…
Reference in New Issue
Block a user