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 <guichaz@yahoo.fr>
21 /****************************
22 * The help and about boxes *
23 ****************************/
25 #include <string.h> /* strlen() */
26 #include <gdk-pixbuf/gdk-pixdata.h>
33 #include "help_text.h"
38 static GtkWindow
*help_win
;
40 static gchar
*get_help_text(void)
42 gchar
**help_lines
, **ptr
;
46 help_lines
= get_help_lines();
48 /* Compute the total text length. */
49 for (ptr
= help_lines
; *ptr
!= NULL
; ptr
++)
52 res_ptr
= res
= g_new(gchar
, len
+ 1);
54 /* Concatenate the lines. */
55 for (ptr
= help_lines
; *ptr
!= NULL
; ptr
++)
56 res_ptr
= g_stpcpy(res_ptr
, *ptr
);
63 /* Get a textual widget with the help text in it. */
64 static GtkWidget
*get_text_widget(const gchar
* text
)
68 widget
= GTK_TEXT_VIEW(gtk_text_view_new());
70 gtk_text_view_set_editable(widget
, FALSE
);
71 gtk_text_view_set_cursor_visible(widget
, FALSE
);
72 gtk_text_view_set_wrap_mode(widget
, GTK_WRAP_WORD
);
73 gtk_text_buffer_set_text(gtk_text_view_get_buffer(widget
), text
, -1);
75 return GTK_WIDGET(widget
);
78 static void show_help(void)
80 PangoFontDescription
*font
;
83 GtkScrolledWindow
*win
;
85 help_text
= get_help_text();
87 widget
= get_text_widget(help_text
);
90 /* We use a fixed font to keep the alignment as in the README file. */
91 font
= pango_font_description_from_string(FONT
);
92 gtk_widget_modify_font(GTK_WIDGET(widget
), font
);
94 /* The window containing the text. */
95 win
= GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL
, NULL
));
96 gtk_scrolled_window_set_policy(win
,
97 GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
99 gtk_container_add(GTK_CONTAINER(win
), widget
);
101 /* The help window. */
102 help_win
= new_window(_("GLiv help"));
103 gtk_window_set_default_size(help_win
, 500, 500);
105 gtk_container_add(GTK_CONTAINER(help_win
), GTK_WIDGET(win
));
107 g_signal_connect(help_win
, "delete-event", G_CALLBACK(toggle_help
), NULL
);
109 show_message(GTK_WIDGET(help_win
), _("GLiv help"));
112 gboolean
toggle_help(void)
119 gtk_widget_destroy(GTK_WIDGET(help_win
));
124 #include "include/gliv_logo.h"
126 GdkPixbuf
*get_gliv_logo(void)
128 static GdkPixbuf
*logo
;
132 logo
= gdk_pixbuf_from_pixdata(&gliv_logo
, FALSE
, NULL
);
137 gboolean
show_about_box(void)
139 GtkDialog
*dialog
= NULL
;
147 logo
= get_gliv_logo();
151 image
= GTK_IMAGE(gtk_image_new_from_pixbuf(logo
));
154 about_text
= g_strconcat(_(ABOUT_GLIV
), " ", VERSION
, "\n",
155 "Guillaume Chazarain <guichaz@yahoo.fr>\n",
157 "\n", _(ABOUT_URL
), "\n", NULL
);
159 about
= GTK_LABEL(gtk_label_new(about_text
));
163 dialog
= GTK_DIALOG(gtk_dialog_new_with_buttons(_("GLiv about box"),
164 get_current_window(),
167 GTK_RESPONSE_ACCEPT
, NULL
));
169 box
= GTK_HBOX(gtk_hbox_new(FALSE
, 10));
170 gtk_box_pack_start_defaults(GTK_BOX(box
), GTK_WIDGET(image
));
171 gtk_box_pack_start_defaults(GTK_BOX(box
), GTK_WIDGET(about
));
172 gtk_widget_show_all(GTK_WIDGET(box
));
174 gtk_container_add(GTK_CONTAINER(dialog
->vbox
), GTK_WIDGET(box
));
176 run_modal_dialog(dialog
);
178 gtk_widget_destroy(GTK_WIDGET(dialog
));