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

Reenable the DocPath help showing stuff, but slightly differently now

Wed Jan 16 18:14:43 2002  George Lebl <jirka@5z.com>

	* panel-util.[ch], applet.c , launcher.c, menu.c: Reenable the
	  DocPath help showing stuff, but slightly differently now

	* panel-util.[ch], panel-widget.c: s/my_g_/panel_g_/

	* panel-util.c, menu.c: a bit more work on error dialogs,
	  also have the error/info dialogs use the markup.
parent 49480b34
Wed Jan 16 18:14:43 2002 George Lebl <jirka@5z.com>
* panel-util.[ch], applet.c , launcher.c, menu.c: Reenable the
DocPath help showing stuff, but slightly differently now
* panel-util.[ch], panel-widget.c: s/my_g_/panel_g_/
* panel-util.c, menu.c: a bit more work on error dialogs,
also have the error/info dialogs use the markup.
2002-01-16 Stephen Browne <stephen.browne@sun.com>
* distribution.c
......
......@@ -194,15 +194,15 @@ applet_callback_callback(GtkWidget *widget, gpointer data)
} else if (strcmp (menu->name, "help_on_app") == 0) {
Launcher * launcher = menu->info->data;
if (launcher->ditem != NULL) {
GError *error = NULL;
const char *docpath =
gnome_desktop_item_get_string
(launcher->ditem, "DocPath");
char *path =
panel_gnome_kde_help_path (docpath);
if (path != NULL) {
gnome_url_show (path, NULL);
/* FIXME: handle errors */
g_free (path);
if ( ! panel_show_gnome_kde_help (docpath, &error)) {
panel_error_dialog ("cannot_show_gnome_kde_help",
_("<b>Cannot display help document</b>\n\n"
"Details: %s"), error->message);
g_clear_error (&error);
}
}
}
......
......@@ -107,7 +107,8 @@ launch (Launcher *launcher)
&error);
if (error != NULL) {
panel_error_dialog ("cannot_launch_icon",
_("Cannot launch icon\n%s"),
_("<b>Cannot launch icon</b>\n\n"
"Details: %s"),
error->message);
g_clear_error (&error);
}
......@@ -419,7 +420,6 @@ setup_button (Launcher *launcher)
const char *comment;
const char *name;
const char *docpath;
char *real_docpath;
char *str;
char *icon;
......@@ -456,18 +456,15 @@ setup_button (Launcher *launcher)
panel_applet_remove_callback (launcher->info, "help_on_app");
real_docpath = panel_gnome_kde_help_path (docpath);
if (real_docpath != NULL) {
if (docpath != NULL) {
char *title;
g_free (real_docpath);
title = g_strdup_printf (_("Help on %s Application"), name);
panel_applet_add_callback (launcher->info,
"help_on_app",
GTK_STOCK_HELP,
title);
GTK_STOCK_HELP,
title);
g_free (title);
}
}
......
......@@ -330,25 +330,29 @@ about_gnome_cb(GtkObject *object, char *program_path)
static void
activate_app_def (GtkWidget *widget, const char *item_loc)
{
GError *error = NULL;
GnomeDesktopItem *item = gnome_desktop_item_new_from_uri
(item_loc,
GNOME_DESKTOP_ITEM_LOAD_NO_TRANSLATIONS,
NULL /* error */);
&error);
if (item != NULL) {
char *curdir = g_get_current_dir ();
chdir (g_get_home_dir ());
gnome_desktop_item_launch (item,
NULL /* file_list */,
0 /* flags */,
NULL /* error */);
&error);
if (error != NULL) {
panel_error_dialog ("cant_load_entry",
_("<b>Can't launch entry</b>\n\n"
"Details: %s"), error->message);
g_clear_error (&error);
}
gnome_desktop_item_unref (item);
chdir (curdir);
g_free (curdir);
} else {
panel_error_dialog ("cannot_load_entry",
_("Can't load entry"));
g_assert (error != NULL);
panel_error_dialog ("cant_load_entry",
_("<b>Can't load entry</b>\n\n"
"Details: %s"), error->message);
g_clear_error (&error);
}
}
......@@ -753,7 +757,8 @@ remove_menuitem (GtkWidget *widget, ShowItemMenu *sim)
if (unlink (sim->item_loc) < 0) {
panel_error_dialog("cant_remove_menu_item",
_("Could not remove the menu item %s: %s\n"),
_("<b>Could not remove the menu item %s</b>\n\n"
"Details: %s\n"),
sim->item_loc, g_strerror (errno));
return;
}
......@@ -815,10 +820,11 @@ remove_menuitem (GtkWidget *widget, ShowItemMenu *sim)
static void
add_to_run_dialog (GtkWidget *widget, const char *item_loc)
{
GError *error = NULL;
GnomeDesktopItem *item =
gnome_desktop_item_new_from_uri (item_loc,
GNOME_DESKTOP_ITEM_LOAD_NO_TRANSLATIONS,
NULL /* error */);
&error);
if (item != NULL) {
const char *exec;
......@@ -836,41 +842,39 @@ add_to_run_dialog (GtkWidget *widget, const char *item_loc)
}
gnome_desktop_item_unref (item);
} else {
g_assert (error != NULL);
panel_error_dialog ("cant_load_entry",
_("Can't load entry"));
_("<b>Can't load entry</b>\n\n"
"Details: %s"), error->message);
g_clear_error (&error);
}
}
static void
show_help_on (GtkWidget *widget, const char *item_loc)
{
GError *error = NULL;
GnomeDesktopItem *item =
gnome_desktop_item_new_from_uri (item_loc,
GNOME_DESKTOP_ITEM_LOAD_NO_TRANSLATIONS,
NULL /* error */);
&error);
if (item != NULL) {
const char *docpath = gnome_desktop_item_get_string
(item, "DocPath");
char *path = panel_gnome_kde_help_path (docpath);
if (path != NULL) {
GError *error = NULL;
gnome_url_show (path, &error);
if (error != NULL) {
const char *name = gnome_desktop_item_get_localestring
(item, GNOME_DESKTOP_ITEM_NAME);
panel_error_dialog ("cant_load_help_on",
_("Cannot load help on %s.\n\n%s"),
name, error->message);
g_clear_error (&error);
}
/* FIXME: this should prolly use gnome_help */
g_free (path);
if ( ! panel_show_gnome_kde_help (docpath, &error)) {
panel_error_dialog ("cannot_show_gnome_kde_help",
_("<b>Cannot display help document</b>\n\n"
"Details: %s"), error->message);
g_clear_error (&error);
}
gnome_desktop_item_unref (item);
} else {
g_assert (error != NULL);
panel_error_dialog ("cant_load_entry",
_("Can't load entry"));
_("<b>Can't load entry</b>\n\n"
"Details: %s"), error->message);
g_clear_error (&error);
}
}
......@@ -1398,6 +1402,13 @@ show_item_menu (GtkWidget *item, GdkEventButton *bevent, ShowItemMenu *sim)
if (sim->type == 1) {
ii = gnome_desktop_item_new_from_uri (sim->item_loc, 0, NULL);
/* eek */
if (ii == NULL) {
gtk_widget_destroy (sim->menu);
sim->menu = NULL;
return;
}
menuitem = gtk_image_menu_item_new ();
if ( ! sim->applet)
setup_menuitem (menuitem, NULL,
......@@ -1442,19 +1453,10 @@ show_item_menu (GtkWidget *item, GdkEventButton *bevent, ShowItemMenu *sim)
G_OBJECT(item->parent));
}
if (ii != NULL) {
const char *doc_path = gnome_desktop_item_get_string (ii, "DocPath");
tmp = panel_gnome_kde_help_path (doc_path);
} else {
tmp = NULL;
}
if (tmp != NULL) {
if (gnome_desktop_item_get_string (ii, "DocPath") != NULL) {
char *title;
const char *name;
g_free (tmp);
menuitem = gtk_image_menu_item_new ();
name = gnome_desktop_item_get_localestring (ii, GNOME_DESKTOP_ITEM_NAME);
title = g_strdup_printf (_("Help on %s"),
......
......@@ -43,18 +43,23 @@ extern GSList *applets;
void
panel_show_help (const char *doc_name, const char *linkid)
{
gnome_help_display (doc_name,
linkid,
NULL);
/* FIXME: handle error */
GError *error = NULL;
if ( ! gnome_help_display (doc_name,
linkid,
&error)) {
panel_error_dialog ("cannot_show_help",
_("<b>Cannot display help document</b>\n\n"
"Details: %s"), error->message);
g_clear_error (&error);
}
}
#ifdef FIXME
static char *
panel_gnome_help_path (const char *docpath)
static gboolean
panel_show_gnome_help (const char *docpath, GError **error)
{
char *fullpath, *app, *p, *path, *uri;
char *app, *p, *path;
gboolean retval;
app = g_strdup (docpath);
......@@ -62,36 +67,49 @@ panel_gnome_help_path (const char *docpath)
if (p == NULL) {
g_free (app);
return NULL;
g_set_error (error,
PANEL_HELP_ERROR,
PANEL_HELP_ERROR_NOT_FOUND,
/* XXX: Not really a correct error,
* but just somewhat correct */
_("Help document not found"));
return FALSE;
}
path = p+1;
*p = '\0';
fullpath = gnome_help_file_path (app, path);
g_free (app);
if ( ! g_file_test (fullpath, G_FILE_TEST_EXISTS)) {
g_free (fullpath);
fullpath = NULL;
retval = TRUE;
if ( ! gnome_help_display_desktop (NULL /* program */,
app /* doc_id */,
path /* file_name */,
NULL /* link_id */,
error)) {
retval = gnome_help_display_with_doc_id (NULL /* program */,
app /* doc_id */,
path /* file_name */,
NULL /* link_id */,
error);
}
uri = g_strconcat ("ghelp:", fullpath, NULL);
g_free (fullpath);
g_free (app);
return uri;
return retval;
}
#endif /* FIXME */
#ifdef FIXME
static char *
panel_kde_help_path (const char *docpath)
static gboolean
panel_show_kde_help (const char *docpath, GError **error)
{
const GList *li;
if ( ! g_file_test (KDE_DOCDIR, G_FILE_TEST_EXISTS))
return NULL;
if ( ! g_file_test (KDE_DOCDIR, G_FILE_TEST_EXISTS)) {
g_set_error (error,
PANEL_HELP_ERROR,
PANEL_HELP_ERROR_NOT_FOUND,
_("Help document not found"));
return FALSE;
}
for (li = gnome_i18n_get_language_list ("LC_MESSAGES");
li != NULL;
......@@ -101,38 +119,54 @@ panel_kde_help_path (const char *docpath)
(char *)li->data,
docpath);
if (g_file_test (fullpath, G_FILE_TEST_EXISTS)) {
gboolean retval;
char *uri = g_strconcat ("ghelp:", fullpath, NULL);
g_free (fullpath);
return uri;
retval = gnome_help_display_uri (uri, error);
g_free (uri);
return retval;
}
g_free (fullpath);
}
return NULL;
g_set_error (error,
PANEL_HELP_ERROR,
PANEL_HELP_ERROR_NOT_FOUND,
_("Help document not found"));
return FALSE;
}
#endif /* FIXME */
char *
panel_gnome_kde_help_path (const char *docpath)
gboolean
panel_show_gnome_kde_help (const char *docpath,
GError **error)
{
#ifdef FIXME
char *path;
if (string_empty (docpath))
return NULL;
if (string_empty (docpath)) {
g_set_error (error,
PANEL_HELP_ERROR,
PANEL_HELP_ERROR_NO_DOCPATH,
_("No document to show"));
return FALSE;
}
if (panel_is_url (docpath))
return g_strdup (docpath);
return gnome_help_display_uri (docpath, error);
if ( ! panel_show_gnome_help (docpath, error)) {
return panel_show_kde_help (docpath, error);
}
path = panel_gnome_help_path (docpath);
return TRUE;
}
if (path == NULL)
path = panel_kde_help_path (docpath);
GQuark
panel_help_error_quark (void)
{
static GQuark q = 0;
if (q == 0)
q = g_quark_from_static_string ("panel-help-error-quark");
return path;
#else
return NULL;
#endif
return q;
}
static void
......@@ -229,7 +263,7 @@ create_icon_entry(GtkWidget *table,
}
GList *
my_g_list_swap_next (GList *list, GList *dl)
panel_g_list_swap_next (GList *list, GList *dl)
{
GList *t;
......@@ -252,7 +286,7 @@ my_g_list_swap_next (GList *list, GList *dl)
}
GList *
my_g_list_swap_prev (GList *list, GList *dl)
panel_g_list_swap_prev (GList *list, GList *dl)
{
GList *t;
......@@ -277,7 +311,7 @@ my_g_list_swap_prev (GList *list, GList *dl)
/*maybe this should be a glib function?
it resorts a single item in the list*/
GList *
my_g_list_resort_item(GList *list, gpointer data, GCompareFunc func)
panel_g_list_resort_item(GList *list, gpointer data, GCompareFunc func)
{
GList *dl;
......@@ -290,10 +324,10 @@ my_g_list_resort_item(GList *list, gpointer data, GCompareFunc func)
while(dl->next &&
(*func)(dl->data,dl->next->data)>0)
list=my_g_list_swap_next(list,dl);
list = panel_g_list_swap_next (list, dl);
while(dl->prev &&
(*func)(dl->data,dl->prev->data)<0)
list=my_g_list_swap_prev(list,dl);
list = panel_g_list_swap_prev (list, dl);
return list;
}
......@@ -618,12 +652,15 @@ panel_error_dialog (const char *class,
}
w = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK, s);
GTK_BUTTONS_OK, "foo");
gtk_widget_add_events (w, GDK_KEY_PRESS_MASK);
g_signal_connect (G_OBJECT (w), "event",
G_CALLBACK (panel_dialog_window_event), NULL);
gtk_window_set_wmclass (GTK_WINDOW (w),
class, "Panel");
gtk_label_set_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (w)->label), s);
g_free (s);
gtk_widget_show_all (w);
......@@ -654,11 +691,14 @@ panel_info_dialog (const char *class,
}
w = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_INFO,
GTK_BUTTONS_OK, s);
GTK_BUTTONS_OK, "foo");
g_signal_connect (G_OBJECT (w), "event",
G_CALLBACK (panel_dialog_window_event), NULL);
gtk_window_set_wmclass (GTK_WINDOW (w),
class, "Panel");
gtk_label_set_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (w)->label), s);
g_free (s);
gtk_widget_show_all (w);
......
......@@ -34,13 +34,13 @@ GtkWidget * create_icon_entry (GtkWidget *table,
void panel_show_help (const char *path,
const char *linkid);
GList * my_g_list_swap_next (GList *list,
GList * panel_g_list_swap_next (GList *list,
GList *dl);
GList * my_g_list_swap_prev (GList *list,
GList * panel_g_list_swap_prev (GList *list,
GList *dl);
/*maybe this should be a glib function?
it resorts a single item in the list*/
GList * my_g_list_resort_item (GList *list,
GList * panel_g_list_resort_item(GList *list,
gpointer data,
GCompareFunc func);
......@@ -85,7 +85,16 @@ 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);
typedef enum {
PANEL_HELP_ERROR_NO_DOCPATH /* No docpath sent */,
PANEL_HELP_ERROR_NOT_FOUND /* Document not found */
} PanelHelpError;
#define PANEL_HELP_ERROR panel_help_error_quark ()
GQuark panel_help_error_quark (void);
gboolean panel_show_gnome_kde_help (const char *docpath,
GError **error);
gboolean panel_is_url (const char *url);
......
......@@ -564,7 +564,7 @@ panel_widget_switch_applet_right(PanelWidget *panel, GList *list)
nad->pos = ad->pos;
ad->pos = nad->pos+nad->min_cells;
panel->applet_list = my_g_list_swap_next(panel->applet_list,list);
panel->applet_list = panel_g_list_swap_next(panel->applet_list,list);
panel_widget_queue_applet_for_resize(ad);
panel_widget_queue_applet_for_resize(nad);
......@@ -597,7 +597,7 @@ panel_widget_switch_applet_left(PanelWidget *panel, GList *list)
ad->pos = pad->pos;
pad->pos = ad->pos+ad->min_cells;
panel->applet_list = my_g_list_swap_prev(panel->applet_list,list);
panel->applet_list = panel_g_list_swap_prev(panel->applet_list,list);
panel_widget_queue_applet_for_resize(ad);
panel_widget_queue_applet_for_resize(pad);
......@@ -1975,8 +1975,8 @@ panel_widget_nice_move (PanelWidget *panel, AppletData *ad, int pos)
ad->pos = pos;
panel->applet_list =
my_g_list_resort_item (panel->applet_list, ad,
(GCompareFunc)applet_data_compare);
panel_g_list_resort_item (panel->applet_list, ad,
(GCompareFunc)applet_data_compare);
l = g_list_find (panel->applet_list, ad);
if (l && l->prev) {
......
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