mirror of
https://github.com/MidnightCommander/mc
synced 2025-02-24 11:14:22 +03:00
1999-02-05 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gpopup2.c (popup_handle_properties): Update the URL information on change. * gnome-file-property-dialog.c (generate_actions_box): Fix memory leak. (create_general_properties): Fix memory leak. * gdesktop.c (desktop_icon_update_url): New function. Updates any changes done to the url/caption on the file-property-dialog. * gnome-file-property-dialog.c (gnome_file_property_dialog_finalize): Release all of the resources allocated (metadata routines alwayre return an allocated block of memory). Add support for changing the url an icon points to and the caption. * gdnd.c (drop_url_on_directory): Better set the icon-filename metadata entry instead of hard coding it.
This commit is contained in:
parent
26af8110ec
commit
dcd005a0ca
@ -1,10 +1,21 @@
|
||||
1999-02-05 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
|
||||
* gpopup2.c (popup_handle_properties): Update the URL information
|
||||
on change.
|
||||
|
||||
* gnome-file-property-dialog.c (generate_actions_box): Fix memory leak.
|
||||
(create_general_properties): Fix memory leak.
|
||||
|
||||
* gdesktop.c (desktop_icon_update_url): New function. Updates any
|
||||
changes done to the url/caption on the file-property-dialog.
|
||||
|
||||
* gnome-file-property-dialog.c
|
||||
(gnome_file_property_dialog_finalize): Release all of the
|
||||
resources allocated (metadata routines alwayre return an allocated
|
||||
block of memory).
|
||||
|
||||
Add support for changing the url an icon points to and the caption.
|
||||
|
||||
* gdnd.c (drop_url_on_directory): Better set the icon-filename
|
||||
metadata entry instead of hard coding it.
|
||||
|
||||
|
@ -123,7 +123,9 @@ static int click_dragging;
|
||||
|
||||
|
||||
static DesktopIconInfo *desktop_icon_info_new (char *filename, char *url,
|
||||
int user_pos, int auto_pos, int xpos, int ypos);
|
||||
char *caption,
|
||||
int user_pos, int auto_pos,
|
||||
int xpos, int ypos);
|
||||
|
||||
|
||||
/* Looks for a free slot in the layout_slots array and returns the coordinates that coorespond to
|
||||
@ -321,6 +323,7 @@ icon_exists_in_list (GList *list, char *filename)
|
||||
typedef struct {
|
||||
char *filename;
|
||||
char *url;
|
||||
char *caption;
|
||||
} file_and_url_t;
|
||||
|
||||
/*
|
||||
@ -339,7 +342,7 @@ reload_desktop_icons (int user_pos, int xpos, int ypos)
|
||||
DesktopIconInfo *dii;
|
||||
GSList *need_position_list, *sl;
|
||||
GList *all_icons, *l;
|
||||
char *desktop_url;
|
||||
char *desktop_url, *caption;
|
||||
|
||||
dir = mc_opendir (desktop_directory);
|
||||
if (!dir) {
|
||||
@ -397,23 +400,31 @@ reload_desktop_icons (int user_pos, int xpos, int ypos)
|
||||
if (gnome_metadata_get (full_name, "desktop-url", &size, &desktop_url) != 0)
|
||||
desktop_url = NULL;
|
||||
|
||||
caption = NULL;
|
||||
gnome_metadata_get (full_name, "icon-caption", &size, &caption);
|
||||
|
||||
if (have_pos) {
|
||||
dii = desktop_icon_info_new (dirent->d_name, desktop_url, FALSE, FALSE, x, y);
|
||||
dii = desktop_icon_info_new (dirent->d_name, desktop_url, caption, FALSE, FALSE, x, y);
|
||||
gtk_widget_show (dii->dicon);
|
||||
|
||||
g_free (full_name);
|
||||
} else {
|
||||
file_and_url_t *fau;
|
||||
|
||||
fau = g_new (file_and_url_t, 1);
|
||||
fau = g_new0 (file_and_url_t, 1);
|
||||
fau->filename = g_strdup (dirent->d_name);
|
||||
fau->url = g_strdup (desktop_url);
|
||||
|
||||
if (desktop_url)
|
||||
fau->url = g_strdup (desktop_url);
|
||||
if (caption)
|
||||
fau->caption = g_strdup (caption);
|
||||
need_position_list = g_slist_prepend (need_position_list, fau);
|
||||
}
|
||||
|
||||
if (desktop_url)
|
||||
g_free (desktop_url);
|
||||
|
||||
if (caption)
|
||||
g_free (caption);
|
||||
}
|
||||
|
||||
mc_closedir (dir);
|
||||
@ -444,10 +455,13 @@ reload_desktop_icons (int user_pos, int xpos, int ypos)
|
||||
for (sl = need_position_list; sl; sl = sl->next) {
|
||||
file_and_url_t *fau = sl->data;
|
||||
|
||||
dii = desktop_icon_info_new (fau->filename, fau->url, user_pos, TRUE, xpos, ypos);
|
||||
dii = desktop_icon_info_new (fau->filename, fau->url, fau->caption, user_pos, TRUE, xpos, ypos);
|
||||
gtk_widget_show (dii->dicon);
|
||||
|
||||
g_free (fau->url);
|
||||
if (fau->url)
|
||||
g_free (fau->url);
|
||||
if (fau->caption)
|
||||
g_free (fau->caption);
|
||||
g_free (fau->filename);
|
||||
g_free (fau);
|
||||
}
|
||||
@ -683,7 +697,7 @@ text_changed_url (GnomeIconTextItem *iti, gpointer data)
|
||||
|
||||
fullname = g_concat_dir_and_file (desktop_directory, dii->filename);
|
||||
new_text = gnome_icon_text_item_get_text (iti);
|
||||
gnome_metadata_set (fullname, "desktop-url", strlen (new_text) + 1, new_text);
|
||||
gnome_metadata_set (fullname, "icon-caption", strlen (new_text) + 1, new_text);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -1338,14 +1352,13 @@ setup_icon_dnd_dest (DesktopIconInfo *dii)
|
||||
* desktop directory. It does not show the icon.
|
||||
*/
|
||||
static DesktopIconInfo *
|
||||
desktop_icon_info_new (char *filename, char *url, int user_pos, int auto_pos, int xpos, int ypos)
|
||||
desktop_icon_info_new (char *filename, char *url, char *caption, int user_pos, int auto_pos, int xpos, int ypos)
|
||||
{
|
||||
DesktopIconInfo *dii;
|
||||
file_entry *fe;
|
||||
char *full_name;
|
||||
GdkImlibImage *icon_im;
|
||||
GtkSignalFunc text_changed_func;
|
||||
char *caption;
|
||||
|
||||
/* Create the icon structure */
|
||||
|
||||
@ -1359,7 +1372,8 @@ desktop_icon_info_new (char *filename, char *url, int user_pos, int auto_pos, in
|
||||
|
||||
if (url){
|
||||
dii->url = g_strdup (url);
|
||||
caption = url;
|
||||
if (!caption)
|
||||
caption = url;
|
||||
} else {
|
||||
dii->url = NULL;
|
||||
caption = filename;
|
||||
@ -1428,6 +1442,37 @@ desktop_icon_info_new (char *filename, char *url, int user_pos, int auto_pos, in
|
||||
return dii;
|
||||
}
|
||||
|
||||
/**
|
||||
* desktop_icon_update_url:
|
||||
* @dii: the desktop icon
|
||||
*
|
||||
* Loads from the metadata updated versions of the caption
|
||||
* and the url
|
||||
*/
|
||||
void
|
||||
desktop_icon_update_url (DesktopIconInfo *dii)
|
||||
{
|
||||
char *fullname = g_concat_dir_and_file (desktop_directory, dii->filename);
|
||||
char *caption = NULL;
|
||||
char *url = NULL;
|
||||
int size;
|
||||
|
||||
gnome_metadata_get (fullname, "icon-caption", &size, &caption);
|
||||
if (caption){
|
||||
desktop_icon_set_text (DESKTOP_ICON (dii->dicon), caption);
|
||||
g_free (caption);
|
||||
}
|
||||
|
||||
gnome_metadata_get (fullname, "desktop-url", &size, &url);
|
||||
if (url){
|
||||
if (dii->url)
|
||||
g_free (dii->url);
|
||||
dii->url = url;
|
||||
}
|
||||
|
||||
g_free (fullname);
|
||||
}
|
||||
|
||||
/**
|
||||
* desktop_icon_info_destroy:
|
||||
* @dii: The desktop icon to destroy
|
||||
@ -2239,3 +2284,4 @@ desktop_destroy (void)
|
||||
gtk_widget_destroy (proxy_invisible);
|
||||
XDeleteProperty (GDK_DISPLAY (), GDK_ROOT_WINDOW (), gdk_atom_intern ("XdndProxy", FALSE));
|
||||
}
|
||||
|
||||
|
@ -122,6 +122,8 @@ gnome_file_property_dialog_finalize (GtkObject *object)
|
||||
g_free (gfpd->icon_filename);
|
||||
if (gfpd->desktop_url)
|
||||
g_free (gfpd->desktop_url);
|
||||
if (gfpd->caption)
|
||||
g_free (gfpd->caption);
|
||||
|
||||
(* GTK_OBJECT_CLASS (parent_class)->finalize) (object);
|
||||
}
|
||||
@ -153,6 +155,7 @@ create_general_properties (GnomeFilePropertyDialog *fp_dlg)
|
||||
strrchr (direc, '/')[0] = '\0';
|
||||
fe = file_entry_from_file (fp_dlg->file_name);
|
||||
fp_dlg->im = gicon_get_icon_for_file_speed (direc, fe, FALSE);
|
||||
file_entry_free (fe);
|
||||
g_free (direc);
|
||||
icon = gnome_pixmap_new_from_imlib (fp_dlg->im);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), icon, FALSE, FALSE, 0);
|
||||
@ -290,9 +293,22 @@ create_url_properties (GnomeFilePropertyDialog *fp_dlg)
|
||||
|
||||
table = gtk_table_new (0, 0, 0);
|
||||
|
||||
label = gtk_label_new (_("URL"));
|
||||
label = gtk_label_new (_("URL:"));
|
||||
gtk_table_attach (GTK_TABLE (table), label,
|
||||
1, 2, 1, 2, 0, 0, GNOME_PAD, GNOME_PAD);
|
||||
fp_dlg->desktop_entry = gtk_entry_new ();
|
||||
gtk_table_attach (GTK_TABLE (table), fp_dlg->desktop_entry,
|
||||
2, 3, 1, 2, GTK_FILL | GTK_EXPAND, 0, GNOME_PAD, GNOME_PAD);
|
||||
|
||||
label = gtk_label_new (_("Caption:"));
|
||||
gtk_table_attach (GTK_TABLE (table), label,
|
||||
1, 2, 2, 3, 0, 0, GNOME_PAD, GNOME_PAD);
|
||||
fp_dlg->caption_entry = gtk_entry_new ();
|
||||
gtk_table_attach (GTK_TABLE (table), fp_dlg->caption_entry,
|
||||
2, 3, 2, 3, GTK_FILL | GTK_EXPAND, 0, GNOME_PAD, GNOME_PAD);
|
||||
|
||||
|
||||
gtk_widget_show_all (table);
|
||||
return table;
|
||||
}
|
||||
|
||||
/* Settings Pane */
|
||||
@ -355,8 +371,10 @@ switch_metadata_box (GnomeFilePropertyDialog *fp_dlg)
|
||||
|
||||
if (fp_dlg->desktop_url){
|
||||
gtk_entry_set_text (GTK_ENTRY (fp_dlg->desktop_entry), fp_dlg->desktop_url);
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (fp_dlg->caption_entry), fp_dlg->caption);
|
||||
}
|
||||
|
||||
|
||||
if (fp_dlg->executable) {
|
||||
gtk_label_set_text (GTK_LABEL (fp_dlg->prop1_label), "Drop Action");
|
||||
gtk_label_set_text (GTK_LABEL (GTK_BIN (fp_dlg->prop1_cbox)->child), "Use default Drop Action options");
|
||||
@ -411,10 +429,15 @@ generate_icon_sel (GnomeFilePropertyDialog *fp_dlg)
|
||||
|
||||
retval = gnome_icon_entry_new ("gmc_file_icon", "Select an Icon");
|
||||
icon = gicon_image_to_name (fp_dlg->im);
|
||||
if (!icon || !icon[0])
|
||||
if (!icon)
|
||||
return retval;
|
||||
g_print ("icon:%s:\n",icon);
|
||||
|
||||
if (!icon[0]){
|
||||
g_free (icon);
|
||||
return retval;
|
||||
}
|
||||
gnome_icon_entry_set_icon (GNOME_ICON_ENTRY (retval), icon);
|
||||
g_free (icon);
|
||||
return retval;
|
||||
}
|
||||
static GtkWidget *
|
||||
@ -912,7 +935,7 @@ static void
|
||||
init_metadata (GnomeFilePropertyDialog *fp_dlg)
|
||||
{
|
||||
gint size;
|
||||
gchar *mime_type;
|
||||
char *mime_type;
|
||||
gchar link_name[60];
|
||||
gint n;
|
||||
gchar *file_name, *desktop_url;
|
||||
@ -934,7 +957,18 @@ init_metadata (GnomeFilePropertyDialog *fp_dlg)
|
||||
}
|
||||
}
|
||||
|
||||
mime_type = gnome_mime_type_or_default (file_name, NULL);
|
||||
if (gnome_metadata_get (fp_dlg->file_name, "desktop-url", &size, &desktop_url) == 0)
|
||||
fp_dlg->desktop_url = desktop_url;
|
||||
else
|
||||
fp_dlg->desktop_url = NULL;
|
||||
|
||||
if (gnome_metadata_get (fp_dlg->file_name, "icon-caption", &size, &fp_dlg->caption))
|
||||
fp_dlg->caption = g_strdup (desktop_url);
|
||||
|
||||
/*
|
||||
* Mime type.
|
||||
*/
|
||||
mime_type = (char *) gnome_mime_type_or_default (file_name, NULL);
|
||||
if (!mime_type)
|
||||
return;
|
||||
fp_dlg->mime_fm_open = gnome_mime_get_value (mime_type, "fm-open");
|
||||
@ -950,11 +984,6 @@ init_metadata (GnomeFilePropertyDialog *fp_dlg)
|
||||
if (fp_dlg->icon_filename)
|
||||
g_print ("we have an icon-filename:%s:\n", fp_dlg->icon_filename);
|
||||
|
||||
if (gnome_metadata_get (fp_dlg->file_name, "desktop-url", &size, &desktop_url) == 0)
|
||||
fp_dlg->desktop_url = desktop_url;
|
||||
else
|
||||
fp_dlg->desktop_url = NULL;
|
||||
|
||||
}
|
||||
GtkWidget *
|
||||
gnome_file_property_dialog_new (gchar *file_name, gboolean can_set_icon)
|
||||
@ -1200,6 +1229,17 @@ apply_metadata_change (GnomeFilePropertyDialog *fpd)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fpd->desktop_url){
|
||||
char *new_desktop_url = gtk_entry_get_text (GTK_ENTRY (fpd->desktop_entry));
|
||||
char *new_caption = gtk_entry_get_text (GTK_ENTRY (fpd->caption_entry));
|
||||
|
||||
gnome_metadata_set (fpd->file_name, "desktop-url",
|
||||
strlen (new_desktop_url)+1, new_desktop_url);
|
||||
gnome_metadata_set (fpd->file_name, "icon-caption",
|
||||
strlen (new_caption)+1, new_caption);
|
||||
}
|
||||
|
||||
if (!fpd->can_set_icon)
|
||||
return 1;
|
||||
/* And finally, we set the metadata on the icon filename */
|
||||
@ -1211,8 +1251,14 @@ apply_metadata_change (GnomeFilePropertyDialog *fpd)
|
||||
* default to the basic icon. We prolly should check that this is a valid
|
||||
* file here, but I'm too tired to do it now -- jrb */
|
||||
gnome_metadata_set (fpd->file_name, "icon-filename", strlen (text) + 1, text);
|
||||
else
|
||||
gnome_metadata_remove (fpd->file_name, "icon-filename");
|
||||
else {
|
||||
/* If text is equal to icon_name it means the user did not
|
||||
* touch it, not that he did remove it
|
||||
*/
|
||||
/*
|
||||
gnome_metadata_remove (fpd->file_name, "icon-filename");
|
||||
*/
|
||||
}
|
||||
}
|
||||
/* I suppose we should only do this if we know there's been a change -- I'll try to figure it
|
||||
* out later if it turns out to be important. */
|
||||
|
@ -69,6 +69,7 @@ struct _GnomeFilePropertyDialog
|
||||
GtkWidget *prop2_label, *prop2_entry, *prop2_cbox, *prop2_hline;
|
||||
GtkWidget *button;
|
||||
GtkWidget *desktop_entry;
|
||||
GtkWidget *caption_entry;
|
||||
|
||||
gchar *fm_open;
|
||||
gchar *fm_view;
|
||||
@ -80,6 +81,8 @@ struct _GnomeFilePropertyDialog
|
||||
gchar *mime_edit;
|
||||
gchar *icon_filename;
|
||||
gchar *desktop_url;
|
||||
gchar *caption;
|
||||
|
||||
gboolean can_set_icon;
|
||||
GdkImlibImage *im;
|
||||
|
||||
|
@ -94,6 +94,13 @@ dicon_properties (GtkWidget *widget, DesktopIconInfo *dii)
|
||||
gtk_widget_show_all (dlg);
|
||||
if (gnome_dialog_run (GNOME_DIALOG (dlg)) == 0)
|
||||
retval = gnome_file_property_dialog_make_changes (GNOME_FILE_PROPERTY_DIALOG (dlg));
|
||||
|
||||
/*
|
||||
* Apply: desktop icon name change and url change
|
||||
*/
|
||||
if (dii->url)
|
||||
desktop_icon_update_url (dii);
|
||||
|
||||
gtk_widget_destroy (dlg);
|
||||
g_free(path);
|
||||
if (retval)
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include <config.h>
|
||||
#include <gnome.h>
|
||||
#include "../vfs/vfs.h"
|
||||
#include "global.h"
|
||||
#include "panel.h"
|
||||
#include "cmd.h"
|
||||
#include "dialog.h"
|
||||
@ -412,6 +411,7 @@ static void popup_handle_properties (GtkWidget *widget, WPanel *panel)
|
||||
gnome_dialog_set_parent (GNOME_DIALOG (dlg), GTK_WINDOW (gtk_widget_get_toplevel (panel->ministatus)));
|
||||
if (gnome_dialog_run (GNOME_DIALOG (dlg)) == 0)
|
||||
retval = gnome_file_property_dialog_make_changes (GNOME_FILE_PROPERTY_DIALOG (dlg));
|
||||
|
||||
gtk_widget_destroy (dlg);
|
||||
g_free (full_name);
|
||||
if (retval)
|
||||
|
Loading…
x
Reference in New Issue
Block a user