2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 * See the COPYING file for license information.
18 * Guillaume Chazarain <gfc@altern.org>
21 /*****************************
22 * The help and about boxes. *
23 *****************************/
31 static GtkWindow
*help_win
;
33 static GtkWidget
*get_text_widget(const gchar
* text
)
37 widget
= GTK_TEXT_VIEW(gtk_text_view_new());
39 gtk_text_view_set_editable(widget
, FALSE
);
40 gtk_text_view_set_cursor_visible(widget
, FALSE
);
41 gtk_text_view_set_wrap_mode(widget
, GTK_WRAP_WORD
);
42 gtk_text_buffer_set_text(gtk_text_view_get_buffer(widget
), text
, -1);
44 return GTK_WIDGET(widget
);
47 static void show_help(void)
49 PangoFontDescription
*font
;
52 GtkScrolledWindow
*win
;
54 help_text
= HELP_TEXT();
56 widget
= get_text_widget(help_text
);
59 /* We use a fixed font to keep the alignment as in the README file. */
60 font
= pango_font_description_from_string(FONT
);
61 gtk_widget_modify_font(GTK_WIDGET(widget
), font
);
63 /* The window containing the text. */
64 win
= GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL
, NULL
));
65 gtk_scrolled_window_set_policy(win
,
66 GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
68 gtk_container_add(GTK_CONTAINER(win
), widget
);
70 /* The help window. */
71 help_win
= GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL
));
72 gtk_window_set_default_size(help_win
, 500, 550);
74 gtk_container_add(GTK_CONTAINER(help_win
), GTK_WIDGET(win
));
76 g_signal_connect(help_win
, "delete-event", G_CALLBACK(toggle_help
), NULL
);
78 show_dialog(GTK_WIDGET(help_win
), _("GLiv help"), FALSE
);
81 gboolean
toggle_help(void)
88 gtk_widget_destroy(GTK_WIDGET(help_win
));
93 static gboolean
delete_about_box(GtkWindow
** about_win
)
101 void show_about_box(void)
103 static GtkWindow
*about_win
= NULL
;
107 if (about_win
!= NULL
)
108 /* About box currently displayed. */
109 gtk_widget_destroy(GTK_WIDGET(about_win
));
111 about_text
= g_strconcat(_(ABOUT_GLIV
), " ", VERSION
, "\n",
112 "Guillaume Chazarain <gfc@altern.org>\n",
116 "\n", _(ABOUT_CLICK_HIDE
), NULL
);
118 about
= GTK_LABEL(gtk_label_new(about_text
));
121 about_win
= GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL
));
123 gtk_container_add(GTK_CONTAINER(about_win
), GTK_WIDGET(about
));
124 gtk_container_set_border_width(GTK_CONTAINER(about_win
), 10);
126 gtk_widget_set_events(GTK_WIDGET(about_win
), GDK_BUTTON_PRESS_MASK
);
128 g_signal_connect(about_win
, "button-press-event",
129 G_CALLBACK(gtk_widget_destroy
), NULL
);
131 g_signal_connect_swapped(about_win
, "delete-event",
132 G_CALLBACK(delete_about_box
), &about_win
);
134 show_dialog(GTK_WIDGET(about_win
), _("GLiv about box"), FALSE
);