1999-02-24 Miguel de Icaza <miguel@nuclecu.unam.mx>

* gicon.c (gicon_get_filename_for_icon): Return const char *, this
	tells the user of this routine "you better not touch or free this
	you dofus".

	* gnome-file-property-dialog.c (apply_metadata_change): Always set
	the name of the icon to the new value, as the entry will always
	match the imlib image anyways (due to the fixes I did to const
	correctness).
	(generate_icon_sel): Do not free the value.  We do not own this
	return value.

	* gdesktop.c (is_mountable): NULL terminate string returned from
	readlink.  Yes guys, readlink does not NULL terminate things.
	(do_mount_umount): ditto.

	* gnome-file-property-dialog.c (init_metadata): ditto
This commit is contained in:
Miguel de Icaza 1999-02-25 04:08:43 +00:00
parent 0ca42b97f0
commit a57560f5dd
9 changed files with 51 additions and 34 deletions

View File

@ -1,3 +1,22 @@
1999-02-24 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gicon.c (gicon_get_filename_for_icon): Return const char *, this
tells the user of this routine "you better not touch or free this
you dofus".
* gnome-file-property-dialog.c (apply_metadata_change): Always set
the name of the icon to the new value, as the entry will always
match the imlib image anyways (due to the fixes I did to const
correctness).
(generate_icon_sel): Do not free the value. We do not own this
return value.
* gdesktop.c (is_mountable): NULL terminate string returned from
readlink. Yes guys, readlink does not NULL terminate things.
(do_mount_umount): ditto.
* gnome-file-property-dialog.c (init_metadata): ditto
Tue Feb 23 17:41:45 1999 George Lebl <jirka@5z.com>
* gmain.c: set the restart property of the gnome client to

View File

