Commit 172a5a87 authored by Jiri (George) Lebl's avatar Jiri (George) Lebl Committed by George Lebl

Remove an old standing "UglyHack(tm)" and fix copying to favourites even

Sat Sep 09 15:54:20 2000  George Lebl <jirka@5z.com>

	* menu.c:  Remove an old standing "UglyHack(tm)" and fix copying
	  to favourites even with merged menus etc.  It now copies only
	  the neccessary files as well and preserves old order files.

	* menu-fentry.c: just cosmetic cleanups
parent 6e8f31c3
Sat Sep 09 15:54:20 2000 George Lebl <jirka@5z.com>
* menu.c: Remove an old standing "UglyHack(tm)" and fix copying
to favourites even with merged menus etc. It now copies only
the neccessary files as well and preserves old order files.
* menu-fentry.c: just cosmetic cleanups
Tue Sep 05 21:22:55 2000 George Lebl <jirka@5z.com>
* gnome-panel-properties.c: When copying a config, copy all
......
Sat Sep 09 15:54:20 2000 George Lebl <jirka@5z.com>
* menu.c: Remove an old standing "UglyHack(tm)" and fix copying
to favourites even with merged menus etc. It now copies only
the neccessary files as well and preserves old order files.
* menu-fentry.c: just cosmetic cleanups
Tue Sep 05 21:22:55 2000 George Lebl <jirka@5z.com>
* gnome-panel-properties.c: When copying a config, copy all
......
......@@ -4,6 +4,8 @@ Things to do on the panel, in no particular order:
* When recheck all TryExec each time a menu is shown, or perhaps in background.
* Configuration boxes take effect immediately, no apply
[ Hmmmm ... needs some thought ]
* RootApplication dentry type support. These would be items to run other apps
as root. This would require pam support of course. So for things like
......@@ -13,23 +15,16 @@ Things to do on the panel, in no particular order:
was toggled on somewhere (global prefs I guess). This is high priority
[Taken: George]
* make vertical explicit hide with a thin long button along the edge of the
panel rather then on the sides. (the motion would be like it is in
autohide.) Though I guess the current should be default as it's less
wastefull for space.
* add a way to set up a custom icon for a menu button instead of using the
one specified in the menu itself
* export more functionality through the CORBA interface, eventually I think
we should have a per panel interface so that the panels could be
manipulated through corba directly, we especially need to export a way to
launch external applets and to add the internal ones, we can also have
things to move panels, and to change their background
Vertigo/2.0 items
Vertigo items
* Bonobo the whole bit, that is: Make the whole thing bonobo components, to
allow even customization of the panel from outside. Also the applets would become
bonobo controls.
* Bonobo the whole bit
* GConf/GnoP using configuration boxes
* tabbed panels
......@@ -39,3 +34,8 @@ Vertigo items
* strech hint for applets so that the panel can optionally strech applets if
it has the space and shrink em down again once it needs the space again
* make vertical explicit hide with a thin long button along the edge of the
panel rather then on the sides. (the motion would be like it is in
autohide.) Though I guess the current should be default as it's less
wastefull for space.
......@@ -222,18 +222,18 @@ fr_fill_dir(FileRec *fr, int sublevels)
time_t curtime = time(NULL);
char *mergedir;
g_return_if_fail(dr->recs==NULL);
g_return_if_fail(fr!=NULL);
g_return_if_fail(fr->name!=NULL);
g_return_if_fail (dr->recs == NULL);
g_return_if_fail (fr != NULL);
g_return_if_fail (fr->name != NULL);
ffr = g_chunk_new0 (FileRec, file_chunk);
ffr->type = FILE_REC_EXTRA;
ffr->name = g_concat_dir_and_file(fr->name,".order");
ffr->name = g_concat_dir_and_file(fr->name, ".order");
ffr->parent = dr;
if (stat (ffr->name, &s) != -1)
ffr->mtime = s.st_mtime;
ffr->last_stat = curtime;
dr->recs = g_slist_prepend(dr->recs,ffr);
dr->recs = g_slist_prepend(dr->recs, ffr);
mergedir = fr_get_mergedir (fr->name);
......@@ -301,7 +301,7 @@ fr_fill_dir(FileRec *fr, int sublevels)
get_applet_goad_id_from_dentry(dentry);
gnome_desktop_entry_free(dentry);
dr->recs = g_slist_prepend(dr->recs,ffr);
dr->recs = g_slist_prepend(dr->recs, ffr);
} else
g_free(name);
}
......
......@@ -14,6 +14,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <dirent.h>
#include <unistd.h>
#include <string.h>
......@@ -60,10 +61,6 @@ extern char *kde_menudir;
extern char *kde_icondir;
extern char *kde_mini_icondir;
extern char *merge_main_dir;
extern int merge_main_dir_len;
extern char *merge_merge_dir;
extern GtkTooltips *panel_tooltips;
typedef struct _TearoffMenu TearoffMenu;
......@@ -185,21 +182,103 @@ activate_app_def (GtkWidget *widget, char *item_loc)
}
}
/* XXX: not as hackish as it was before, but still quite bad */
/* Copy a single file */
static void
add_app_to_personal (GtkWidget *widget, char *item_loc)
copy_file_to_dir (const char *item, const char *to, mode_t mode)
{
char *argv[6]={"cp","-r","-f"};
char *p;
int fdin;
int fdout;
int chars;
char buf[1024];
char *toname;
fdin = open (item, O_RDONLY);
if (fdin < 0)
return;
toname = g_concat_dir_and_file (to, g_basename (item));
fdout = open (toname, O_WRONLY | O_CREAT, mode);
g_free (toname);
if (fdout < 0) {
close (fdin);
return;
}
while ((chars = read(fdin, buf, sizeof(buf))) > 0) {
write (fdout, buf, chars);
}
p = gnome_util_home_file("apps");
argv[3] = item_loc;
argv[4] = p;
argv[5] = NULL;
if(gnome_execute_async(NULL, 5, argv)<0)
panel_error_dialog(_("Can't execute copy (cp)"));
g_free(p);
close (fdin);
close (fdout);
}
static void
copy_fr_dir (DirRec *dr, const char *to)
{
GSList *li;
char *file_name;
FILE *order_file = NULL;
g_return_if_fail (dr != NULL);
g_return_if_fail (to != NULL);
file_name = g_concat_dir_and_file (dr->frec.name, ".directory");
copy_file_to_dir (file_name, to, 0600);
g_free (file_name);
file_name = g_concat_dir_and_file (to, ".order");
order_file = fopen (file_name, "a");
g_free (file_name);
for (li = dr->recs; li != NULL; li = li->next) {
FileRec *fr = li->data;
if (fr->type == FILE_REC_FILE) {
copy_file_to_dir (fr->name, to, 0600);
} else if (fr->type == FILE_REC_DIR) {
char *newdir = g_concat_dir_and_file (to, g_basename (fr->name));
if (g_file_exists (newdir) ||
mkdir (newdir, 0700) == 0)
copy_fr_dir ((DirRec *)fr, newdir);
g_free (newdir);
} else if (fr->type == FILE_REC_EXTRA) {
if (strcmp (g_basename (fr->name),
".order") != 0)
copy_file_to_dir (fr->name, to, 0600);
} else {
continue;
}
if (order_file != NULL)
fprintf (order_file, "%s\n", g_basename (fr->name));
}
if (order_file != NULL)
fclose (order_file);
}
static void
add_app_to_personal (GtkWidget *widget, const char *item_loc)
{
char *to;
to = gnome_util_home_file ("apps");
if (g_file_test (item_loc, G_FILE_TEST_ISDIR)) {
FileRec *fr = fr_get_dir (item_loc);
if (fr != NULL) {
char *newdir = g_concat_dir_and_file (to, g_basename (fr->name));
if (g_file_exists (newdir) ||
mkdir (newdir, 0700) == 0)
copy_fr_dir ((DirRec *)fr, newdir);
g_free(newdir);
}
} else {
copy_file_to_dir (item_loc, to, 0600);
}
g_free (to);
}
static PanelWidget *
......@@ -1908,7 +1987,7 @@ static char *
get_unique_tearoff_wmclass(void)
{
static char buf[256];
g_snprintf(buf,256,"panel_tearoff_%lu",wmclass_number++);
g_snprintf(buf, 256, "panel_tearoff_%lu", wmclass_number++);
return buf;
}
......@@ -2159,7 +2238,7 @@ create_fake_menu_at (const char *menudir,
return menu;
}
static void
static gboolean
create_menuitem(GtkWidget *menu,
FileRec *fr,
gboolean applets,
......@@ -2172,16 +2251,16 @@ create_menuitem(GtkWidget *menu,
? MEDIUM_ICON_SIZE : SMALL_ICON_SIZE;
char *itemname;
g_return_if_fail(fr != NULL);
g_return_val_if_fail (fr != NULL, FALSE);
if(fr->type == FILE_REC_EXTRA)
return;
return FALSE;
if(fr->type == FILE_REC_FILE && applets &&
!fr->goad_id) {
g_warning(_("Can't get goad_id for applet, ignoring it"));
return;
return FALSE;
}
sub = NULL;
......@@ -2212,7 +2291,7 @@ create_menuitem(GtkWidget *menu,
if (!sub) {
g_free(itemname);
return;
return FALSE;
}
}
......@@ -2266,6 +2345,8 @@ create_menuitem(GtkWidget *menu,
fr->name);
}
g_free(itemname);
return TRUE;
}
GtkWidget *
......@@ -2333,10 +2414,12 @@ create_menu_at_fr (GtkWidget *menu,
}
if(fr) {
GSList *last = NULL;
/* Last added points to the last fr list item that was successfuly
* added as a menu item */
GSList *last_added = NULL;
for(li = dr->recs; li != NULL; li = li->next) {
FileRec *tfr = li->data;
FileRec *pfr = last ? last->data : NULL;
FileRec *pfr = last_added ? last_added->data : NULL;
/* Add a separator between merged and non-merged menuitems */
if (tfr->merged &&
......@@ -2345,12 +2428,11 @@ create_menu_at_fr (GtkWidget *menu,
add_menu_separator(menu);
}
create_menuitem(menu, tfr,
applets, fake_submenus,
&add_separator,
&first_item);
last = li;
if (create_menuitem(menu, tfr,
applets, fake_submenus,
&add_separator,
&first_item))
last_added = li;
}
}
......@@ -2678,7 +2760,7 @@ add_panel_tearoff_new_menu(GtkWidget *w, gpointer data)
"destroy", GTK_SIGNAL_FUNC(gtk_widget_unref),
GTK_OBJECT(menu));
show_tearoff_menu(menu, _("Create panel"),TRUE,0,0,wmclass);
show_tearoff_menu(menu, _("Create panel"), TRUE, 0, 0, wmclass);
tm = g_new0(TearoffMenu,1);
tm->menu = menu;
......
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