You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

326 lines
10 KiB

  1. /* gxfce
  2. * Copyright (C) 1999 Olivier Fourdan (fourdan@xfce.org)
  3. * 2002 Xavier MAILLARD (zedek@fxgsproject.org)
  4. * 2003 Jasper Huijsmans (huysmans@users.sourceforge.net)
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. */
  20. #include <config.h>
  21. #include <my_gettext.h>
  22. #include <stdio.h>
  23. #include <string.h>
  24. #include "global.h"
  25. #include "xfce_support.h"
  26. #include "icons/xfce_slogan.xpm"
  27. #ifndef XFCE_LICENSE
  28. #define XFCE_LICENSE "COPYING"
  29. #endif
  30. #ifndef XFCE_AUTHORS
  31. #define XFCE_AUTHORS "AUTHORS"
  32. #endif
  33. #define BORDER 6
  34. static void fill_buffer(const char *filename, char **buf, int *nb)
  35. {
  36. GError *err = NULL;
  37. if(!filename)
  38. return;
  39. g_file_get_contents(filename, buf, nb, &err);
  40. if(err)
  41. {
  42. g_printerr("%s: %s (line: %d): %s\n\n", PACKAGE, __FILE__, __LINE__,
  43. err->message);
  44. }
  45. }
  46. static GtkWidget *create_bold_label(const char *text)
  47. {
  48. GtkWidget *label;
  49. char *markup;
  50. if(!text)
  51. return gtk_label_new("");
  52. markup = g_strconcat("<b> ", text, " </b>", NULL);
  53. label = gtk_label_new(NULL);
  54. gtk_label_set_markup(GTK_LABEL(label), markup);
  55. return label;
  56. }
  57. static void info_help_cb(GtkWidget * w, gpointer data)
  58. {
  59. exec_cmd("xfhelp", FALSE);
  60. }
  61. GtkWidget *create_scrolled_text_view(const char *file)
  62. {
  63. GtkWidget *frame;
  64. GtkWidget *sw;
  65. GtkTextBuffer *textbuffer = gtk_text_buffer_new(NULL);
  66. GtkWidget *textview = gtk_text_view_new();
  67. char *buffer;
  68. int nbytes_read;
  69. frame = gtk_frame_new(NULL);
  70. gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
  71. gtk_widget_show(frame);
  72. sw = gtk_scrolled_window_new(NULL, NULL);
  73. gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
  74. GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  75. gtk_widget_show(sw);
  76. gtk_container_add(GTK_CONTAINER(frame), sw);
  77. fill_buffer(file, &buffer, &nbytes_read);
  78. if(buffer)
  79. gtk_text_buffer_set_text(GTK_TEXT_BUFFER(textbuffer), buffer,
  80. nbytes_read);
  81. else
  82. gtk_text_buffer_set_text(GTK_TEXT_BUFFER(textbuffer), " ", 1);
  83. g_free(buffer);
  84. gtk_text_view_set_buffer(GTK_TEXT_VIEW(textview), textbuffer);
  85. gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), FALSE);
  86. gtk_text_view_set_left_margin(GTK_TEXT_VIEW(textview), BORDER);
  87. gtk_text_view_set_right_margin(GTK_TEXT_VIEW(textview), BORDER);
  88. gtk_widget_show(textview);
  89. gtk_container_add(GTK_CONTAINER(sw), textview);
  90. return frame;
  91. }
  92. static GtkWidget *create_info_header(void)
  93. {
  94. GtkWidget *vbox1, *vbox2;
  95. GdkPixbuf *logo_pb;
  96. GtkWidget *logo_im;
  97. GtkWidget *frame;
  98. GtkWidget *label;
  99. vbox1 = gtk_vbox_new(FALSE, BORDER);
  100. gtk_widget_show(vbox1);
  101. logo_pb = gdk_pixbuf_new_from_xpm_data((const char **)xfce_slogan);
  102. logo_im = gtk_image_new_from_pixbuf(logo_pb);
  103. g_object_unref(logo_pb);
  104. gtk_widget_show(logo_im);
  105. gtk_box_pack_start(GTK_BOX(vbox1), logo_im, FALSE, FALSE, BORDER);
  106. frame = gtk_frame_new(NULL);
  107. gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
  108. gtk_widget_show(frame);
  109. gtk_box_pack_start(GTK_BOX(vbox1), frame, FALSE, FALSE, 0);
  110. vbox2 = gtk_vbox_new(FALSE, BORDER);
  111. gtk_container_set_border_width(GTK_CONTAINER(vbox2), BORDER);
  112. gtk_widget_show(vbox2);
  113. gtk_container_add(GTK_CONTAINER(frame), vbox2);
  114. label = create_bold_label(_("XFce Desktop Environment"));
  115. gtk_widget_show(label);
  116. gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
  117. gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0);
  118. label = create_bold_label(_("Copyright 2002-2003 by Olivier Fourdan" ));
  119. gtk_widget_show(label);
  120. gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
  121. gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0);
  122. return vbox1;
  123. }
  124. static void add_info_page(GtkNotebook * notebook)
  125. {
  126. GtkWidget *sw;
  127. GtkWidget *info_label_1;
  128. GtkWidget *info_notebook_page;
  129. GtkWidget *info_bottom_frame;
  130. GtkWidget *info_view;
  131. info_label_1 = gtk_label_new(_("Info"));
  132. gtk_widget_show(info_label_1);
  133. info_notebook_page = gtk_vbox_new(FALSE, 0);
  134. gtk_container_set_border_width(GTK_CONTAINER(info_notebook_page), BORDER);
  135. gtk_widget_show(info_notebook_page);
  136. gtk_notebook_append_page(GTK_NOTEBOOK(notebook), info_notebook_page,
  137. info_label_1);
  138. info_bottom_frame = gtk_frame_new(NULL);
  139. gtk_frame_set_shadow_type(GTK_FRAME(info_bottom_frame), GTK_SHADOW_IN);
  140. gtk_widget_show(info_bottom_frame);
  141. gtk_box_pack_start(GTK_BOX(info_notebook_page), info_bottom_frame, TRUE,
  142. TRUE, 0);
  143. sw = gtk_scrolled_window_new(NULL, NULL);
  144. gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
  145. GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  146. gtk_widget_show(sw);
  147. gtk_container_add(GTK_CONTAINER(info_bottom_frame), sw);
  148. {
  149. GtkTextBuffer *tb = gtk_text_buffer_new(NULL);
  150. char *info_text = (""
  151. "XFce is a collection of programs that together provide a full-featured\n"
  152. "desktop enviroment. The following programs are part of XFce:\n"
  153. "\n"
  154. "o Window manager (xfwm4)\n"
  155. " handles the placement of windows on the screen\n"
  156. "\n"
  157. "o Panel (xfce4-panel)\n"
  158. " program lauchers, popup menus, clock, desktop switcher and more.\n"
  159. "\n"
  160. "o Desktop manager (xfdesktop)\n"
  161. " sets a background color or image and provides a menu when you click\n"
  162. " on the desktop background\n"
  163. "\n"
  164. "o File manager (xffm)\n"
  165. " fast file manager\n"
  166. "\n"
  167. "o Utilities\n"
  168. " xfrun4: run programs\n"
  169. " xftaskbar4: simple taskbar with optional pager\n"
  170. "\n\n"
  171. "Thank you for your interest in XFce,\n"
  172. "\n"
  173. " -- The XFce Development Team --\n");
  174. gtk_text_buffer_set_text(tb, info_text, -1);
  175. info_view = gtk_text_view_new();
  176. gtk_text_view_set_buffer(GTK_TEXT_VIEW(info_view), tb);
  177. gtk_text_view_set_editable(GTK_TEXT_VIEW(info_view), FALSE);
  178. gtk_text_view_set_left_margin(GTK_TEXT_VIEW(info_view), BORDER);
  179. gtk_text_view_set_right_margin(GTK_TEXT_VIEW(info_view), BORDER);
  180. gtk_widget_show(info_view);
  181. gtk_container_add(GTK_CONTAINER(sw), info_view);
  182. }
  183. }
  184. static void add_credits_page(GtkNotebook * notebook)
  185. {
  186. GtkWidget *info_label;
  187. GtkWidget *info_notebook_page;
  188. GtkWidget *info_credits_view;
  189. char *filename;
  190. info_label = gtk_label_new(_("Credits"));
  191. gtk_widget_show(info_label);
  192. info_notebook_page = gtk_vbox_new(FALSE, 0);
  193. gtk_container_set_border_width(GTK_CONTAINER(info_notebook_page), BORDER);
  194. gtk_widget_show(info_notebook_page);
  195. gtk_notebook_append_page(notebook, info_notebook_page, info_label);
  196. filename = g_build_filename(DATADIR, XFCE_AUTHORS, NULL);
  197. info_credits_view = create_scrolled_text_view(filename);
  198. g_free(filename);
  199. gtk_widget_show(info_credits_view);
  200. gtk_container_add(GTK_CONTAINER(info_notebook_page), info_credits_view);
  201. }
  202. static void add_license_page(GtkNotebook * notebook)
  203. {
  204. GtkWidget *info_label;
  205. GtkWidget *info_notebook_page;
  206. GtkWidget *info_license_view;
  207. char *filename;
  208. info_label = gtk_label_new(_("License"));
  209. gtk_widget_show(info_label);
  210. info_notebook_page = gtk_vbox_new(FALSE, 0);
  211. gtk_container_set_border_width(GTK_CONTAINER(info_notebook_page), BORDER);
  212. gtk_widget_show(info_notebook_page);
  213. gtk_notebook_append_page(notebook, info_notebook_page, info_label);
  214. filename = g_build_filename(DATADIR, XFCE_LICENSE, NULL);
  215. info_license_view = create_scrolled_text_view(filename);
  216. g_free(filename);
  217. gtk_container_add(GTK_CONTAINER(info_notebook_page), info_license_view);
  218. }
  219. void info_panel_dialog(void)
  220. {
  221. GtkWidget *info;
  222. GtkWidget *vbox;
  223. GtkWidget *header;
  224. GtkWidget *notebook;
  225. GtkWidget *buttonbox;
  226. GtkWidget *info_ok_button;
  227. GtkWidget *info_help_button;
  228. info = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  229. gtk_window_set_title(GTK_WINDOW(info), _("Info"));
  230. /* Make the info dialog sticky */
  231. gtk_window_stick(GTK_WINDOW(info));
  232. gtk_container_set_border_width(GTK_CONTAINER(info), BORDER);
  233. vbox = gtk_vbox_new(FALSE, BORDER);
  234. gtk_widget_show(vbox);
  235. gtk_container_add(GTK_CONTAINER(info), vbox);
  236. /* header with logo */
  237. header = create_info_header();
  238. gtk_box_pack_start(GTK_BOX(vbox), header, FALSE, FALSE, 0);
  239. /* the notebook */
  240. notebook = gtk_notebook_new();
  241. gtk_widget_show(notebook);
  242. gtk_widget_set_size_request(notebook, -1, 300);
  243. gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
  244. /* add pages */
  245. add_info_page(GTK_NOTEBOOK(notebook));
  246. add_credits_page(GTK_NOTEBOOK(notebook));
  247. add_license_page(GTK_NOTEBOOK(notebook));
  248. /* buttons */
  249. buttonbox = gtk_hbutton_box_new();
  250. gtk_widget_show(buttonbox);
  251. gtk_box_pack_start(GTK_BOX(vbox), buttonbox, FALSE, FALSE, BORDER);
  252. info_ok_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
  253. gtk_widget_show(info_ok_button);
  254. gtk_box_pack_start(GTK_BOX(buttonbox), info_ok_button, FALSE, FALSE, 0);
  255. info_help_button = gtk_button_new_from_stock(GTK_STOCK_HELP);
  256. gtk_widget_show(info_help_button);
  257. gtk_box_pack_start(GTK_BOX(buttonbox), info_help_button, FALSE, FALSE, 0);
  258. gtk_button_box_set_child_secondary(GTK_BUTTON_BOX(buttonbox),
  259. info_ok_button, TRUE);
  260. g_signal_connect_swapped(info_ok_button, "clicked",
  261. G_CALLBACK(gtk_widget_destroy), info);
  262. g_signal_connect(info_help_button, "clicked", G_CALLBACK(info_help_cb),
  263. NULL);
  264. gtk_window_set_position(GTK_WINDOW(info), GTK_WIN_POS_CENTER);
  265. gtk_widget_show(info);
  266. }