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

Understand the DocPath field. Now we can start using it in other

Tue Mar 06 16:20:26 2001  George Lebl <jirka@5z.com>

	* launcher.[ch], menu.c, applet.c, gnome-panel-properties.desktop,
	  panel-utils.c:  Understand the DocPath field.  Now we can start
	  using it in other .desktops.  Still doesn't understand the kde
	  paths, though that should not be hard if we can guess the KDE
	  documentation path.
parent 32bbbc1d
Tue Mar 06 16:20:26 2001 George Lebl <jirka@5z.com>
* launcher.[ch], menu.c, applet.c, gnome-panel-properties.desktop,
panel-utils.c: Understand the DocPath field. Now we can start
using it in other .desktops. Still doesn't understand the kde
paths, though that should not be hard if we can guess the KDE
documentation path.
Tue Mar 06 11:08:45 2001 George Lebl <jirka@5z.com>
* basep-widget.c: don't show the panel if hidebuttons are disabled
......
Tue Mar 06 16:20:26 2001 George Lebl <jirka@5z.com>
* launcher.[ch], menu.c, applet.c, gnome-panel-properties.desktop,
panel-utils.c: Understand the DocPath field. Now we can start
using it in other .desktops. Still doesn't understand the kde
paths, though that should not be hard if we can guess the KDE
documentation path.
Tue Mar 06 11:08:45 2001 George Lebl <jirka@5z.com>
* basep-widget.c: don't show the panel if hidebuttons are disabled
......
......@@ -120,6 +120,21 @@ applet_callback_callback(GtkWidget *widget, gpointer data)
launcher_properties(menu->info->data);
else if (strcmp (menu->name, "help") == 0)
panel_show_help ("launchers.html");
else if (strcmp (menu->name, "help_on_app") == 0) {
Launcher * launcher = menu->info->data;
if (launcher->dentry != NULL) {
char *path = panel_gnome_kde_help_path
(launcher->dentry->docpath);
if (path != NULL) {
char *fullpath = g_strconcat ("ghelp:",
path,
NULL);
gnome_url_show (fullpath);
g_free (fullpath);
g_free (path);
}
}
}
break;
case APPLET_DRAWER:
if(strcmp(menu->name,"properties")==0) {
......
......@@ -51,3 +51,4 @@ Exec=gnome-panel-properties-capplet
Icon=gnome-panel.png
Terminal=0
Type=Application
DocPath=panel/globalpanelprefs.html
......@@ -337,6 +337,7 @@ create_launcher (const char *parameters, GnomeDesktopEntry *dentry)
launcher = g_new0 (Launcher, 1);
launcher->info = NULL;
launcher->button = NULL;
launcher->dedit = NULL;
launcher->prop_dialog = NULL;
......@@ -420,6 +421,7 @@ properties_apply (Launcher *launcher)
{
char *icon;
char *location;
char *docpath;
/* save (steal) location */
location = launcher->dentry->location;
......@@ -461,6 +463,22 @@ properties_apply (Launcher *launcher)
button_widget_set_pixmap(BUTTON_WIDGET(launcher->button),
default_app_pixmap, -1);
}
applet_remove_callback (launcher->info, "help_on_app");
docpath = panel_gnome_kde_help_path (launcher->dentry->docpath);
if (docpath != NULL) {
char *title;
g_free (docpath);
title = g_strdup_printf (_("Help on %s"),
launcher->dentry->name);
applet_add_callback (launcher->info, "help_on_app",
GNOME_STOCK_PIXMAP_HELP,
title);
g_free (title);
}
}
static void
......@@ -608,6 +626,7 @@ load_launcher_applet_full (const char *params, GnomeDesktopEntry *dentry,
PanelWidget *panel, int pos, gboolean exactpos)
{
Launcher *launcher;
char *docpath;
launcher = create_launcher (params, dentry);
......@@ -623,16 +642,34 @@ load_launcher_applet_full (const char *params, GnomeDesktopEntry *dentry,
return NULL;
}
launcher->info = applets_last->data;
gtk_tooltips_set_tip (panel_tooltips,
launcher->button,
launcher->dentry->comment,NULL);
launcher->dentry->comment,
NULL);
applet_add_callback (applets_last->data,"properties",
GNOME_STOCK_MENU_PROP,
_("Properties..."));
applet_add_callback (applets_last->data, "help",
GNOME_STOCK_PIXMAP_HELP,
_("Help"));
docpath = panel_gnome_kde_help_path (launcher->dentry->docpath);
if (docpath != NULL) {
char *title;
applet_add_callback(applets_last->data,"properties",
GNOME_STOCK_MENU_PROP,
_("Properties..."));
applet_add_callback(applets_last->data, "help",
GNOME_STOCK_PIXMAP_HELP,
_("Help"));
g_free (docpath);
title = g_strdup_printf (_("Help on %s"),
launcher->dentry->name);
applet_add_callback (applets_last->data, "help_on_app",
GNOME_STOCK_PIXMAP_HELP,
title);
g_free (title);
}
return launcher;
}
......
......@@ -16,6 +16,7 @@
BEGIN_GNOME_DECLS
typedef struct {
AppletInfo *info;
GtkWidget *button;
GtkObject *dedit;
GnomeDesktopEntry *dentry;
......
......@@ -969,6 +969,25 @@ add_to_run_dialog (GtkWidget *widget, const char *item_loc)
}
}
static void
show_help_on (GtkWidget *widget, const char *item_loc)
{
GnomeDesktopEntry *item =
gnome_desktop_entry_load_unconditional (item_loc);
if (item != NULL) {
char *path = panel_gnome_kde_help_path (item->docpath);
if (path != NULL) {
char *fullpath = g_strconcat ("ghelp:", path, NULL);
gnome_url_show (fullpath);
g_free (fullpath);
g_free (path);
}
gnome_desktop_entry_free (item);
} else {
panel_error_dialog (_("Can't load entry"));
}
}
static void
add_app_to_panel (GtkWidget *widget, const char *item_loc)
{
......@@ -1548,6 +1567,10 @@ show_item_menu (GtkWidget *item, GdkEventButton *bevent, ShowItemMenu *sim)
if(sim->type == 1) {
char *tmp;
GnomeDesktopEntry *ii;
ii = gnome_desktop_entry_load_unconditional (sim->item_loc);
menuitem = gtk_menu_item_new ();
gtk_widget_lock_accelerators (menuitem);
if ( ! sim->applet)
......@@ -1609,6 +1632,37 @@ show_item_menu (GtkWidget *item, GdkEventButton *bevent, ShowItemMenu *sim)
GTK_SIGNAL_FUNC(gtk_menu_shell_deactivate),
GTK_OBJECT(item->parent));
}
if (ii != NULL)
tmp = panel_gnome_kde_help_path (ii->docpath);
else
tmp = NULL;
if (tmp != NULL) {
char *title;
g_free (tmp);
menuitem = gtk_menu_item_new ();
gtk_widget_lock_accelerators (menuitem);
title = g_strdup_printf (_("Help on %s"),
ii->name);
setup_menuitem (menuitem, 0, title);
g_free (title);
gtk_menu_append (GTK_MENU (sim->menu),
menuitem);
gtk_signal_connect
(GTK_OBJECT(menuitem), "activate",
GTK_SIGNAL_FUNC(show_help_on),
(gpointer)sim->item_loc);
gtk_signal_connect_object
(GTK_OBJECT(menuitem),
"activate",
GTK_SIGNAL_FUNC(gtk_menu_shell_deactivate),
GTK_OBJECT(item->parent));
}
gnome_desktop_entry_free (ii);
} else {
menuitem = gtk_menu_item_new ();
gtk_widget_lock_accelerators (menuitem);
......
......@@ -32,6 +32,58 @@ panel_show_help (const char *path)
gnome_help_display (NULL, &help_entry);
}
static char *
panel_gnome_help_path (const char *docpath)
{
char *fullpath, *app, *p, *path;
app = g_strdup (docpath);
p = strchr (app, '/');
if (p == NULL) {
g_free (app);
return NULL;
}
path = p+1;
*p = '\0';
fullpath = gnome_help_file_path (app, path);
g_free (app);
if ( ! panel_file_exists (fullpath)) {
g_free (fullpath);
fullpath = NULL;
}
return fullpath;
}
static char *
panel_kde_help_path (const char *docpath)
{
/* FIXME: */
return NULL;
}
char *
panel_gnome_kde_help_path (const char *docpath)
{
char *path;
if (string_empty (docpath))
return NULL;
path = panel_gnome_help_path (docpath);
if (path == NULL)
path = panel_kde_help_path (docpath);
return path;
}
gboolean
string_is_in_list(const GSList *list, const char *text)
{
......
......@@ -90,6 +90,8 @@ int find_applet (GtkWidget *widget);
int get_requisition_width (GtkWidget *widget);
int get_requisition_height (GtkWidget *widget);
char * panel_gnome_kde_help_path (const char *docpath);
END_GNOME_DECLS
#endif /* PANEL_UTIL_H */
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