/src/wrappers/gtk/examples/gtk-demo/changedisplay.e

http://github.com/tybor/Liberty · Specman e · 654 lines · 21 code · 110 blank · 523 comment · 2 complexity · b5937243dd9471b3d2c19a1b0d16d57c MD5 · raw file

  1. indexing
  2. description: "."
  3. copyright: "[
  4. Copyright (C) 2006 Paolo Redaelli, GTK+ team
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. ]"
  18. class CHANGEDISPLAY
  19. creation make
  20. feature
  21. -- /* Change Display
  22. -- *
  23. -- * Demonstrates migrating a window between different displays and
  24. -- * screens. A display is a mouse and keyboard with some number of
  25. -- * associated monitors. A screen is a set of monitors grouped
  26. -- * into a single physical work area. The neat thing about having
  27. -- * multiple displays is that they can be on a completely separate
  28. -- * computers, as long as there is a network connection to the
  29. -- * computer where the application is running.
  30. -- *
  31. -- * Only some of the windowing systems where GTK+ runs have the
  32. -- * concept of multiple displays and screens. (The X Window System
  33. -- * is the main example.) Other windowing systems can only
  34. -- * handle one keyboard and mouse, and combine all monitors into
  35. -- * a single screen.
  36. -- *
  37. -- * This is a moderately complex example, and demonstrates:
  38. -- *
  39. -- * - Tracking the currently open displays and screens
  40. -- *
  41. -- * - Changing the screen for a window
  42. -- *
  43. -- * - Letting the user choose a window by clicking on it
  44. -- *
  45. -- * - Using GtkListStore and GtkTreeView
  46. -- *
  47. -- * - Using GtkDialog
  48. -- */
  49. -- #include <string.h>
  50. -- #include <gtk/gtk.h>
  51. -- #include "demo-common.h"
  52. -- /* The ChangeDisplayInfo structure corresponds to a toplevel window and
  53. -- * holds pointers to widgets inside the toplevel window along with other
  54. -- * information about the contents of the window.
  55. -- * This is a common organizational structure in real applications.
  56. -- */
  57. -- typedef struct _ChangeDisplayInfo ChangeDisplayInfo;
  58. -- struct _ChangeDisplayInfo
  59. -- {
  60. -- GtkWidget *window;
  61. -- GtkSizeGroup *size_group;
  62. -- GtkTreeModel *display_model;
  63. -- GtkTreeModel *screen_model;
  64. -- GtkTreeSelection *screen_selection;
  65. -- GdkDisplay *current_display;
  66. -- GdkScreen *current_screen;
  67. -- };
  68. -- /* These enumerations provide symbolic names for the columns
  69. -- * in the two GtkListStore models.
  70. -- */
  71. -- enum
  72. -- {
  73. -- DISPLAY_COLUMN_NAME,
  74. -- DISPLAY_COLUMN_DISPLAY,
  75. -- DISPLAY_NUM_COLUMNS
  76. -- };
  77. -- enum
  78. -- {
  79. -- SCREEN_COLUMN_NUMBER,
  80. -- SCREEN_COLUMN_SCREEN,
  81. -- SCREEN_NUM_COLUMNS
  82. -- };
  83. -- /* Finds the toplevel window under the mouse pointer, if any.
  84. -- */
  85. -- static GtkWidget *
  86. -- find_toplevel_at_pointer (GdkDisplay *display)
  87. -- {
  88. -- GdkWindow *pointer_window;
  89. -- GtkWidget *widget = NULL;
  90. -- pointer_window = gdk_display_get_window_at_pointer (display, NULL, NULL);
  91. -- /* The user data field of a GdkWindow is used to store a pointer
  92. -- * to the widget that created it.
  93. -- */
  94. -- if (pointer_window)
  95. -- gdk_window_get_user_data (pointer_window, (gpointer*) &widget);
  96. -- return widget ? gtk_widget_get_toplevel (widget) : NULL;
  97. -- }
  98. -- static gboolean
  99. -- button_release_event_cb (GtkWidget *widget,
  100. -- GdkEventButton *event,
  101. -- gboolean *clicked)
  102. -- {
  103. -- *clicked = TRUE;
  104. -- return TRUE;
  105. -- }
  106. -- /* Asks the user to click on a window, then waits for them click
  107. -- * the mouse. When the mouse is released, returns the toplevel
  108. -- * window under the pointer, or NULL, if there is none.
  109. -- */
  110. -- static GtkWidget *
  111. -- query_for_toplevel (GdkScreen *screen,
  112. -- const char *prompt)
  113. -- {
  114. -- GdkDisplay *display = gdk_screen_get_display (screen);
  115. -- GtkWidget *popup, *label, *frame;
  116. -- GdkCursor *cursor;
  117. -- GtkWidget *toplevel = NULL;
  118. -- popup = gtk_window_new (GTK_WINDOW_POPUP);
  119. -- gtk_window_set_screen (GTK_WINDOW (popup), screen);
  120. -- gtk_window_set_modal (GTK_WINDOW (popup), TRUE);
  121. -- gtk_window_set_position (GTK_WINDOW (popup), GTK_WIN_POS_CENTER);
  122. -- frame = gtk_frame_new (NULL);
  123. -- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
  124. -- gtk_container_add (GTK_CONTAINER (popup), frame);
  125. -- label = gtk_label_new (prompt);
  126. -- gtk_misc_set_padding (GTK_MISC (label), 10, 10);
  127. -- gtk_container_add (GTK_CONTAINER (frame), label);
  128. -- gtk_widget_show_all (popup);
  129. -- cursor = gdk_cursor_new_for_display (display, GDK_CROSSHAIR);
  130. -- if (gdk_pointer_grab (popup->window, FALSE,
  131. -- GDK_BUTTON_RELEASE_MASK,
  132. -- NULL,
  133. -- cursor,
  134. -- GDK_CURRENT_TIME) == GDK_GRAB_SUCCESS)
  135. -- {
  136. -- gboolean clicked = FALSE;
  137. -- g_signal_connect (popup, "button-release-event",
  138. -- G_CALLBACK (button_release_event_cb), &clicked);
  139. -- /* Process events until clicked is set by button_release_event_cb.
  140. -- * We pass in may_block=TRUE since we want to wait if there
  141. -- * are no events currently.
  142. -- */
  143. -- while (!clicked)
  144. -- g_main_context_iteration (NULL, TRUE);
  145. -- toplevel = find_toplevel_at_pointer (gdk_screen_get_display (screen));
  146. -- if (toplevel == popup)
  147. -- toplevel = NULL;
  148. -- }
  149. -- gdk_cursor_unref (cursor);
  150. -- gtk_widget_destroy (popup);
  151. -- gdk_flush (); /* Really release the grab */
  152. -- return toplevel;
  153. -- }
  154. -- /* Prompts the user for a toplevel window to move, and then moves
  155. -- * that window to the currently selected display
  156. -- */
  157. -- static void
  158. -- query_change_display (ChangeDisplayInfo *info)
  159. -- {
  160. -- GdkScreen *screen = gtk_widget_get_screen (info->window);
  161. -- GtkWidget *toplevel;
  162. -- toplevel = query_for_toplevel (screen,
  163. -- "Please select the toplevel\n"
  164. -- "to move to the new screen");
  165. -- if (toplevel)
  166. -- gtk_window_set_screen (GTK_WINDOW (toplevel), info->current_screen);
  167. -- else
  168. -- gdk_display_beep (gdk_screen_get_display (screen));
  169. -- }
  170. -- /* Fills in the screen list based on the current display
  171. -- */
  172. -- static void
  173. -- fill_screens (ChangeDisplayInfo *info)
  174. -- {
  175. -- gtk_list_store_clear (GTK_LIST_STORE (info->screen_model));
  176. -- if (info->current_display)
  177. -- {
  178. -- gint n_screens = gdk_display_get_n_screens (info->current_display);
  179. -- gint i;
  180. -- for (i = 0; i < n_screens; i++)
  181. -- {
  182. -- GdkScreen *screen = gdk_display_get_screen (info->current_display, i);
  183. -- GtkTreeIter iter;
  184. -- gtk_list_store_append (GTK_LIST_STORE (info->screen_model), &iter);
  185. -- gtk_list_store_set (GTK_LIST_STORE (info->screen_model), &iter,
  186. -- SCREEN_COLUMN_NUMBER, i,
  187. -- SCREEN_COLUMN_SCREEN, screen,
  188. -- -1);
  189. -- if (i == 0)
  190. -- gtk_tree_selection_select_iter (info->screen_selection, &iter);
  191. -- }
  192. -- }
  193. -- }
  194. -- /* Called when the user clicks on a button in our dialog or
  195. -- * closes the dialog through the window manager. Unless the
  196. -- * "Change" button was clicked, we destroy the dialog.
  197. -- */
  198. -- static void
  199. -- response_cb (GtkDialog *dialog,
  200. -- gint response_id,
  201. -- ChangeDisplayInfo *info)
  202. -- {
  203. -- if (response_id == GTK_RESPONSE_OK)
  204. -- query_change_display (info);
  205. -- else
  206. -- gtk_widget_destroy (GTK_WIDGET (dialog));
  207. -- }
  208. -- /* Called when the user clicks on "Open..." in the display
  209. -- * frame. Prompts for a new display, and then opens a connection
  210. -- * to that display.
  211. -- */
  212. -- static void
  213. -- open_display_cb (GtkWidget *button,
  214. -- ChangeDisplayInfo *info)
  215. -- {
  216. -- GtkWidget *dialog;
  217. -- GtkWidget *display_entry;
  218. -- GtkWidget *dialog_label;
  219. -- gchar *new_screen_name = NULL;
  220. -- GdkDisplay *result = NULL;
  221. -- dialog = gtk_dialog_new_with_buttons ("Open Display",
  222. -- GTK_WINDOW (info->window),
  223. -- GTK_DIALOG_MODAL,
  224. -- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
  225. -- GTK_STOCK_OK, GTK_RESPONSE_OK,
  226. -- NULL);
  227. -- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
  228. -- display_entry = gtk_entry_new ();
  229. -- gtk_entry_set_activates_default (GTK_ENTRY (display_entry), TRUE);
  230. -- dialog_label =
  231. -- gtk_label_new ("Please enter the name of\nthe new display\n");
  232. -- gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), dialog_label);
  233. -- gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), display_entry);
  234. -- gtk_widget_grab_focus (display_entry);
  235. -- gtk_widget_show_all (GTK_BIN (dialog)->child);
  236. -- while (!result)
  237. -- {
  238. -- gint response_id = gtk_dialog_run (GTK_DIALOG (dialog));
  239. -- if (response_id != GTK_RESPONSE_OK)
  240. -- break;
  241. -- new_screen_name = gtk_editable_get_chars (GTK_EDITABLE (display_entry),
  242. -- 0, -1);
  243. -- if (strcmp (new_screen_name, "") != 0)
  244. -- {
  245. -- result = gdk_display_open (new_screen_name);
  246. -- if (!result)
  247. -- {
  248. -- gchar *error_msg =
  249. -- g_strdup_printf ("Can't open display :\n\t%s\nplease try another one\n",
  250. -- new_screen_name);
  251. -- gtk_label_set_text (GTK_LABEL (dialog_label), error_msg);
  252. -- g_free (error_msg);
  253. -- }
  254. -- g_free (new_screen_name);
  255. -- }
  256. -- }
  257. -- gtk_widget_destroy (dialog);
  258. -- }
  259. -- /* Called when the user clicks on the "Close" button in the
  260. -- * "Display" frame. Closes the selected display.
  261. -- */
  262. -- static void
  263. -- close_display_cb (GtkWidget *button,
  264. -- ChangeDisplayInfo *info)
  265. -- {
  266. -- if (info->current_display)
  267. -- gdk_display_close (info->current_display);
  268. -- }
  269. -- /* Called when the selected row in the display list changes.
  270. -- * Updates info->current_display, then refills the list of
  271. -- * screens.
  272. -- */
  273. -- static void
  274. -- display_changed_cb (GtkTreeSelection *selection,
  275. -- ChangeDisplayInfo *info)
  276. -- {
  277. -- GtkTreeModel *model;
  278. -- GtkTreeIter iter;
  279. -- if (gtk_tree_selection_get_selected (selection, &model, &iter))
  280. -- gtk_tree_model_get (model, &iter,
  281. -- DISPLAY_COLUMN_DISPLAY, &info->current_display,
  282. -- -1);
  283. -- else
  284. -- info->current_display = NULL;
  285. -- fill_screens (info);
  286. -- }
  287. -- /* Called when the selected row in the sceen list changes.
  288. -- * Updates info->current_screen.
  289. -- */
  290. -- static void
  291. -- screen_changed_cb (GtkTreeSelection *selection,
  292. -- ChangeDisplayInfo *info)
  293. -- {
  294. -- GtkTreeModel *model;
  295. -- GtkTreeIter iter;
  296. -- if (gtk_tree_selection_get_selected (selection, &model, &iter))
  297. -- gtk_tree_model_get (model, &iter,
  298. -- SCREEN_COLUMN_SCREEN, &info->current_screen,
  299. -- -1);
  300. -- else
  301. -- info->current_screen = NULL;
  302. -- }
  303. -- /* This function is used both for creating the "Display" and
  304. -- * "Screen" frames, since they have a similar structure. The
  305. -- * caller hooks up the right context for the value returned
  306. -- * in tree_view, and packs any relevant buttons into button_vbox.
  307. -- */
  308. -- static void
  309. -- create_frame (ChangeDisplayInfo *info,
  310. -- const char *title,
  311. -- GtkWidget **frame,
  312. -- GtkWidget **tree_view,
  313. -- GtkWidget **button_vbox)
  314. -- {
  315. -- GtkTreeSelection *selection;
  316. -- GtkWidget *scrollwin;
  317. -- GtkWidget *hbox;
  318. -- *frame = gtk_frame_new (title);
  319. -- hbox = gtk_hbox_new (FALSE, 8);
  320. -- gtk_container_set_border_width (GTK_CONTAINER (hbox), 8);
  321. -- gtk_container_add (GTK_CONTAINER (*frame), hbox);
  322. -- scrollwin = gtk_scrolled_window_new (NULL, NULL);
  323. -- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin),
  324. -- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  325. -- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrollwin),
  326. -- GTK_SHADOW_IN);
  327. -- gtk_box_pack_start (GTK_BOX (hbox), scrollwin, TRUE, TRUE, 0);
  328. -- *tree_view = gtk_tree_view_new ();
  329. -- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (*tree_view), FALSE);
  330. -- gtk_container_add (GTK_CONTAINER (scrollwin), *tree_view);
  331. -- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (*tree_view));
  332. -- gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
  333. -- *button_vbox = gtk_vbox_new (FALSE, 5);
  334. -- gtk_box_pack_start (GTK_BOX (hbox), *button_vbox, FALSE, FALSE, 0);
  335. -- if (!info->size_group)
  336. -- info->size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
  337. -- gtk_size_group_add_widget (GTK_SIZE_GROUP (info->size_group), *button_vbox);
  338. -- }
  339. -- /* If we have a stack of buttons, it often looks better if their contents
  340. -- * are left-aligned, rather than centered. This function creates a button
  341. -- * and left-aligns it contents.
  342. -- */
  343. -- GtkWidget *
  344. -- left_align_button_new (const char *label)
  345. -- {
  346. -- GtkWidget *button = gtk_button_new_with_mnemonic (label);
  347. -- GtkWidget *child = gtk_bin_get_child (GTK_BIN (button));
  348. -- gtk_misc_set_alignment (GTK_MISC (child), 0., 0.5);
  349. -- return button;
  350. -- }
  351. -- /* Creates the "Display" frame in the main window.
  352. -- */
  353. -- GtkWidget *
  354. -- create_display_frame (ChangeDisplayInfo *info)
  355. -- {
  356. -- GtkWidget *frame;
  357. -- GtkWidget *tree_view;
  358. -- GtkWidget *button_vbox;
  359. -- GtkTreeViewColumn *column;
  360. -- GtkTreeSelection *selection;
  361. -- GtkWidget *button;
  362. -- create_frame (info, "Display", &frame, &tree_view, &button_vbox);
  363. -- button = left_align_button_new ("_Open...");
  364. -- g_signal_connect (button, "clicked", G_CALLBACK (open_display_cb), info);
  365. -- gtk_box_pack_start (GTK_BOX (button_vbox), button, FALSE, FALSE, 0);
  366. -- button = left_align_button_new ("_Close");
  367. -- g_signal_connect (button, "clicked", G_CALLBACK (close_display_cb), info);
  368. -- gtk_box_pack_start (GTK_BOX (button_vbox), button, FALSE, FALSE, 0);
  369. -- info->display_model = (GtkTreeModel *)gtk_list_store_new (DISPLAY_NUM_COLUMNS,
  370. -- G_TYPE_STRING,
  371. -- GDK_TYPE_DISPLAY);
  372. -- gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), info->display_model);
  373. -- column = gtk_tree_view_column_new_with_attributes ("Name",
  374. -- gtk_cell_renderer_text_new (),
  375. -- "text", DISPLAY_COLUMN_NAME,
  376. -- NULL);
  377. -- gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
  378. -- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
  379. -- g_signal_connect (selection, "changed",
  380. -- G_CALLBACK (display_changed_cb), info);
  381. -- return frame;
  382. -- }
  383. -- /* Creates the "Screen" frame in the main window.
  384. -- */
  385. -- GtkWidget *
  386. -- create_screen_frame (ChangeDisplayInfo *info)
  387. -- {
  388. -- GtkWidget *frame;
  389. -- GtkWidget *tree_view;
  390. -- GtkWidget *button_vbox;
  391. -- GtkTreeViewColumn *column;
  392. -- create_frame (info, "Screen", &frame, &tree_view, &button_vbox);
  393. -- info->screen_model = (GtkTreeModel *)gtk_list_store_new (SCREEN_NUM_COLUMNS,
  394. -- G_TYPE_INT,
  395. -- GDK_TYPE_SCREEN);
  396. -- gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), info->screen_model);
  397. -- column = gtk_tree_view_column_new_with_attributes ("Number",
  398. -- gtk_cell_renderer_text_new (),
  399. -- "text", SCREEN_COLUMN_NUMBER,
  400. -- NULL);
  401. -- gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
  402. -- info->screen_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
  403. -- g_signal_connect (info->screen_selection, "changed",
  404. -- G_CALLBACK (screen_changed_cb), info);
  405. -- return frame;
  406. -- }
  407. -- /* Called when one of the currently open displays is closed.
  408. -- * Remove it from our list of displays.
  409. -- */
  410. -- static void
  411. -- display_closed_cb (GdkDisplay *display,
  412. -- gboolean is_error,
  413. -- ChangeDisplayInfo *info)
  414. -- {
  415. -- GtkTreeIter iter;
  416. -- gboolean valid;
  417. -- for (valid = gtk_tree_model_get_iter_first (info->display_model, &iter);
  418. -- valid;
  419. -- valid = gtk_tree_model_iter_next (info->display_model, &iter))
  420. -- {
  421. -- GdkDisplay *tmp_display;
  422. -- gtk_tree_model_get (info->display_model, &iter,
  423. -- DISPLAY_COLUMN_DISPLAY, &tmp_display,
  424. -- -1);
  425. -- if (tmp_display == display)
  426. -- {
  427. -- gtk_list_store_remove (GTK_LIST_STORE (info->display_model), &iter);
  428. -- break;
  429. -- }
  430. -- }
  431. -- }
  432. -- /* Adds a new display to our list of displays, and connects
  433. -- * to the "closed" signal so that we can remove it from the
  434. -- * list of displays again.
  435. -- */
  436. -- static void
  437. -- add_display (ChangeDisplayInfo *info,
  438. -- GdkDisplay *display)
  439. -- {
  440. -- const gchar *name = gdk_display_get_name (display);
  441. -- GtkTreeIter iter;
  442. -- gtk_list_store_append (GTK_LIST_STORE (info->display_model), &iter);
  443. -- gtk_list_store_set (GTK_LIST_STORE (info->display_model), &iter,
  444. -- DISPLAY_COLUMN_NAME, name,
  445. -- DISPLAY_COLUMN_DISPLAY, display,
  446. -- -1);
  447. -- g_signal_connect (display, "closed",
  448. -- G_CALLBACK (display_closed_cb), info);
  449. -- }
  450. -- /* Called when a new display is opened
  451. -- */
  452. -- static void
  453. -- display_opened_cb (GdkDisplayManager *manager,
  454. -- GdkDisplay *display,
  455. -- ChangeDisplayInfo *info)
  456. -- {
  457. -- add_display (info, display);
  458. -- }
  459. -- /* Adds all currently open displays to our list of displays,
  460. -- * and set up a signal connection so that we'll be notified
  461. -- * when displays are opened in the future as well.
  462. -- */
  463. -- static void
  464. -- initialize_displays (ChangeDisplayInfo *info)
  465. -- {
  466. -- GdkDisplayManager *manager = gdk_display_manager_get ();
  467. -- GSList *displays = gdk_display_manager_list_displays (manager);
  468. -- GSList *tmp_list;
  469. -- for (tmp_list = displays; tmp_list; tmp_list = tmp_list->next)
  470. -- add_display (info, tmp_list->data);
  471. -- g_slist_free (tmp_list);
  472. -- g_signal_connect (manager, "display_opened",
  473. -- G_CALLBACK (display_opened_cb), info);
  474. -- }
  475. -- /* Cleans up when the toplevel is destroyed; we remove the
  476. -- * connections we use to track currently open displays, then
  477. -- * free the ChangeDisplayInfo structure.
  478. -- */
  479. -- static void
  480. -- destroy_info (ChangeDisplayInfo *info)
  481. -- {
  482. -- GdkDisplayManager *manager = gdk_display_manager_get ();
  483. -- GSList *displays = gdk_display_manager_list_displays (manager);
  484. -- GSList *tmp_list;
  485. -- g_signal_handlers_disconnect_by_func (manager,
  486. -- display_opened_cb,
  487. -- info);
  488. -- for (tmp_list = displays; tmp_list; tmp_list = tmp_list->next)
  489. -- g_signal_handlers_disconnect_by_func (tmp_list->data,
  490. -- display_closed_cb,
  491. -- info);
  492. -- g_slist_free (tmp_list);
  493. -- g_object_unref (info->size_group);
  494. -- g_free (info);
  495. -- }
  496. -- static void
  497. -- destroy_cb (GtkObject *object,
  498. -- ChangeDisplayInfo **info)
  499. -- {
  500. -- destroy_info (*info);
  501. -- *info = NULL;
  502. -- }
  503. -- /* Main entry point. If the dialog for this demo doesn't yet exist, creates
  504. -- * it. Otherwise, destroys it.
  505. -- */
  506. -- GtkWidget *
  507. -- do_changedisplay (GtkWidget *do_widget)
  508. -- {
  509. -- static ChangeDisplayInfo *info = NULL;
  510. -- if (!info)
  511. -- {
  512. -- GtkWidget *vbox;
  513. -- GtkWidget *frame;
  514. -- info = g_new0 (ChangeDisplayInfo, 1);
  515. -- info->window = gtk_dialog_new_with_buttons ("Change Screen or display",
  516. -- GTK_WINDOW (do_widget),
  517. -- GTK_DIALOG_NO_SEPARATOR,
  518. -- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
  519. -- "Change", GTK_RESPONSE_OK,
  520. -- NULL);
  521. -- gtk_window_set_default_size (GTK_WINDOW (info->window), 300, 400);
  522. -- g_signal_connect (info->window, "response",
  523. -- G_CALLBACK (response_cb), info);
  524. -- g_signal_connect (info->window, "destroy",
  525. -- G_CALLBACK (destroy_cb), &info);
  526. -- vbox = gtk_vbox_new (FALSE, 5);
  527. -- gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
  528. -- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (info->window)->vbox), vbox,
  529. -- TRUE, TRUE, 0);
  530. -- frame = create_display_frame (info);
  531. -- gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
  532. -- frame = create_screen_frame (info);
  533. -- gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
  534. -- initialize_displays (info);
  535. -- gtk_widget_show_all (info->window);
  536. -- return info->window;
  537. -- }
  538. -- else
  539. -- {
  540. -- gtk_widget_destroy (info->window);
  541. -- return NULL;
  542. -- }
  543. -- }
  544. end