Commit 1a7ac289 authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

Move to new GnomeDesktopItem api

2001-10-11  Alex Larsson  <alexl@redhat.com>

	* menu-fentry.c (fr_fill_dir, fr_read_dir,
	fr_check_and_reread):
	Move to new GnomeDesktopItem api

	* menu-fentry.h (struct DirRect):
	renams dentry* to ditem*

	* menu.c (edit_direntry, add_applet):
	Warn when running commented function.
	(show_item_menu):
	Update to new GnomeDesktopItem API

	* panel.c (drop_urilist):
	Warn when running commented function.
parent b5919033
2001-10-11 Alex Larsson <alexl@redhat.com>
* menu-fentry.c (fr_fill_dir, fr_read_dir,
fr_check_and_reread):
Move to new GnomeDesktopItem api
* menu-fentry.h (struct DirRect):
renams dentry* to ditem*
* menu.c (edit_direntry, add_applet):
Warn when running commented function.
(show_item_menu):
Update to new GnomeDesktopItem API
* panel.c (drop_urilist):
Warn when running commented function.
2001-10-10 Alex Larsson <alexl@redhat.com>
* menu.c (add_drawers_from_dir):
......
......@@ -357,7 +357,6 @@ fr_free (FileRec *fr, gboolean free_fr)
static void
fr_fill_dir(FileRec *fr, int sublevels)
{
#ifdef FIXME
GSList *flist;
struct stat s;
DirRec *dr = (DirRec *)fr;
......@@ -429,22 +428,25 @@ fr_fill_dir(FileRec *fr, int sublevels)
tryexec_path = NULL;
ditem = gnome_desktop_item_load_unconditional (name);
if (ditem != NULL &&
ditem->tryexec != NULL) {
tryexec_path = gnome_is_program_in_path (ditem->tryexec);
if (tryexec_path == NULL) {
dr->tryexecs = g_slist_prepend (dr->tryexecs, ditem->tryexec);
ditem->tryexec = NULL;
gnome_desktop_item_free (ditem);
ditem = NULL;
ditem = gnome_desktop_item_new_from_file (name, GNOME_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS, NULL);
if (ditem != NULL) {
const char *tryexec;
tryexec = gnome_desktop_item_get_string (ditem, "TryExec");
if (tryexec != NULL) {
tryexec_path = gnome_is_program_in_path (tryexec);
if (tryexec_path == NULL) {
dr->tryexecs = g_slist_prepend (dr->tryexecs, g_strdup (tryexec));
gnome_desktop_item_unref (ditem);
ditem = NULL;
}
}
}
if (ditem != NULL) {
const char *type;
ffr = g_chunk_new0 (FileRec, file_chunk);
if (ditem->type != NULL &&
strcasecmp_no_locale (ditem->type,
"separator") == 0)
type = gnome_desktop_item_get_string (ditem, "Type");
if (type != NULL &&
strcasecmp_no_locale (type, "separator") == 0)
ffr->type = FILE_REC_SEP;
else
ffr->type = FILE_REC_FILE;
......@@ -453,15 +455,13 @@ fr_fill_dir(FileRec *fr, int sublevels)
ffr->mtime = s.st_mtime;
ffr->last_stat = curtime;
ffr->parent = dr;
ffr->icon = ditem->icon;
ditem->icon = NULL;
ffr->fullname = ditem->name;
ffr->comment = g_strdup (ditem->comment);
ditem->name = NULL;
ffr->icon = gnome_desktop_item_get_icon (ditem);
ffr->fullname = g_strdup (gnome_desktop_item_get_localestring (ditem, "Name"));
ffr->comment = g_strdup (gnome_desktop_item_get_localestring (ditem, "Comment"));
ffr->tryexec_path = tryexec_path;
ffr->goad_id =
get_applet_goad_id_from_ditem (ditem);
gnome_desktop_item_free (ditem);
gnome_desktop_item_unref (ditem);
dr->recs = g_slist_prepend (dr->recs, ffr);
} else {
......@@ -472,14 +472,12 @@ fr_fill_dir(FileRec *fr, int sublevels)
dr->recs = g_slist_reverse (dr->recs);
g_free (mergedir);
#endif
}
FileRec *
fr_read_dir (DirRec *dr, const char *mdir, struct stat *dstat,
struct stat *merge_dstat, int sublevels)
{
#ifdef FIXME
char *fname;
struct stat s;
FileRec *fr;
......@@ -538,17 +536,17 @@ fr_read_dir (DirRec *dr, const char *mdir, struct stat *dstat,
if (dr->ditemlast_stat >= curtime-STAT_EVERY ||
stat (fname, &s) != -1) {
GnomeDesktopItem *ditem;
ditem = gnome_desktop_item_load(fname);
ditem = gnome_desktop_item_new_from_file(fname,
GNOME_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS,
NULL);
if (ditem != NULL) {
g_free (fr->icon);
fr->icon = ditem->icon;
ditem->icon = NULL;
fr->icon = gnome_desktop_item_get_icon (ditem);
g_free (fr->fullname);
fr->fullname = ditem->name;
fr->fullname = g_strdup (gnome_desktop_item_get_localestring (ditem, "Name"));
g_free (fr->comment);
fr->comment = g_strdup (ditem->comment);
ditem->name = NULL;
gnome_desktop_item_free (ditem);
fr->comment = g_strdup (gnome_desktop_item_get_localestring (ditem, "Comment"));
gnome_desktop_item_unref (ditem);
} else {
g_free (fr->icon);
fr->icon = NULL;
......@@ -574,9 +572,6 @@ fr_read_dir (DirRec *dr, const char *mdir, struct stat *dstat,
fr_fill_dir (fr, sublevels);
return fr;
#else
return NULL;
#endif
}
......@@ -610,7 +605,6 @@ fr_replace (FileRec *fr)
FileRec *
fr_check_and_reread (FileRec *fr)
{
#ifdef FIXME
DirRec *dr = (DirRec *)fr;
FileRec *ret = fr;
time_t curtime;
......@@ -708,17 +702,15 @@ fr_check_and_reread (FileRec *fr)
}
if(ddr->ditemmtime != s.st_mtime) {
GnomeDesktopItem *ditem;
ditem = gnome_desktop_item_load(p);
ditem = gnome_desktop_item_new_from_file (p, GNOME_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS, NULL);
if(ditem) {
g_free(ffr->icon);
ffr->icon = ditem->icon;
ditem->icon = NULL;
ffr->icon = gnome_desktop_item_get_icon (ditem);
g_free(ffr->fullname);
ffr->fullname = ditem->name;
ffr->fullname = g_strdup (gnome_desktop_item_get_localestring (ditem, "Name"));
g_free(ffr->comment);
ffr->comment = g_strdup (ditem->comment);
ditem->name = NULL;
gnome_desktop_item_free(ditem);
ffr->comment = g_strdup (gnome_desktop_item_get_localestring (ditem, "Comment"));
gnome_desktop_item_unref (ditem);
} else {
g_free(ffr->icon);
ffr->icon = NULL;
......@@ -742,24 +734,20 @@ fr_check_and_reread (FileRec *fr)
ffr->last_stat = curtime;
if(ffr->mtime != s.st_mtime) {
GnomeDesktopItem *ditem;
ditem = gnome_desktop_item_load(ffr->name);
ditem = gnome_desktop_item_new_from_file (ffr->name,
GNOME_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS,
NULL);
if (ditem != NULL) {
/* take over memory */
g_free (ffr->icon);
ffr->icon = ditem->icon;
ditem->icon = NULL;
ffr->icon = gnome_desktop_item_get_icon (ditem);
/* take over memory */
g_free (ffr->fullname);
ffr->fullname = ditem->name;
ditem->name = NULL;
ffr->fullname = g_strdup (gnome_desktop_item_get_localestring (ditem, "Name"));
/* take over memory */
g_free (ffr->comment);
ffr->comment = ditem->comment;
ditem->comment = NULL;
ffr->comment = g_strdup (gnome_desktop_item_get_localestring (ditem, "Comment"));
gnome_desktop_item_free (ditem);
gnome_desktop_item_unref (ditem);
} else {
reread = TRUE;
break;
......@@ -798,9 +786,6 @@ fr_check_and_reread (FileRec *fr)
}
}
return ret;
#else
return NULL;
#endif
}
FileRec *
......
......@@ -53,8 +53,8 @@ struct _FileRec {
struct _DirRec {
FileRec frec;
time_t dentrymtime;
time_t dentrylast_stat;
time_t ditemmtime;
time_t ditemlast_stat;
time_t merge_mtime;
gboolean force_reread;
GSList *tryexecs;
......
......@@ -1485,6 +1485,7 @@ edit_dentry (GtkWidget *widget, ShowItemMenu *sim)
static void
edit_direntry (GtkWidget *widget, ShowItemMenu *sim)
{
g_warning ("FIXME: edit_direntry() is not implemented");
#ifdef FIXME
GtkWidget *dialog, *notebook;
GtkWidget *dedit;
......@@ -1617,10 +1618,9 @@ edit_direntry (GtkWidget *widget, ShowItemMenu *sim)
static void
show_item_menu (GtkWidget *item, GdkEventButton *bevent, ShowItemMenu *sim)
{
#ifdef FIXME
GtkWidget *menuitem;
char *tmp;
GnomeDesktopEntry *ii;
GnomeDesktopItem *ii;
if (sim->menu == NULL) {
sim->menu = menu_new ();
......@@ -1634,7 +1634,7 @@ show_item_menu (GtkWidget *item, GdkEventButton *bevent, ShowItemMenu *sim)
item);
if (sim->type == 1) {
ii = gnome_desktop_entry_load_unconditional (sim->item_loc);
ii = gnome_desktop_item_new_from_file (sim->item_loc, 0, NULL);
menuitem = gtk_menu_item_new ();
gtk_widget_lock_accelerators (menuitem);
......@@ -1699,21 +1699,21 @@ show_item_menu (GtkWidget *item, GdkEventButton *bevent, ShowItemMenu *sim)
}
if (ii != NULL)
tmp = panel_gnome_kde_help_path (ii->docpath);
tmp = panel_gnome_kde_help_path (gnome_desktop_item_get_string (ii, "DocPath"));
else
tmp = NULL;
if (tmp != NULL) {
char *title;
const char *name;
g_free (tmp);
menuitem = gtk_menu_item_new ();
gtk_widget_lock_accelerators (menuitem);
name = gnome_desktop_item_get_localestring (ii, "Name");
title = g_strdup_printf (_("Help on %s"),
ii->name != NULL ?
ii->name :
_("Application"));
(name != NULL) ? name : _("Application"));
setup_menuitem (menuitem, 0, title);
g_free (title);
gtk_menu_shell_append (GTK_MENU_SHELL (sim->menu),
......@@ -1744,7 +1744,7 @@ show_item_menu (GtkWidget *item, GdkEventButton *bevent, ShowItemMenu *sim)
gtk_menu_shell_append (GTK_MENU_SHELL (sim->menu), menuitem);
gnome_desktop_entry_free (ii);
gnome_desktop_item_unref (ii);
}
if (sim->mf != NULL) {
......@@ -1839,7 +1839,6 @@ show_item_menu (GtkWidget *item, GdkEventButton *bevent, ShowItemMenu *sim)
NULL,
bevent->button,
bevent->time);
#endif
}
static gboolean
......@@ -2266,6 +2265,7 @@ try_add_status_to_panel (GtkWidget *widget, gpointer data)
static void
add_applet (GtkWidget *w, const char *item_loc)
{
g_warning ("FIXME: add_applet() not implemented\n");
#ifdef FIXME
GnomeDesktopEntry *ii;
char *goad_id;
......
......@@ -985,6 +985,7 @@ static void
drop_urilist (PanelWidget *panel, int pos, char *urilist,
gboolean background_drops)
{
g_warning ("FIXME: drop_urilist() not implemented");
#ifdef FIXME
GList *li, *files;
struct stat s;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment