windowck-dialogs.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. /* $Id$
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 3 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along
  14. * with this program; if not, write to the Free Software Foundation, Inc.,
  15. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  16. *
  17. * Copyright (C) 2013 Alessio Piccoli <alepic@geckoblu.net>
  18. * Cedric Leporcq <cedl38@gmail.com>
  19. *
  20. */
  21. #ifdef HAVE_CONFIG_H
  22. #include <config.h>
  23. #endif
  24. #include <string.h>
  25. #include <gtk/gtk.h>
  26. #include <libxfce4ui/libxfce4ui.h>
  27. #include <libxfce4panel/xfce-panel-plugin.h>
  28. #include <common/theme.h>
  29. #include "windowck.h"
  30. #include "windowck-title.h"
  31. #include "windowck-dialogs.h"
  32. #include "windowck-dialogs_ui.h"
  33. /* the website url */
  34. #define PLUGIN_WEBSITE "http://goodies.xfce.org/projects/panel-plugins/xfce4-windowck-plugin"
  35. #define TITLE_SIZE_MIN 3
  36. static void on_only_maximized_toggled(GtkRadioButton *only_maximized, WindowckPlugin *wckp)
  37. {
  38. wckp->prefs->only_maximized = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(only_maximized));
  39. reload_wnck_title (wckp);
  40. }
  41. static void on_show_on_desktop_toggled(GtkToggleButton *show_on_desktop, WindowckPlugin *wckp)
  42. {
  43. wckp->prefs->show_on_desktop = gtk_toggle_button_get_active(show_on_desktop);
  44. if (wckp->icon->symbol)
  45. gtk_widget_set_sensitive (wckp->icon->symbol, TRUE);
  46. reload_wnck_title (wckp);
  47. }
  48. static void on_titlesize_changed(GtkSpinButton *titlesize, WindowckPlugin *wckp)
  49. {
  50. wckp->prefs->title_size = gtk_spin_button_get_value(titlesize);
  51. resize_title(wckp);
  52. }
  53. static void on_size_mode_changed (GtkComboBox *size_mode, WindowckPlugin *wckp)
  54. {
  55. gint id;
  56. GtkWidget *titlesize, *width_unit;
  57. id = gtk_combo_box_get_active (size_mode);
  58. if (id < 0 || id > 2)
  59. {
  60. g_critical ("Trying to set a default size but got an invalid item");
  61. return;
  62. }
  63. titlesize = GTK_WIDGET (gtk_builder_get_object (wckp->prefs->builder, "titlesize"));
  64. width_unit = GTK_WIDGET (gtk_builder_get_object (wckp->prefs->builder, "width_unit"));
  65. if (id == 0)
  66. {
  67. wckp->prefs->size_mode = SHRINK;
  68. xfce_panel_plugin_set_shrink (wckp->plugin, FALSE);
  69. gtk_widget_set_sensitive (titlesize, TRUE);
  70. gtk_widget_set_sensitive (width_unit, TRUE);
  71. }
  72. else if (id == 1)
  73. {
  74. wckp->prefs->size_mode = FIXE;
  75. xfce_panel_plugin_set_shrink (wckp->plugin, TRUE);
  76. gtk_widget_set_sensitive(titlesize, TRUE);
  77. gtk_widget_set_sensitive(width_unit, TRUE);
  78. }
  79. else if (id == 2)
  80. {
  81. wckp->prefs->size_mode = EXPAND;
  82. xfce_panel_plugin_set_shrink (wckp->plugin, TRUE);
  83. gtk_widget_set_sensitive (titlesize, FALSE);
  84. gtk_widget_set_sensitive (width_unit, FALSE);
  85. }
  86. /* dynamic resizing */
  87. /* don't work for title shrinking -> need to restart the applet */
  88. // TODO: make it working...
  89. resize_title(wckp);
  90. }
  91. static void on_full_name_toggled(GtkToggleButton *full_name, WindowckPlugin *wckp)
  92. {
  93. wckp->prefs->full_name = gtk_toggle_button_get_active(full_name);
  94. on_wck_state_changed (wckp->win->controlwindow, wckp);
  95. }
  96. static void on_two_lines_toggled(GtkToggleButton *two_lines, WindowckPlugin *wckp)
  97. {
  98. GtkWidget *sync_wm_font, *subtitle_font, *subtitle_font_label;
  99. sync_wm_font = GTK_WIDGET(gtk_builder_get_object(wckp->prefs->builder, "sync_wm_font"));
  100. subtitle_font = GTK_WIDGET(gtk_builder_get_object(wckp->prefs->builder, "subtitle_font"));
  101. subtitle_font_label = GTK_WIDGET(gtk_builder_get_object(wckp->prefs->builder, "subtitle_font_label"));
  102. wckp->prefs->two_lines = gtk_toggle_button_get_active(two_lines);
  103. on_wck_state_changed (wckp->win->controlwindow, wckp);
  104. if (wckp->prefs->two_lines)
  105. {
  106. gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sync_wm_font), FALSE);
  107. }
  108. gtk_widget_set_sensitive (subtitle_font, wckp->prefs->two_lines);
  109. gtk_widget_set_sensitive (subtitle_font_label, wckp->prefs->two_lines);
  110. gtk_widget_set_sensitive (sync_wm_font, !wckp->prefs->two_lines);
  111. }
  112. static void on_show_app_icon_toggled(GtkToggleButton *show_app_icon, WindowckPlugin *wckp)
  113. {
  114. wckp->prefs->show_app_icon = gtk_toggle_button_get_active(show_app_icon);
  115. create_symbol (wckp->prefs->show_app_icon, wckp);
  116. if (!wckp->prefs->show_app_icon)
  117. wck_signal_handler_disconnect (G_OBJECT(wckp->win->controlwindow), wckp->cih);
  118. on_wck_state_changed (wckp->win->controlwindow, wckp);
  119. }
  120. static void on_icon_on_right_toggled(GtkToggleButton *icon_on_right, WindowckPlugin *wckp)
  121. {
  122. wckp->prefs->icon_on_right = gtk_toggle_button_get_active(icon_on_right);
  123. if (wckp->prefs->icon_on_right)
  124. gtk_box_reorder_child (GTK_BOX (wckp->hvbox), GTK_WIDGET(wckp->icon->eventbox), 1);
  125. else
  126. gtk_box_reorder_child (GTK_BOX (wckp->hvbox), GTK_WIDGET(wckp->icon->eventbox), 0);
  127. }
  128. static void on_show_window_menu_toggled(GtkToggleButton *show_window_menu, WindowckPlugin *wckp)
  129. {
  130. GtkWidget *show_app_icon;
  131. GtkWidget *icon_on_right;
  132. wckp->prefs->show_window_menu = gtk_toggle_button_get_active(show_window_menu);
  133. show_app_icon = GTK_WIDGET(gtk_builder_get_object(wckp->prefs->builder, "show_app_icon"));
  134. icon_on_right = GTK_WIDGET(gtk_builder_get_object(wckp->prefs->builder, "icon_on_right"));
  135. create_symbol (wckp->prefs->show_app_icon, wckp);
  136. if (wckp->prefs->show_window_menu)
  137. {
  138. gtk_widget_set_sensitive (show_app_icon, TRUE);
  139. gtk_widget_set_sensitive (icon_on_right, TRUE);
  140. on_wck_state_changed (wckp->win->controlwindow, wckp);
  141. }
  142. else
  143. {
  144. gtk_widget_set_sensitive (show_app_icon, FALSE);
  145. gtk_widget_set_sensitive (icon_on_right, FALSE);
  146. if (wckp->prefs->show_app_icon)
  147. wck_signal_handler_disconnect (G_OBJECT(wckp->win->controlwindow), wckp->cih);
  148. }
  149. }
  150. static void on_sync_wm_font_toggled(GtkToggleButton *sync_wm_font, WindowckPlugin *wckp)
  151. {
  152. GtkFontButton *title_font;
  153. wckp->prefs->sync_wm_font = gtk_toggle_button_get_active (sync_wm_font);
  154. init_title (wckp);
  155. title_font = GTK_FONT_BUTTON(gtk_builder_get_object(wckp->prefs->builder, "title_font"));
  156. gtk_font_button_set_font_name(title_font, wckp->prefs->title_font);
  157. }
  158. static void on_title_font_set(GtkFontButton *title_font, WindowckPlugin *wckp)
  159. {
  160. PangoFontDescription *font;
  161. wckp->prefs->title_font = g_strdup(gtk_font_button_get_font_name(title_font));
  162. font = pango_font_description_from_string(wckp->prefs->title_font);
  163. gtk_widget_modify_font(GTK_WIDGET(wckp->title), font);
  164. pango_font_description_free(font);
  165. if (wckp->prefs->sync_wm_font)
  166. xfconf_channel_set_string (wckp->wm_channel, "/general/title_font", wckp->prefs->title_font);
  167. }
  168. static void on_subtitle_font_set(GtkFontButton *subtitle_font, WindowckPlugin *wckp)
  169. {
  170. PangoFontDescription *font;
  171. wckp->prefs->subtitle_font = g_strdup(gtk_font_button_get_font_name(subtitle_font));
  172. font = pango_font_description_from_string(wckp->prefs->subtitle_font);
  173. gtk_widget_modify_font(GTK_WIDGET(wckp->title), font);
  174. pango_font_description_free(font);
  175. }
  176. static void on_title_alignment_changed (GtkComboBox *title_alignment, WindowckPlugin *wckp)
  177. {
  178. gint id;
  179. id = gtk_combo_box_get_active(title_alignment);
  180. if (id < 0 || id > 2)
  181. {
  182. g_critical ("Trying to set a default size but got an invalid item");
  183. return;
  184. }
  185. if (id == 0)
  186. {
  187. wckp->prefs->title_alignment = LEFT;
  188. }
  189. else if (id == 1)
  190. {
  191. wckp->prefs->title_alignment = CENTER;
  192. }
  193. else if (id == 2)
  194. {
  195. wckp->prefs->title_alignment = RIGHT;
  196. }
  197. gtk_misc_set_alignment(GTK_MISC(wckp->title), wckp->prefs->title_alignment / 10.0, 0.5);
  198. on_wck_state_changed (wckp->win->controlwindow, wckp);
  199. }
  200. static void on_title_padding_changed(GtkSpinButton *title_padding, WindowckPlugin *wckp)
  201. {
  202. wckp->prefs->title_padding = gtk_spin_button_get_value(title_padding);
  203. gtk_alignment_set_padding(GTK_ALIGNMENT(wckp->alignment), ICON_PADDING, ICON_PADDING, wckp->prefs->title_padding, wckp->prefs->title_padding);
  204. gtk_box_set_spacing (GTK_BOX(wckp->hvbox), wckp->prefs->title_padding);
  205. }
  206. static GtkWidget * build_properties_area(WindowckPlugin *wckp, const gchar *buffer, gsize length)
  207. {
  208. GError *error = NULL;
  209. GObject *area = NULL;
  210. GtkSpinButton *titlesize, *title_padding;
  211. GtkComboBox *size_mode, *title_alignment;
  212. GtkToggleButton *sync_wm_font;
  213. GtkRadioButton *only_maximized, *active_window;
  214. GtkToggleButton *show_on_desktop, *full_name, *two_lines;
  215. GtkToggleButton *show_app_icon, *icon_on_right, *show_window_menu;
  216. GtkFontButton *title_font, *subtitle_font;
  217. GtkWidget *width_unit, *subtitle_font_label;
  218. wckp->prefs->builder = gtk_builder_new();
  219. if (gtk_builder_add_from_string(wckp->prefs->builder, buffer, length, &error)) {
  220. area = gtk_builder_get_object(wckp->prefs->builder, "alignment0");
  221. if (G_LIKELY (area != NULL))
  222. {
  223. only_maximized = GTK_RADIO_BUTTON(gtk_builder_get_object(wckp->prefs->builder, "only_maximized"));
  224. active_window = GTK_RADIO_BUTTON(gtk_builder_get_object(wckp->prefs->builder, "active_window"));
  225. if (G_LIKELY (only_maximized != NULL))
  226. {
  227. gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(only_maximized), wckp->prefs->only_maximized);
  228. gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(active_window), !wckp->prefs->only_maximized);
  229. g_signal_connect(only_maximized, "toggled", G_CALLBACK(on_only_maximized_toggled), wckp);
  230. }
  231. else {
  232. DBG("No widget with the name \"only_maximized\" found");
  233. }
  234. show_on_desktop = GTK_TOGGLE_BUTTON(gtk_builder_get_object(wckp->prefs->builder, "show_on_desktop"));
  235. if (G_LIKELY (show_on_desktop != NULL)) {
  236. gtk_toggle_button_set_active(show_on_desktop, wckp->prefs->show_on_desktop);
  237. g_signal_connect(show_on_desktop, "toggled", G_CALLBACK(on_show_on_desktop_toggled), wckp);
  238. }
  239. else {
  240. DBG("No widget with the name \"show_on_desktop\" found");
  241. }
  242. full_name = GTK_TOGGLE_BUTTON(gtk_builder_get_object(wckp->prefs->builder, "full_name"));
  243. if (G_LIKELY (full_name != NULL))
  244. {
  245. gtk_toggle_button_set_active(full_name, wckp->prefs->full_name);
  246. g_signal_connect(full_name, "toggled", G_CALLBACK(on_full_name_toggled), wckp);
  247. }
  248. else {
  249. DBG("No widget with the name \"full_name\" found");
  250. }
  251. two_lines = GTK_TOGGLE_BUTTON(gtk_builder_get_object(wckp->prefs->builder, "two_lines"));
  252. if (G_LIKELY (two_lines != NULL))
  253. {
  254. gtk_toggle_button_set_active(two_lines, wckp->prefs->two_lines);
  255. g_signal_connect(two_lines, "toggled", G_CALLBACK(on_two_lines_toggled), wckp);
  256. }
  257. else {
  258. DBG("No widget with the name \"two_lines\" found");
  259. }
  260. show_app_icon = GTK_TOGGLE_BUTTON(gtk_builder_get_object(wckp->prefs->builder, "show_app_icon"));
  261. if (G_LIKELY (show_app_icon != NULL))
  262. {
  263. gtk_toggle_button_set_active(show_app_icon, wckp->prefs->show_app_icon);
  264. g_signal_connect(show_app_icon, "toggled", G_CALLBACK(on_show_app_icon_toggled), wckp);
  265. }
  266. else {
  267. DBG("No widget with the name \"show_app_icon\" found");
  268. }
  269. icon_on_right = GTK_TOGGLE_BUTTON(gtk_builder_get_object(wckp->prefs->builder, "icon_on_right"));
  270. if (G_LIKELY (icon_on_right != NULL))
  271. {
  272. gtk_toggle_button_set_active(icon_on_right, wckp->prefs->icon_on_right);
  273. g_signal_connect(icon_on_right, "toggled", G_CALLBACK(on_icon_on_right_toggled), wckp);
  274. }
  275. else {
  276. DBG("No widget with the name \"icon_on_right\" found");
  277. }
  278. show_window_menu = GTK_TOGGLE_BUTTON(gtk_builder_get_object(wckp->prefs->builder, "show_window_menu"));
  279. if (G_LIKELY (show_window_menu != NULL))
  280. {
  281. gtk_toggle_button_set_active(show_window_menu, wckp->prefs->show_window_menu);
  282. g_signal_connect(show_window_menu, "toggled", G_CALLBACK(on_show_window_menu_toggled), wckp);
  283. }
  284. else {
  285. DBG("No widget with the name \"show_window_menu\" found");
  286. }
  287. titlesize = GTK_SPIN_BUTTON(gtk_builder_get_object(wckp->prefs->builder, "titlesize"));
  288. width_unit = GTK_WIDGET(gtk_builder_get_object(wckp->prefs->builder, "width_unit"));
  289. if (G_LIKELY (titlesize != NULL))
  290. {
  291. gtk_spin_button_set_range(titlesize, TITLE_SIZE_MIN, TITLE_SIZE_MAX);
  292. gtk_spin_button_set_increments(titlesize, 1, 1);
  293. gtk_spin_button_set_value(titlesize, wckp->prefs->title_size);
  294. g_signal_connect(titlesize, "value-changed", G_CALLBACK(on_titlesize_changed), wckp);
  295. }
  296. else {
  297. DBG("No widget with the name \"titlesize\" found");
  298. }
  299. sync_wm_font = GTK_TOGGLE_BUTTON(gtk_builder_get_object(wckp->prefs->builder, "sync_wm_font"));
  300. title_font = GTK_FONT_BUTTON(gtk_builder_get_object(wckp->prefs->builder, "title_font"));
  301. if (G_LIKELY (sync_wm_font != NULL))
  302. {
  303. if (wckp->wm_channel)
  304. {
  305. gtk_toggle_button_set_active(sync_wm_font, wckp->prefs->sync_wm_font);
  306. g_signal_connect(sync_wm_font, "toggled", G_CALLBACK(on_sync_wm_font_toggled), wckp);
  307. }
  308. else {
  309. gtk_widget_set_sensitive (GTK_WIDGET(sync_wm_font), FALSE);
  310. }
  311. }
  312. else {
  313. DBG("No widget with the name \"sync_wm_font\" found");
  314. }
  315. if (G_LIKELY (title_font != NULL))
  316. {
  317. gtk_font_button_set_font_name(title_font, wckp->prefs->title_font);
  318. g_signal_connect(title_font, "font-set", G_CALLBACK(on_title_font_set), wckp);
  319. }
  320. else {
  321. DBG("No widget with the name \"title_font\" found");
  322. }
  323. subtitle_font = GTK_FONT_BUTTON(gtk_builder_get_object(wckp->prefs->builder, "subtitle_font"));
  324. subtitle_font_label = GTK_WIDGET(gtk_builder_get_object(wckp->prefs->builder, "subtitle_font_label"));
  325. if (G_LIKELY (subtitle_font != NULL))
  326. {
  327. gtk_font_button_set_font_name(subtitle_font, wckp->prefs->subtitle_font);
  328. gtk_widget_set_sensitive (GTK_WIDGET(subtitle_font), wckp->prefs->two_lines);
  329. gtk_widget_set_sensitive (subtitle_font_label, wckp->prefs->two_lines);
  330. g_signal_connect(subtitle_font, "font-set", G_CALLBACK(on_subtitle_font_set), wckp);
  331. }
  332. else {
  333. DBG("No widget with the name \"title_font\" found");
  334. }
  335. title_alignment = GTK_COMBO_BOX(gtk_builder_get_object(wckp->prefs->builder, "title_alignment"));
  336. if (G_LIKELY (title_alignment != NULL)) {
  337. /* set active item */
  338. if ( wckp->prefs->title_alignment == LEFT ) {
  339. gtk_combo_box_set_active(title_alignment, 0);
  340. }
  341. else if( wckp->prefs->title_alignment == CENTER ) {
  342. gtk_combo_box_set_active(title_alignment, 1);
  343. }
  344. else if( wckp->prefs->title_alignment == RIGHT ) {
  345. gtk_combo_box_set_active(title_alignment, 2);
  346. }
  347. g_signal_connect(title_alignment, "changed", G_CALLBACK(on_title_alignment_changed), wckp);
  348. } else {
  349. DBG("No widget with the name \"title_alignment\" found");
  350. }
  351. title_padding = GTK_SPIN_BUTTON(gtk_builder_get_object(wckp->prefs->builder, "title_padding"));
  352. if (G_LIKELY (title_padding != NULL)) {
  353. gtk_spin_button_set_range(title_padding, 0, 99);
  354. gtk_spin_button_set_increments(title_padding, 1, 1);
  355. gtk_spin_button_set_value(title_padding, wckp->prefs->title_padding);
  356. g_signal_connect(title_padding, "value-changed", G_CALLBACK(on_title_padding_changed), wckp);
  357. } else {
  358. DBG("No widget with the name \"title_padding\" found");
  359. }
  360. size_mode = GTK_COMBO_BOX(gtk_builder_get_object(wckp->prefs->builder, "size_mode"));
  361. if (G_LIKELY (size_mode != NULL)) {
  362. /* set active item */
  363. if ( wckp->prefs->size_mode == SHRINK ) {
  364. gtk_combo_box_set_active(size_mode, 0);
  365. }
  366. else if( wckp->prefs->size_mode == FIXE ) {
  367. gtk_combo_box_set_active(size_mode, 1);
  368. }
  369. else if( wckp->prefs->size_mode == EXPAND ) {
  370. gtk_combo_box_set_active(size_mode, 2);
  371. gtk_widget_set_sensitive(GTK_WIDGET(titlesize), FALSE);
  372. gtk_widget_set_sensitive(width_unit, FALSE);
  373. }
  374. g_signal_connect(size_mode, "changed", G_CALLBACK(on_size_mode_changed), wckp);
  375. } else {
  376. DBG("No widget with the name \"size_mode\" found");
  377. }
  378. return GTK_WIDGET(area) ;
  379. }
  380. else {
  381. g_set_error_literal(&error, 0, 0, "No widget with the name \"contentarea\" found");
  382. }
  383. }
  384. g_critical("Faild to construct the wckp->prefs->builder for plugin %s-%d: %s.", xfce_panel_plugin_get_name (wckp->plugin), xfce_panel_plugin_get_unique_id (wckp->plugin), error->message);
  385. g_error_free(error);
  386. g_object_unref(G_OBJECT (wckp->prefs->builder) );
  387. return NULL ;
  388. }
  389. static void windowck_configure_response(GtkWidget *dialog, gint response, WindowckPlugin *wckp)
  390. {
  391. gboolean result;
  392. if (response == GTK_RESPONSE_HELP)
  393. {
  394. /* show help */
  395. result = g_spawn_command_line_async ("exo-open --launch WebBrowser " PLUGIN_WEBSITE, NULL);
  396. if (G_UNLIKELY (result == FALSE))
  397. g_warning (_("Unable to open the following url: %s"), PLUGIN_WEBSITE);
  398. }
  399. else
  400. {
  401. /* remove the dialog data from the plugin */
  402. g_object_set_data (G_OBJECT (wckp->plugin), "dialog", NULL);
  403. /* unlock the panel menu */
  404. xfce_panel_plugin_unblock_menu (wckp->plugin);
  405. /* save the plugin */
  406. windowck_save (wckp->plugin, wckp);
  407. /* destroy the properties dialog */
  408. gtk_widget_destroy (dialog);
  409. }
  410. }
  411. void windowck_configure(XfcePanelPlugin *plugin, WindowckPlugin *wckp)
  412. {
  413. GtkWidget *dialog;
  414. GtkWidget *content_area;
  415. GtkWidget *ca;
  416. const gchar *name;
  417. /* block the plugin menu */
  418. xfce_panel_plugin_block_menu (plugin);
  419. /* create the dialog */
  420. name = xfce_panel_plugin_get_display_name (plugin);
  421. dialog = xfce_titled_dialog_new_with_buttons (_(name),
  422. GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))),
  423. GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
  424. GTK_STOCK_HELP, GTK_RESPONSE_HELP,
  425. GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
  426. NULL);
  427. /* center dialog on the screen */
  428. gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
  429. /* set dialog icon */
  430. gtk_window_set_icon_name (GTK_WINDOW (dialog), "xfce4-settings");
  431. /* link the dialog to the plugin, so we can destroy it when the plugin
  432. * is closed, but the dialog is still open */
  433. g_object_set_data (G_OBJECT (plugin), "dialog", dialog);
  434. /* connect the reponse signal to the dialog */
  435. g_signal_connect (G_OBJECT (dialog), "response",
  436. G_CALLBACK(windowck_configure_response), wckp);
  437. content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog) );
  438. ca = build_properties_area (wckp, windowck_dialogs_ui, windowck_dialogs_ui_length);
  439. if (G_LIKELY (ca != NULL))
  440. gtk_container_add(GTK_CONTAINER (content_area), ca);
  441. else
  442. DBG("Failed to create content area");
  443. /* show the entire dialog */
  444. gtk_widget_show (dialog);
  445. }