@ -914,7 +914,8 @@ is_mountable (char *filename, file_entry *fe, int *is_mounted, char **point)
char buffer [128], *p;
umode_t mode;
struct stat s;
int len;
if (point)
*point = NULL;
@ -928,9 +929,11 @@ is_mountable (char *filename, file_entry *fe, int *is_mounted, char **point)
if (!S_ISBLK (mode))
return FALSE;
if (readlink (filename, buffer, sizeof (buffer)) == -1)
len = readlink (filename, buffer, sizeof (buffer));
if (len == -1)
return FALSE;
buffer [len] = 0;
p = is_block_device_mountable (buffer);
if (!p)
return FALSE;
@ -952,7 +955,8 @@ do_mount_umount (char *filename, gboolean is_mount)
static char *umount_command;
char *op;
char buffer [128];
int count;
if (is_mount){
if (!mount_command)
mount_command = find_command (mount_known_locations);
@ -963,8 +967,10 @@ do_mount_umount (char *filename, gboolean is_mount)
op = umount_command;
}
if (readlink (filename, buffer, sizeof (buffer)) == -1)
count = readlink (filename, buffer, sizeof (buffer));
if (count == -1)
return FALSE;
buffer [count] = 0;
if (op){
char *command;

View File

@ -130,7 +130,7 @@ get_icon_set (const char *filename)
if (iset)
return iset;
im = gdk_imlib_load_image (filename);
im = gdk_imlib_load_image ((char *) filename);
if (!im)
return NULL;
@ -141,7 +141,7 @@ get_icon_set (const char *filename)
/* Insert the icon information into the hash tables */
g_hash_table_insert (name_hash, filename, iset);
g_hash_table_insert (name_hash, (char *) filename, iset);
g_hash_table_insert (image_hash, iset->plain, iset);
return iset;
@ -436,7 +436,7 @@ gicon_get_icon_for_file (char *directory, file_entry *fe, gboolean do_quick)
*
* Return value: The filename that contains the icon for the specified image.
**/
char *
const char *
gicon_get_filename_for_icon (GdkImlibImage *image)
{
IconSet *iset;

View File

@ -17,7 +17,7 @@
void gicon_init (void);
GdkImlibImage *gicon_get_icon_for_file (char *directory, file_entry *fe, gboolean do_quick);
char *gicon_get_filename_for_icon (GdkImlibImage *image);
const char *gicon_get_filename_for_icon (GdkImlibImage *image);
#endif

View File

@ -64,6 +64,7 @@ void free (void *ptr);
#endif
#ifdef MOUNTED_VMOUNT /* AIX. */
#include <stdio.h>
#include <fshelp.h>
#include <sys/vfs.h>
#endif

View File

@ -211,6 +211,7 @@ create_general_properties (GnomeFilePropertyDialog *fp_dlg)
if (n < 0)
label = gtk_label_new (_("Target Name: INVALID LINK"));
else {
buf [n] = 0;
gen_string = g_strconcat (_("Target Name: "), buf, NULL);
label = gtk_label_new (gen_string);
g_free (gen_string);
@ -433,7 +434,7 @@ static GtkWidget *
generate_icon_sel (GnomeFilePropertyDialog *fp_dlg)
{
GtkWidget *retval;
gchar *icon;
const gchar *icon;
retval = gnome_icon_entry_new ("gmc_file_icon", "Select an Icon");
icon = gicon_get_filename_for_icon (fp_dlg->im);
@ -441,11 +442,9 @@ generate_icon_sel (GnomeFilePropertyDialog *fp_dlg)
return retval;
if (!icon[0]){
g_free (icon);
return retval;
}
gnome_icon_entry_set_icon (GNOME_ICON_ENTRY (retval), icon);
g_free (icon);
return retval;
}
@ -962,8 +961,10 @@ init_metadata (GnomeFilePropertyDialog *fp_dlg)
file_name = fp_dlg->file_name;
if (S_ISLNK (fp_dlg->st.st_mode)) {
n = mc_readlink (fp_dlg->file_name, link_name, MC_MAXPATHLEN);
if (n > 0)
if (n > 0){
link_name [n] = 0;
file_name = link_name;
}
}
if (gnome_metadata_get (fp_dlg->file_name, "desktop-url", &size, &desktop_url) == 0)
@ -1281,22 +1282,9 @@ apply_metadata_change (GnomeFilePropertyDialog *fpd)
/* And finally, we set the metadata on the icon filename */
text = gnome_icon_entry_get_filename (GNOME_ICON_ENTRY (fpd->button));
/*gtk_entry_get_text (GTK_ENTRY (gnome_icon_entry_gtk_entry (GNOME_ICON_ENTRY (fpd->button))));*/
icon_name = gicon_get_filename_for_icon (fpd->im);
if (text) {
if (strcmp (text, icon_name))
/* FIXME: We make a big assumption here. If the file doesn't exist, it will
* 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 {
/* 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");
*/
}
gnome_metadata_set (fpd->file_name, "icon-filename", strlen (text) + 1, text);
g_free (text);
}
/* I suppose we should only do this if we know there's been a change -- I'll try to figure it

View File

@ -94,6 +94,7 @@ item_properties (GtkWidget *parent, char *fname, DesktopIconInfo *dii)
file_entry *fe;
char *dirname;
char *p;
const char *ifile;
p = strrchr (fname, PATH_SEP);
g_assert (p != NULL);
@ -103,9 +104,11 @@ item_properties (GtkWidget *parent, char *fname, DesktopIconInfo *dii)
icon = gicon_get_icon_for_file (dirname, fe, FALSE);
g_free (dirname);
file_entry_free (fe);
icon_filename = gicon_get_filename_for_icon (icon);
if (icon_filename == NULL)
ifile = gicon_get_filename_for_icon (icon);
if (ifile == NULL)
icon_filename = g_strdup (ICONDIR "i-regular.png");
else
icon_filename = g_strdup (ifile);
gene = gprop_general_new (fname, icon_filename);

View File

@ -37,7 +37,7 @@ free_stuff (GtkWidget *widget, gpointer data)
/***** Filename *****/
GpropFilename *
gprop_filename_new (char *complete_filename, char *filename)
gprop_filename_new (const char *complete_filename, const char *filename)
{
GpropFilename *gp;
GtkWidget *frame;
@ -475,7 +475,7 @@ change_icon (GtkEntry *entry, GpropGeneral *gp)
}
GpropGeneral *
gprop_general_new (char *title, char *icon_filename)
gprop_general_new (const char *title, const char *icon_filename)
{
GpropGeneral *gp;
GtkWidget *frame;

View File

@ -22,7 +22,7 @@ typedef struct {
GtkWidget *filename;
} GpropFilename;
GpropFilename *gprop_filename_new (char *complete_filename, char *filename);
GpropFilename *gprop_filename_new (const char *complete_filename, const char *filename);
void gprop_filename_get_data (GpropFilename *gp, char **filename);
/***** Permissions *****/
@ -54,7 +54,7 @@ typedef struct {
GtkWidget *icon_pixmap;
} GpropGeneral;
GpropGeneral *gprop_general_new (char *title, char *icon_filename);
GpropGeneral *gprop_general_new (const char *title, const char *icon_filename);
void gprop_general_get_data (GpropGeneral *gp, char **title, char **icon_filename);
typedef struct {