예제 #1
0
파일: interface.c 프로젝트: kaseya/lshw
GtkWidget*
create_lshw (void)
{
  GtkWidget *lshw;
  GtkWidget *vbox1;
  GtkWidget *menu;
  GtkWidget *menuitem4;
  GtkWidget *menuitem4_menu;
  GtkWidget *save;
  GtkWidget *quit1;
  GtkWidget *menuitem6;
  GtkWidget *menuitem6_menu;
  GtkWidget *refresh1;
  GtkWidget *menuitem7;
  GtkWidget *menuitem7_menu;
  GtkWidget *about1;
  GtkWidget *toolbar1;
  GtkIconSize tmp_toolbar_icon_size;
  GtkWidget *upbutton;
  GtkWidget *refreshbutton;
  GtkWidget *savebutton;
  GtkWidget *quitbutton;
  GtkWidget *scrolledwindow1;
  GtkWidget *viewport2;
  GtkWidget *hbox1;
  GtkWidget *hpaned1;
  GtkWidget *hbox3;
  GtkWidget *scrolledwindow10;
  GtkWidget *treeview1;
  GtkWidget *scrolledwindow11;
  GtkWidget *treeview2;
  GtkWidget *scrolledwindow12;
  GtkWidget *treeview3;
  GtkWidget *vbox2;
  GtkWidget *scrolledwindow13;
  GtkWidget *viewport3;
  GtkWidget *scrolledwindow14;
  GtkWidget *description;
  GtkWidget *statusbar;
  GtkAccelGroup *accel_group;
  GtkTooltips *tooltips;

  tooltips = gtk_tooltips_new ();

  accel_group = gtk_accel_group_new ();

  lshw = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (lshw), "lshw");
  gtk_window_set_default_size (GTK_WINDOW (lshw), 700, 480);

  vbox1 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox1);
  gtk_container_add (GTK_CONTAINER (lshw), vbox1);

  menu = gtk_menu_bar_new ();
  gtk_widget_show (menu);
  gtk_box_pack_start (GTK_BOX (vbox1), menu, FALSE, FALSE, 0);

  menuitem4 = gtk_menu_item_new_with_mnemonic ("_File");
  gtk_widget_show (menuitem4);
  gtk_container_add (GTK_CONTAINER (menu), menuitem4);

  menuitem4_menu = gtk_menu_new ();
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem4), menuitem4_menu);

  save = gtk_image_menu_item_new_from_stock ("gtk-save", accel_group);
  gtk_widget_show (save);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), save);
  gtk_widget_set_sensitive (save, FALSE);

  quit1 = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group);
  gtk_widget_show (quit1);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), quit1);

  menuitem6 = gtk_menu_item_new_with_mnemonic ("_View");
  gtk_widget_show (menuitem6);
  gtk_container_add (GTK_CONTAINER (menu), menuitem6);

  menuitem6_menu = gtk_menu_new ();
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem6), menuitem6_menu);

  refresh1 = gtk_image_menu_item_new_from_stock ("gtk-refresh", accel_group);
  gtk_widget_show (refresh1);
  gtk_container_add (GTK_CONTAINER (menuitem6_menu), refresh1);
  gtk_widget_add_accelerator (refresh1, "activate", accel_group,
                              GDK_F5, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  menuitem7 = gtk_menu_item_new_with_mnemonic ("_Help");
  gtk_widget_show (menuitem7);
  gtk_container_add (GTK_CONTAINER (menu), menuitem7);

  menuitem7_menu = gtk_menu_new ();
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem7), menuitem7_menu);

  about1 = gtk_menu_item_new_with_mnemonic ("_About");
  gtk_widget_show (about1);
  gtk_container_add (GTK_CONTAINER (menuitem7_menu), about1);

  toolbar1 = gtk_toolbar_new ();
  gtk_widget_show (toolbar1);
  gtk_box_pack_start (GTK_BOX (vbox1), toolbar1, FALSE, FALSE, 0);
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar1), GTK_TOOLBAR_BOTH);
  tmp_toolbar_icon_size = gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar1));

  upbutton = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-go-up");
  gtk_widget_show (upbutton);
  gtk_container_add (GTK_CONTAINER (toolbar1), upbutton);
  gtk_widget_set_sensitive (upbutton, FALSE);

  refreshbutton = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-refresh");
  gtk_widget_show (refreshbutton);
  gtk_container_add (GTK_CONTAINER (toolbar1), refreshbutton);
  gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (refreshbutton), tooltips, "Rescan the hardware", NULL);

  savebutton = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-save");
  gtk_widget_show (savebutton);
  gtk_container_add (GTK_CONTAINER (toolbar1), savebutton);
  gtk_widget_set_sensitive (savebutton, FALSE);

  quitbutton = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-quit");
  gtk_widget_show (quitbutton);
  gtk_container_add (GTK_CONTAINER (toolbar1), quitbutton);

  scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_show (scrolledwindow1);
  gtk_box_pack_start (GTK_BOX (vbox1), scrolledwindow1, TRUE, TRUE, 0);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

  viewport2 = gtk_viewport_new (NULL, NULL);
  gtk_widget_show (viewport2);
  gtk_container_add (GTK_CONTAINER (scrolledwindow1), viewport2);

  hbox1 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox1);
  gtk_container_add (GTK_CONTAINER (viewport2), hbox1);

  hpaned1 = gtk_hpaned_new ();
  gtk_widget_show (hpaned1);
  gtk_box_pack_start (GTK_BOX (hbox1), hpaned1, TRUE, TRUE, 0);

  hbox3 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox3);
  gtk_paned_pack1 (GTK_PANED (hpaned1), hbox3, FALSE, TRUE);

  scrolledwindow10 = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_show (scrolledwindow10);
  gtk_box_pack_start (GTK_BOX (hbox3), scrolledwindow10, TRUE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (scrolledwindow10), 2);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow10), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow10), GTK_SHADOW_ETCHED_IN);

  treeview1 = gtk_tree_view_new ();
  gtk_widget_show (treeview1);
  gtk_container_add (GTK_CONTAINER (scrolledwindow10), treeview1);
  gtk_widget_set_size_request (treeview1, 128, -1);
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview1), FALSE);

  scrolledwindow11 = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_show (scrolledwindow11);
  gtk_box_pack_start (GTK_BOX (hbox3), scrolledwindow11, TRUE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (scrolledwindow11), 2);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow11), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow11), GTK_SHADOW_ETCHED_IN);

  treeview2 = gtk_tree_view_new ();
  gtk_widget_show (treeview2);
  gtk_container_add (GTK_CONTAINER (scrolledwindow11), treeview2);
  gtk_widget_set_size_request (treeview2, 128, -1);
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview2), FALSE);

  scrolledwindow12 = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_show (scrolledwindow12);
  gtk_box_pack_start (GTK_BOX (hbox3), scrolledwindow12, TRUE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (scrolledwindow12), 2);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow12), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow12), GTK_SHADOW_ETCHED_IN);

  treeview3 = gtk_tree_view_new ();
  gtk_widget_show (treeview3);
  gtk_container_add (GTK_CONTAINER (scrolledwindow12), treeview3);
  gtk_widget_set_size_request (treeview3, 128, -1);
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview3), FALSE);

  vbox2 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox2);
  gtk_paned_pack2 (GTK_PANED (hpaned1), vbox2, TRUE, TRUE);

  scrolledwindow13 = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_show (scrolledwindow13);
  gtk_box_pack_start (GTK_BOX (vbox2), scrolledwindow13, TRUE, TRUE, 0);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow13), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

  viewport3 = gtk_viewport_new (NULL, NULL);
  gtk_widget_show (viewport3);
  gtk_container_add (GTK_CONTAINER (scrolledwindow13), viewport3);
  gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport3), GTK_SHADOW_NONE);

  scrolledwindow14 = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_show (scrolledwindow14);
  gtk_container_add (GTK_CONTAINER (viewport3), scrolledwindow14);
  gtk_container_set_border_width (GTK_CONTAINER (scrolledwindow14), 2);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow14), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow14), GTK_SHADOW_ETCHED_IN);

  description = gtk_text_view_new ();
  gtk_widget_show (description);
  gtk_container_add (GTK_CONTAINER (scrolledwindow14), description);
  GTK_WIDGET_UNSET_FLAGS (description, GTK_CAN_FOCUS);
  gtk_tooltips_set_tip (tooltips, description, "This pane displays detailed information about the selected hardware node", NULL);
  gtk_text_view_set_editable (GTK_TEXT_VIEW (description), FALSE);
  gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (description), FALSE);
  gtk_text_view_set_left_margin (GTK_TEXT_VIEW (description), 10);
  gtk_text_view_set_right_margin (GTK_TEXT_VIEW (description), 10);
  gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (description)), "no information available.\n\nclick on Refresh to query hardware", -1);

  statusbar = gtk_statusbar_new ();
  gtk_widget_show (statusbar);
  gtk_box_pack_start (GTK_BOX (vbox1), statusbar, FALSE, FALSE, 0);
  gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (statusbar), FALSE);

  g_signal_connect ((gpointer) lshw, "delete_event",
                    G_CALLBACK (gtk_main_quit),
                    NULL);
  g_signal_connect_after ((gpointer) lshw, "map",
                          G_CALLBACK (on_lshw_map),
                          NULL);
  g_signal_connect ((gpointer) save, "activate",
                    G_CALLBACK (on_save_activate),
                    NULL);
  g_signal_connect ((gpointer) quit1, "activate",
                    G_CALLBACK (gtk_main_quit),
                    NULL);
  g_signal_connect ((gpointer) refresh1, "activate",
                    G_CALLBACK (refresh_display),
                    NULL);
  g_signal_connect ((gpointer) about1, "activate",
                    G_CALLBACK (on_about1_activate),
                    NULL);
  g_signal_connect ((gpointer) upbutton, "clicked",
                    G_CALLBACK (go_up),
                    NULL);
  g_signal_connect ((gpointer) refreshbutton, "clicked",
                    G_CALLBACK (refresh_display),
                    NULL);
  g_signal_connect ((gpointer) savebutton, "clicked",
                    G_CALLBACK (on_savebutton_clicked),
                    NULL);
  g_signal_connect ((gpointer) quitbutton, "clicked",
                    G_CALLBACK (gtk_main_quit),
                    NULL);
  g_signal_connect ((gpointer) treeview1, "row_activated",
                    G_CALLBACK (on_treeview1_row_activated),
                    NULL);
  g_signal_connect ((gpointer) treeview1, "cursor_changed",
                    G_CALLBACK (on_treeview1_cursor_changed),
                    NULL);
  g_signal_connect ((gpointer) treeview2, "row_activated",
                    G_CALLBACK (on_treeview2_row_activated),
                    NULL);
  g_signal_connect ((gpointer) treeview2, "cursor_changed",
                    G_CALLBACK (on_treeview2_cursor_changed),
                    NULL);
  g_signal_connect ((gpointer) treeview3, "row_activated",
                    G_CALLBACK (on_treeview3_row_activated),
                    NULL);
  g_signal_connect ((gpointer) treeview3, "cursor_changed",
                    G_CALLBACK (on_treeview3_cursor_changed),
                    NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (lshw, lshw, "lshw");
  GLADE_HOOKUP_OBJECT (lshw, vbox1, "vbox1");
  GLADE_HOOKUP_OBJECT (lshw, menu, "menu");
  GLADE_HOOKUP_OBJECT (lshw, menuitem4, "menuitem4");
  GLADE_HOOKUP_OBJECT (lshw, menuitem4_menu, "menuitem4_menu");
  GLADE_HOOKUP_OBJECT (lshw, save, "save");
  GLADE_HOOKUP_OBJECT (lshw, quit1, "quit1");
  GLADE_HOOKUP_OBJECT (lshw, menuitem6, "menuitem6");
  GLADE_HOOKUP_OBJECT (lshw, menuitem6_menu, "menuitem6_menu");
  GLADE_HOOKUP_OBJECT (lshw, refresh1, "refresh1");
  GLADE_HOOKUP_OBJECT (lshw, menuitem7, "menuitem7");
  GLADE_HOOKUP_OBJECT (lshw, menuitem7_menu, "menuitem7_menu");
  GLADE_HOOKUP_OBJECT (lshw, about1, "about1");
  GLADE_HOOKUP_OBJECT (lshw, toolbar1, "toolbar1");
  GLADE_HOOKUP_OBJECT (lshw, upbutton, "upbutton");
  GLADE_HOOKUP_OBJECT (lshw, refreshbutton, "refreshbutton");
  GLADE_HOOKUP_OBJECT (lshw, savebutton, "savebutton");
  GLADE_HOOKUP_OBJECT (lshw, quitbutton, "quitbutton");
  GLADE_HOOKUP_OBJECT (lshw, scrolledwindow1, "scrolledwindow1");
  GLADE_HOOKUP_OBJECT (lshw, viewport2, "viewport2");
  GLADE_HOOKUP_OBJECT (lshw, hbox1, "hbox1");
  GLADE_HOOKUP_OBJECT (lshw, hpaned1, "hpaned1");
  GLADE_HOOKUP_OBJECT (lshw, hbox3, "hbox3");
  GLADE_HOOKUP_OBJECT (lshw, scrolledwindow10, "scrolledwindow10");
  GLADE_HOOKUP_OBJECT (lshw, treeview1, "treeview1");
  GLADE_HOOKUP_OBJECT (lshw, scrolledwindow11, "scrolledwindow11");
  GLADE_HOOKUP_OBJECT (lshw, treeview2, "treeview2");
  GLADE_HOOKUP_OBJECT (lshw, scrolledwindow12, "scrolledwindow12");
  GLADE_HOOKUP_OBJECT (lshw, treeview3, "treeview3");
  GLADE_HOOKUP_OBJECT (lshw, vbox2, "vbox2");
  GLADE_HOOKUP_OBJECT (lshw, scrolledwindow13, "scrolledwindow13");
  GLADE_HOOKUP_OBJECT (lshw, viewport3, "viewport3");
  GLADE_HOOKUP_OBJECT (lshw, scrolledwindow14, "scrolledwindow14");
  GLADE_HOOKUP_OBJECT (lshw, description, "description");
  GLADE_HOOKUP_OBJECT (lshw, statusbar, "statusbar");
  GLADE_HOOKUP_OBJECT_NO_REF (lshw, tooltips, "tooltips");

  gtk_window_add_accel_group (GTK_WINDOW (lshw), accel_group);

  return lshw;
}
예제 #2
0
static void
bt_settings_dialog_init_ui (const BtSettingsDialog * self)
{
  GtkWidget *box, *scrolled_window, *pages;
  GtkCellRenderer *renderer;
  GtkListStore *store;
  GtkTreeIter tree_iter;

  gtk_widget_set_name (GTK_WIDGET (self), "buzztrax settings");

  //gtk_widget_set_size_request(GTK_WIDGET(self),800,600);
  gtk_window_set_title (GTK_WINDOW (self), _("buzztrax settings"));

  // add dialog commision widgets (okay, cancel)
  gtk_dialog_add_buttons (GTK_DIALOG (self),
      _("_OK"), GTK_RESPONSE_ACCEPT, _("_Cancel"), GTK_RESPONSE_REJECT, NULL);

  gtk_dialog_set_default_response (GTK_DIALOG (self), GTK_RESPONSE_ACCEPT);

  // add widgets to the dialog content area
  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
  gtk_container_set_border_width (GTK_CONTAINER (box), 6);

  // add a list on the right and a notebook without tabs on the left
  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
      GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
      GTK_SHADOW_ETCHED_IN);
  self->priv->settings_list = GTK_TREE_VIEW (gtk_tree_view_new ());
  gtk_tree_view_set_headers_visible (self->priv->settings_list, FALSE);
  renderer = gtk_cell_renderer_pixbuf_new ();
  gtk_tree_view_insert_column_with_attributes (self->priv->settings_list, -1,
      NULL, renderer, "icon-name", COL_ICON_NAME, NULL);
  renderer = gtk_cell_renderer_text_new ();
  gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT
      (renderer), 1);
  gtk_tree_view_insert_column_with_attributes (self->priv->settings_list, -1,
      NULL, renderer, "text", COL_LABEL, NULL);
  gtk_tree_selection_set_mode (gtk_tree_view_get_selection (self->
          priv->settings_list), GTK_SELECTION_BROWSE);
  gtk_container_add (GTK_CONTAINER (scrolled_window),
      GTK_WIDGET (self->priv->settings_list));
  gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (scrolled_window), FALSE, FALSE,
      0);

  g_signal_connect (self->priv->settings_list, "realize",
      G_CALLBACK (on_settings_list_realize), (gpointer) scrolled_window);
  g_signal_connect (self->priv->settings_list, "cursor-changed",
      G_CALLBACK (on_settings_list_cursor_changed), (gpointer) self);

  store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_LONG, G_TYPE_STRING);
  //-- append entries for settings pages
  gtk_list_store_append (store, &tree_iter);
  gtk_list_store_set (store, &tree_iter,
      COL_LABEL, _("Audio Devices"),
      COL_ID, BT_SETTINGS_PAGE_AUDIO_DEVICES, COL_ICON_NAME, "audio-card", -1);
  gtk_list_store_append (store, &tree_iter);
  gtk_list_store_set (store, &tree_iter,
      COL_LABEL, _("Directories"),
      COL_ID, BT_SETTINGS_PAGE_DIRECTORIES, COL_ICON_NAME, "folder", -1);
  gtk_list_store_append (store, &tree_iter);
  gtk_list_store_set (store, &tree_iter,
      COL_LABEL, _("Interaction Controller"),
      COL_ID, BT_SETTINGS_PAGE_INTERACTION_CONTROLLER,
      COL_ICON_NAME, "input-gaming", -1);
  gtk_list_store_append (store, &tree_iter);
  gtk_list_store_set (store, &tree_iter,
      COL_LABEL, _("Playback Controller"),
      COL_ID, BT_SETTINGS_PAGE_PLAYBACK_CONTROLLER,
      COL_ICON_NAME, "media-playback-start", -1);
  gtk_list_store_append (store, &tree_iter);
  gtk_list_store_set (store, &tree_iter,
      COL_LABEL, _("Shortcuts"),
      COL_ID, BT_SETTINGS_PAGE_SHORTCUTS, COL_ICON_NAME, "input-keyboard", -1);
  gtk_list_store_append (store, &tree_iter);
  gtk_list_store_set (store, &tree_iter,
      COL_LABEL, _("User interface"),
      COL_ID, BT_SETTINGS_PAGE_UI, COL_ICON_NAME, "preferences-desktop-theme",
      -1);
  gtk_tree_view_set_model (self->priv->settings_list, GTK_TREE_MODEL (store));
  g_object_unref (store);       // drop with treeview

  // add notebook
  pages = gtk_notebook_new ();
  self->priv->settings_pages = GTK_NOTEBOOK (pages);
  gtk_widget_set_name (pages, "settings pages");
  gtk_notebook_set_show_tabs (self->priv->settings_pages, FALSE);
  gtk_notebook_set_show_border (self->priv->settings_pages, FALSE);
  gtk_container_add (GTK_CONTAINER (box), pages);

  // add audio device page
  self->priv->audiodevices_page = bt_settings_page_audiodevices_new (pages);
  gtk_container_add (GTK_CONTAINER (self->priv->settings_pages),
      GTK_WIDGET (self->priv->audiodevices_page));
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (self->priv->settings_pages),
      gtk_notebook_get_nth_page (GTK_NOTEBOOK (self->priv->settings_pages),
          BT_SETTINGS_PAGE_AUDIO_DEVICES), gtk_label_new (_("Audio Devices")));

  // add directories page
  self->priv->directories_page = bt_settings_page_directories_new (pages);
  gtk_container_add (GTK_CONTAINER (self->priv->settings_pages),
      GTK_WIDGET (self->priv->directories_page));
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (self->priv->settings_pages),
      gtk_notebook_get_nth_page (GTK_NOTEBOOK (self->priv->settings_pages),
          BT_SETTINGS_PAGE_DIRECTORIES), gtk_label_new (_("Directories")));

  // add interaction controller page
  self->priv->interaction_controller_page =
      bt_settings_page_interaction_controller_new (pages);
  gtk_container_add (GTK_CONTAINER (self->priv->settings_pages),
      GTK_WIDGET (self->priv->interaction_controller_page));
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (self->priv->settings_pages),
      gtk_notebook_get_nth_page (GTK_NOTEBOOK (self->priv->settings_pages),
          BT_SETTINGS_PAGE_INTERACTION_CONTROLLER),
      gtk_label_new (_("Interaction Controller")));

  // add playback controller page
  self->priv->playback_controller_page =
      bt_settings_page_playback_controller_new (pages);
  gtk_container_add (GTK_CONTAINER (self->priv->settings_pages),
      GTK_WIDGET (self->priv->playback_controller_page));
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (self->priv->settings_pages),
      gtk_notebook_get_nth_page (GTK_NOTEBOOK (self->priv->settings_pages),
          BT_SETTINGS_PAGE_PLAYBACK_CONTROLLER),
      gtk_label_new (_("Playback Controller")));

  // add shortcuts pags
  self->priv->shortcuts_page = bt_settings_page_shortcuts_new (pages);
  gtk_container_add (GTK_CONTAINER (self->priv->settings_pages),
      GTK_WIDGET (self->priv->shortcuts_page));
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (self->priv->settings_pages),
      gtk_notebook_get_nth_page (GTK_NOTEBOOK (self->priv->settings_pages),
          BT_SETTINGS_PAGE_SHORTCUTS), gtk_label_new (_("Shortcuts")));

  // add ui page
  self->priv->ui_page = bt_settings_page_ui_new (pages);
  gtk_container_add (GTK_CONTAINER (self->priv->settings_pages),
      GTK_WIDGET (self->priv->ui_page));
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (self->priv->settings_pages),
      gtk_notebook_get_nth_page (GTK_NOTEBOOK (self->priv->settings_pages),
          BT_SETTINGS_PAGE_UI), gtk_label_new (_("User Interface")));

  /* TODO(ensonic): more settings
   * - misc
   *   - initial song bpm (from, to)
   *   - cpu monitor (view menu?)
   */

  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))),
      box, TRUE, TRUE, 0);
}
예제 #3
0
/* GtkWidgetClass methods */
static void
eel_wrap_table_size_request (GtkWidget *widget,
                             GtkRequisition *requisition)
{
    EelWrapTable *wrap_table;
    EelDimensions content_dimensions;

    g_assert (EEL_IS_WRAP_TABLE (widget));
    g_assert (requisition != NULL);

    wrap_table = EEL_WRAP_TABLE (widget);

    content_dimensions = wrap_table_get_content_dimensions (wrap_table);

    /* The -1 tells Satan to use as much space as is available */
    requisition->width = -1;
    requisition->height = content_dimensions.height + gtk_container_get_border_width (GTK_CONTAINER (widget)) * 2;
}
예제 #4
0
파일: main.cpp 프로젝트: flocke/sterm
int main(int argc, char *argv[]) {
  gtk_init(&argc, &argv);

  if ( ! parse_commandline(argc, argv) )
    return(EXIT_FAILURE);

  sterm::common::set_debugging(opt_debug);

  if ( opt_config_file != NULL )
    config_file = opt_config_file;

  configuration = new sterm::config(config_file);

  gtk_window_set_default_icon_name("utilities-terminal");

  main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(main_window), "STerm");
  gtk_container_set_border_width(GTK_CONTAINER(main_window), 0);

  terminal = new sterm::terminal(configuration);

  std::string child_command;
  if ( opt_command != NULL )
    child_command = opt_command;

  terminal->attach_to_container(GTK_CONTAINER(main_window));

  terminal->spawn_child(child_command);

  terminal->connect_callback("child-exited", G_CALLBACK(main_exit_with_status_cb), NULL);
  terminal->connect_callback("bell", G_CALLBACK(main_bell_cb), NULL);

  terminal->link_property_to_terminal("window-title", G_OBJECT(main_window), "title");

  g_signal_connect(G_OBJECT(main_window), "destroy", G_CALLBACK(main_exit_cb), &main_window);

  functions = new sterm::function_handler(configuration, terminal);

  gtk_widget_show_all(main_window);
  gtk_main();

  if ( terminal != NULL ) {
    delete(terminal);
    terminal = NULL;
  }

  if ( functions != NULL ) {
    delete(functions);
    functions = NULL;
  }

  if ( configuration != NULL ) {
    delete(configuration);
    configuration = NULL;
  }

  if ( main_window != NULL ) {
    gtk_widget_destroy(main_window);
    main_window = NULL;
  }

  return ret;
}
예제 #5
0
파일: settings.c 프로젝트: BucketPW/pomfit
void settings_window_create (void) {

	if(win_set_main != NULL) {
		gtk_widget_hide(win_set_main);
		gtk_widget_show(win_set_main);
		return;
	}

	GtkWidget *vbox_set_m, *hbox_set_m, *but_set_close, *but_set_save, *but_set_reset;
	GtkWidget *nb_set_m, *lab_e, *vbox_nb_up, *vbox_nb_um, *vbox_nb_uq;
	GtkWidget *hbox_um_s, *grid_uq, *grid_up, *grid_um;

	win_set_main = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(win_set_main), "Pomf it! - Settings");
	g_signal_connect(win_set_main, "destroy", G_CALLBACK(settings_window_destroy), NULL);
	gtk_container_set_border_width(GTK_CONTAINER(win_set_main), 10);
	gtk_window_resize(GTK_WINDOW(win_set_main), 320, 200);
	gtk_window_set_position(GTK_WINDOW(win_set_main), GTK_WIN_POS_CENTER);

	vbox_set_m = gtk_box_new(GTK_ORIENTATION_VERTICAL , 0);
	gtk_container_add(GTK_CONTAINER(win_set_main), vbox_set_m);

	nb_set_m = gtk_notebook_new();
	gtk_container_add(GTK_CONTAINER(vbox_set_m),nb_set_m);

	vbox_nb_up = gtk_box_new(GTK_ORIENTATION_VERTICAL , 0);
	gtk_container_add(GTK_CONTAINER(nb_set_m), vbox_nb_up);
	lab_e = gtk_label_new("Uploader");
	g_object_set(G_OBJECT(lab_e), "can-focus", FALSE, NULL);
	gtk_notebook_set_tab_label(GTK_NOTEBOOK(nb_set_m),
		gtk_notebook_get_nth_page(GTK_NOTEBOOK(nb_set_m), 0),lab_e);

	vbox_nb_um = gtk_box_new(GTK_ORIENTATION_VERTICAL , 0);
	gtk_container_add(GTK_CONTAINER(nb_set_m), vbox_nb_um);
	lab_e = gtk_label_new("Manager");
	g_object_set(G_OBJECT(lab_e), "can-focus", FALSE, NULL);
	gtk_notebook_set_tab_label(GTK_NOTEBOOK(nb_set_m),
		gtk_notebook_get_nth_page(GTK_NOTEBOOK(nb_set_m), 1),lab_e);

	vbox_nb_uq = gtk_box_new(GTK_ORIENTATION_VERTICAL , 0);
	gtk_container_add(GTK_CONTAINER(nb_set_m), vbox_nb_uq);
	lab_e = gtk_label_new("Queue");
	g_object_set(G_OBJECT(lab_e), "can-focus", FALSE, NULL);
	gtk_notebook_set_tab_label(GTK_NOTEBOOK(nb_set_m),
		gtk_notebook_get_nth_page(GTK_NOTEBOOK(nb_set_m), 2),lab_e);

	grid_up = gtk_grid_new ();
	gtk_box_pack_start(GTK_BOX(vbox_nb_up), grid_up , FALSE, FALSE, 0);

	lab_e = gtk_label_new("Profiles:	");
	gtk_grid_attach (GTK_GRID (grid_up),lab_e, 0, 0, 2,  1);

	com_upm_pl = gtk_combo_box_text_new();
	gtk_grid_attach (GTK_GRID (grid_up),com_upm_pl, 2, 0, 2,  1);
	profiles_combo_fill();

	hbox_um_s = gtk_box_new(GTK_ORIENTATION_HORIZONTAL , 0);
	gtk_grid_attach (GTK_GRID (grid_up),hbox_um_s, 4, 0, 4,  1);

	GtkWidget *but_up_act = gtk_button_new_with_label("Activate");
	g_signal_connect(but_up_act,"clicked",G_CALLBACK(profiles_profile_activate), NULL);
	gtk_box_pack_start(GTK_BOX(hbox_um_s),GTK_WIDGET(but_up_act),TRUE,TRUE,0);

	GtkWidget *but_up_edit = gtk_button_new_with_label("Edit");
	g_signal_connect(but_up_edit,"clicked",G_CALLBACK(profiles_profile_edit), NULL);
	gtk_box_pack_start(GTK_BOX(hbox_um_s),GTK_WIDGET(but_up_edit),TRUE,TRUE,0);

	hbox_um_s = gtk_box_new(GTK_ORIENTATION_HORIZONTAL , 0);
	gtk_grid_attach (GTK_GRID (grid_up),hbox_um_s, 8, 0, 4,  1);

	GtkWidget *but_up_add = gtk_button_new_with_label("Add New");
	g_signal_connect(but_up_add,"clicked",G_CALLBACK(profiles_window_create), NULL);
	gtk_box_pack_end(GTK_BOX(hbox_um_s),GTK_WIDGET(but_up_add),TRUE,FALSE,0);

	GtkWidget *but_up_del = gtk_button_new_with_label("Delete");
	g_signal_connect(but_up_del,"clicked",G_CALLBACK(profiles_profile_delete), NULL);
	gtk_box_pack_start(GTK_BOX(hbox_um_s),GTK_WIDGET(but_up_del),TRUE,FALSE,0);

	lab_e = gtk_label_new("Active Profile:");
	gtk_grid_attach (GTK_GRID (grid_up),lab_e, 0, 1, 2,  1);

	lab_profile = gtk_label_new("none");
	gtk_grid_attach (GTK_GRID (grid_up),lab_profile, 2, 1, 2,  1);

	lab_e = gtk_label_new("Keep SS:");
	gtk_grid_attach (GTK_GRID (grid_up),lab_e, 4, 1, 2,  1);

	sw_up_kss = gtk_switch_new();
	gtk_grid_attach (GTK_GRID (grid_up),sw_up_kss, 6, 1, 2,  1);

    grid_um = gtk_grid_new ();
	gtk_box_pack_start(GTK_BOX(vbox_nb_um), grid_um , FALSE, FALSE, 0);

	lab_e = gtk_label_new("Picture Preview:");
	gtk_grid_attach (GTK_GRID (grid_um),lab_e, 0, 0, 2,  1);

	sw_um_pp = gtk_switch_new();
	gtk_grid_attach (GTK_GRID (grid_um),sw_um_pp, 2, 0, 2,  1);

	lab_e = gtk_label_new("Window Size:");
	gtk_grid_attach (GTK_GRID (grid_um),lab_e, 4, 0, 2,  1);

	hbox_um_s = gtk_box_new(GTK_ORIENTATION_HORIZONTAL , 0);
	gtk_grid_attach (GTK_GRID (grid_um),hbox_um_s, 6, 0, 4,  1);

	entry_um_win_w = gtk_entry_new();
	gtk_container_add(GTK_CONTAINER(hbox_um_s), entry_um_win_w);
	gtk_entry_set_width_chars(GTK_ENTRY(entry_um_win_w),5);

	lab_e = gtk_label_new("X");
	gtk_container_add(GTK_CONTAINER(hbox_um_s), lab_e);

	entry_um_win_h = gtk_entry_new();
	gtk_container_add(GTK_CONTAINER(hbox_um_s), entry_um_win_h);
	gtk_entry_set_width_chars(GTK_ENTRY(entry_um_win_h),5);

	lab_e = gtk_label_new("Animate Preview:");
	gtk_grid_attach (GTK_GRID (grid_um),lab_e, 0, 1, 2,  1);

	sw_um_ap = gtk_switch_new();
	gtk_grid_attach (GTK_GRID (grid_um),sw_um_ap, 2, 1, 2,  1);

	lab_e = gtk_label_new("Preview Size:");
	gtk_grid_attach (GTK_GRID (grid_um),lab_e, 4, 1, 2,  1);

	hbox_um_s = gtk_box_new(GTK_ORIENTATION_HORIZONTAL , 0);
	gtk_grid_attach (GTK_GRID (grid_um),hbox_um_s, 6, 1, 4,  1);

	entry_um_pw_w = gtk_entry_new();
	gtk_container_add(GTK_CONTAINER(hbox_um_s), entry_um_pw_w);
	gtk_entry_set_width_chars(GTK_ENTRY(entry_um_pw_w),5);

	lab_e = gtk_label_new("X");
	gtk_container_add(GTK_CONTAINER(hbox_um_s), lab_e);

	entry_um_pw_h = gtk_entry_new();
	gtk_container_add(GTK_CONTAINER(hbox_um_s), entry_um_pw_h);
	gtk_entry_set_width_chars(GTK_ENTRY(entry_um_pw_h),5);

	lab_e = gtk_label_new("Window Position:");
	gtk_grid_attach (GTK_GRID (grid_um),lab_e, 4, 2, 2,  1);

	com_um_wp = gtk_combo_box_text_new();
    gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_um_wp), NULL, "Default");
    gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_um_wp), NULL, "Center");
    gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_um_wp), NULL, "Mouse");
	gtk_grid_attach (GTK_GRID (grid_um),com_um_wp, 6, 2, 2,  1);

	lab_e = gtk_label_new("Enable Double Click:");
	gtk_grid_attach (GTK_GRID (grid_um),lab_e, 0, 3, 2,  1);

	sw_um_dc = gtk_switch_new();
	gtk_grid_attach (GTK_GRID (grid_um),sw_um_dc, 2, 3, 2,  1);

	lab_e = gtk_label_new("Action:");
	gtk_grid_attach (GTK_GRID (grid_um),lab_e, 4, 3, 2,  1);

	com_um_dca = gtk_combo_box_text_new();
    gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_um_dca), NULL, "Open File");
    gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_um_dca), NULL, "Open Link");
    gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_um_dca), NULL, "Open Folder");
    gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_um_dca), NULL, "Copy URL");
	gtk_grid_attach (GTK_GRID (grid_um),com_um_dca, 6, 3, 2,  1);

	grid_uq = gtk_grid_new ();
	gtk_box_pack_start(GTK_BOX(vbox_nb_uq), grid_uq , FALSE, FALSE, 0);

	lab_e = gtk_label_new("Window Position:");
	gtk_grid_attach (GTK_GRID (grid_uq),lab_e, 0, 0, 2,  1);

	com_uq_wp = gtk_combo_box_text_new();
    gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_uq_wp), NULL, "Default");
    gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_uq_wp), NULL, "Center");
    gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_uq_wp), NULL, "Mouse");
	gtk_grid_attach (GTK_GRID (grid_uq),com_uq_wp, 2, 0, 2,  1);

	lab_e = gtk_label_new("Window Size:");
	gtk_grid_attach (GTK_GRID (grid_uq),lab_e, 4, 0, 2,  1);

	hbox_um_s = gtk_box_new(GTK_ORIENTATION_HORIZONTAL , 0);
	gtk_grid_attach (GTK_GRID (grid_uq),hbox_um_s, 6, 0, 4,  1);

	entry_uq_win_w = gtk_entry_new();
	gtk_container_add(GTK_CONTAINER(hbox_um_s), entry_uq_win_w);
	gtk_entry_set_width_chars(GTK_ENTRY(entry_uq_win_w),5);

	lab_e = gtk_label_new("X");
	gtk_container_add(GTK_CONTAINER(hbox_um_s), lab_e);

	entry_uq_win_h = gtk_entry_new();
	gtk_container_add(GTK_CONTAINER(hbox_um_s), entry_uq_win_h);
	gtk_entry_set_width_chars(GTK_ENTRY(entry_uq_win_h),5);

	hbox_set_m = gtk_box_new(GTK_ORIENTATION_HORIZONTAL , 0);
	gtk_box_pack_end(GTK_BOX(vbox_set_m), hbox_set_m, FALSE, FALSE, 0);

	but_set_reset = gtk_button_new_with_label("Reset Settings");
	g_signal_connect(but_set_reset,"clicked",G_CALLBACK(settings_conf_default), NULL);
	gtk_container_add(GTK_CONTAINER(hbox_set_m), but_set_reset);

	but_set_close = gtk_button_new_with_label("    Close    ");
	g_signal_connect(but_set_close,"clicked",G_CALLBACK(settings_window_destroy), NULL);
	gtk_box_pack_end(GTK_BOX(hbox_set_m),GTK_WIDGET(but_set_close),FALSE,FALSE,0);

	but_set_save = gtk_button_new_with_label("Save & Close");
	g_signal_connect(but_set_save,"clicked",G_CALLBACK(settings_conf_save), NULL);
	gtk_box_pack_end(GTK_BOX(hbox_set_m),GTK_WIDGET(but_set_save),FALSE,FALSE,0);

	settings_window_create_set_actives();
	gtk_widget_show_all(win_set_main);
}
예제 #6
0
GtkWidget *
pgd_forms_create_widget (PopplerDocument *document)
{
	PgdFormsDemo     *demo;
	GtkWidget        *label;
	GtkWidget        *vbox;
	GtkWidget        *hbox, *page_selector;
	GtkWidget        *button;
	GtkWidget        *hpaned;
	GtkWidget        *swindow, *treeview;
	GtkTreeSelection *selection;
	GtkCellRenderer  *renderer;
	gchar            *str;
	gint              n_pages;

	demo = g_new0 (PgdFormsDemo, 1);
	
	demo->doc = g_object_ref (document);
	
	n_pages = poppler_document_get_n_pages (document);

	vbox = gtk_vbox_new (FALSE, 12);

	hbox = gtk_hbox_new (FALSE, 6);

	label = gtk_label_new ("Page:");
	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
	gtk_widget_show (label);

	page_selector = gtk_spin_button_new_with_range (1, n_pages, 1);
	g_signal_connect (G_OBJECT (page_selector), "value-changed",
			  G_CALLBACK (pgd_forms_page_selector_value_changed),
			  (gpointer)demo);
	gtk_box_pack_start (GTK_BOX (hbox), page_selector, FALSE, TRUE, 0);
	gtk_widget_show (page_selector);

	str = g_strdup_printf ("of %d", n_pages);
	label = gtk_label_new (str);
	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
	gtk_widget_show (label);
	g_free (str);

	button = gtk_button_new_with_label ("Get Forms Fields");
	g_signal_connect (G_OBJECT (button), "clicked",
			  G_CALLBACK (pgd_forms_get_form_fields),
			  (gpointer)demo);
	gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
	gtk_widget_show (button);

	gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
	gtk_widget_show (hbox);

	demo->timer_label = gtk_label_new (NULL);
	gtk_label_set_markup (GTK_LABEL (demo->timer_label), "<i>No form fields found</i>");
	g_object_set (G_OBJECT (demo->timer_label), "xalign", 1.0, NULL);
	gtk_box_pack_start (GTK_BOX (vbox), demo->timer_label, FALSE, TRUE, 0);
	gtk_widget_show (demo->timer_label);

	hpaned = gtk_hpaned_new ();

	demo->field_view = pgd_form_field_view_new ();

	swindow = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
					GTK_POLICY_AUTOMATIC,
					GTK_POLICY_AUTOMATIC);
	
	demo->model = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING,
					  G_TYPE_INT, G_TYPE_BOOLEAN,
					  G_TYPE_STRING,
					  G_TYPE_STRING, G_TYPE_STRING,
					  G_TYPE_STRING, G_TYPE_OBJECT);
	treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (demo->model));

	renderer = gtk_cell_renderer_text_new ();
	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
						     0, "Form Field Type",
						     renderer,
						     "text", FORMS_FIELD_TYPE_COLUMN,
						     NULL);
	
	renderer = gtk_cell_renderer_text_new ();
	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
						     1, "Form Field Id",
						     renderer,
						     "text", FORMS_ID_COLUMN,
						     NULL);
	
	renderer = gtk_cell_renderer_toggle_new ();
	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
						     2, "Read Only",
						     renderer,
						     "active", FORMS_READ_ONLY_COLUMN,
						     NULL);

	renderer = gtk_cell_renderer_text_new ();
	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
						     3, "X1",
						     renderer,
						     "text", FORMS_X1_COLUMN,
						     NULL);
	renderer = gtk_cell_renderer_text_new ();
	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
						     4, "Y1",
						     renderer,
						     "text", FORMS_Y1_COLUMN,
						     NULL);
	renderer = gtk_cell_renderer_text_new ();
	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
						     5, "X2",
						     renderer,
						     "text", FORMS_X2_COLUMN,
						     NULL);
	renderer = gtk_cell_renderer_text_new ();
	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
						     6, "Y2",
						     renderer,
						     "text", FORMS_Y2_COLUMN,
						     NULL);
	
	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
	g_signal_connect (G_OBJECT (selection), "changed",
			  G_CALLBACK (pgd_forms_selection_changed),
			  (gpointer)demo);

	gtk_container_add (GTK_CONTAINER (swindow), treeview);
	gtk_widget_show (treeview);

	gtk_paned_add1 (GTK_PANED (hpaned), swindow);
	gtk_widget_show (swindow);

	gtk_paned_add2 (GTK_PANED (hpaned), demo->field_view);
	gtk_widget_show (demo->field_view);

	gtk_paned_set_position (GTK_PANED (hpaned), 300);

	gtk_box_pack_start (GTK_BOX (vbox), hpaned, TRUE, TRUE, 0);
	gtk_widget_show (hpaned);

	g_object_weak_ref (G_OBJECT (vbox),
			   (GWeakNotify)pgd_forms_free,
			   demo);
	
	return vbox;
}
int main( int   argc, 
          char *argv[] )
{
  GtkWidget *window;
  GtkWidget *drawing_area;
  GtkWidget *vbox;
  GtkWidget *v1box;
  GtkWidget *hbox;
  GtkWidget *button;
  
  gtk_init (&argc, &argv);
  printf("Helo\n");
  int i,j;
	for(i=0;i<1000;i++)
	{
		for(j=0;j<1000;j++)
		{
			pixels[i][j]=0;
			visited[i][j]=0;
		}
	}
	

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
  gtk_window_set_title(GTK_WINDOW(window), "pencil_project");

  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (window), vbox);
  gtk_widget_show (vbox);

  g_signal_connect (GTK_WINDOW(window), "destroy",
                    G_CALLBACK (quit), NULL);

  hbox = gtk_hbox_new (FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
  gtk_widget_show (hbox);
  v1box = newVerticalbox ( FALSE, 0, TRUE, TRUE, 0 );
  gtk_box_pack_start (GTK_BOX (hbox), v1box, FALSE, FALSE, 0);
  gtk_widget_show (v1box);
  
    /* Create the drawing area */
    
  drawing_area = gtk_drawing_area_new ();
  gtk_widget_set_size_request (GTK_WIDGET (drawing_area), breadth, height);//breadth,height global variables in buttons.h
  //cr = gdk_cairo_create(drawing_area->window);
  gtk_box_pack_start (GTK_BOX (hbox), drawing_area, TRUE, TRUE, 0);

  gtk_widget_show (drawing_area);

  g_signal_connect (drawing_area, "expose_event",
		    G_CALLBACK (expose_event),NULL);
 /* g_signal_connect (drawing_area, "configure_event",
		    G_CALLBACK (configure_event), NULL);

  /* Event signals */

  g_signal_connect (drawing_area, "motion_notify_event",
		    G_CALLBACK (motion_notify_event), NULL);//made them null as it don't have significance.
  handler_id = g_signal_connect (drawing_area, "button_press_event",
		    G_CALLBACK (button_press_event), NULL);

  gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK
			 |GDK_LEAVE_NOTIFY_MASK
			 | GDK_BUTTON_PRESS_MASK
			 |GDK_POINTER_MOTION_MASK
			 | GDK_POINTER_MOTION_HINT_MASK);
  button = horizontal_box ( FALSE, 0, TRUE, TRUE, 0, TRUE );
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
  button = horizontal_box ( FALSE, 0, TRUE, TRUE, 0, FALSE );
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);   
  
   button = gtk_button_new_with_label ("Fill");
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
  g_signal_connect_swapped (button, "clicked", G_CALLBACK (button_press_event_fill), drawing_area);
 
                           
  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}
예제 #8
0
static void
word_list_window_init (WordListWindow *window)
{
  GtkWidget *word_list, *vbox, *statusbar;
  GtkUIManager *ui;
  GtkActionGroup *actions;

  gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
  gtk_window_set_default_size(GTK_WINDOW(window), 600, 450);
  gtk_window_set_title(GTK_WINDOW(window), _("Edit the dictionary"));

#if GTK_CHECK_VERSION(3, 2, 0)
  vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
#else
  vbox = gtk_vbox_new(FALSE, 0);
#endif
  gtk_container_add(GTK_CONTAINER(window), vbox);
  gtk_widget_show(vbox);

  window->action_group = actions = gtk_action_group_new("Actions");
#if ENABLE_NLS
  gtk_action_group_set_translate_func(window->action_group,
				      translate_func, NULL, NULL);
#endif
  gtk_action_group_add_actions(actions, menu_action_entries,
			       n_menu_action_entries, window);

  gtk_action_group_add_radio_actions(actions, dictionary_entries,
				     n_dictionary_entries,
				     DICT_ENUM_DICTIONARY_TYPE_ANTHY,
				     G_CALLBACK(activate_radio_action),
				     window);

  window->ui_manager = ui = gtk_ui_manager_new();
  gtk_ui_manager_insert_action_group(ui, actions, 0);
  g_signal_connect(ui, "add_widget",
		   G_CALLBACK(add_widget_cb),
		   vbox);
  gtk_window_add_accel_group(GTK_WINDOW(window),
			     gtk_ui_manager_get_accel_group(ui));

  gtk_ui_manager_add_ui_from_file(ui,
				  UIM_DATADIR "/helperdata/uim-dict-ui.xml",
				  NULL);
  gtk_ui_manager_ensure_update(ui);

  window->word_list = word_list = word_list_view_new();
  word_list_view_set_visible_cclass_code_column(WORD_LIST_VIEW(word_list), TRUE);
  word_list_view_set_visible_freq_column(WORD_LIST_VIEW(word_list), TRUE);
  gtk_widget_show(word_list);
  gtk_box_pack_start(GTK_BOX(vbox), word_list, TRUE, TRUE, 0);

  g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN(window->word_list))),
		   "button-press-event",
		   G_CALLBACK(word_list_button_press_cb), window);
  g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN(window->word_list))),
		   "row-activated",
		   G_CALLBACK(word_list_row_activated_cb), window);
  g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN(window->word_list))),
		   "key-press-event",
		   G_CALLBACK(word_list_key_press_cb), window);
  g_signal_connect(G_OBJECT(WORD_LIST_VIEW(window->word_list)->selection),
		   "changed",
		   G_CALLBACK(word_list_selection_changed_cb), window);

  window->statusbar = statusbar = gtk_statusbar_new();
  gtk_box_pack_start(GTK_BOX(vbox), statusbar, FALSE, FALSE, 0);
  gtk_widget_show(statusbar);

  word_list_window_set_sensitive(window);
}
예제 #9
0
static void
help_about_action_cb(GtkAction *action, WordListWindow *window)
{
  const gchar *name = N_("uim-dict");
#if GTK_CHECK_VERSION(2, 6, 0)
  GdkPixbuf *pixbuf, *transparent;
  const gchar *filename = UIM_PIXMAPSDIR "/uim-dict.png";
  const gchar *authors[] = {
    "Masahito Omote <*****@*****.**>",
    "Takuro Ashie",
    "Etsushi Kato",
    NULL
  };
  const gchar *copyright = N_(
    "Copyright (C) 2003-2004 Masahito Omote\n"
    "Copyright (C) 2004-2013 uim Project\n"
    "All rights reserved.");

  transparent = NULL;
  pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
  if (pixbuf) {
    transparent = gdk_pixbuf_add_alpha(pixbuf, TRUE, 0xff, 0xff, 0xff);
    g_object_unref(pixbuf);
  }
  
#if !GTK_CHECK_VERSION(2, 18, 0)
  gtk_about_dialog_set_url_hook (activate_url, NULL, NULL);
#endif
  gtk_show_about_dialog (GTK_WINDOW(window),
			 "name", name,
			 "version", VERSION,
			 "copyright", copyright,
			 "website", "https://github.com/uim/uim",
			 "authors", authors,
			 "logo", transparent,
			 NULL);
  g_object_unref(transparent);
#else
  GtkWidget *about_dialog, *label1;
  const gchar *copyright = N_(
    "Copyright 2003-2004 Masahito Omote &lt;[email protected]&gt;\n"
    "Copyright 2004-2013 uim Project https://github.com/uim/uim\n"
    "All rights reserved.");
  gchar *about_name =
    g_strdup_printf("<span size=\"20000\">%s %s </span>\n\n<span size=\"14000\">%s </span>\n", _(name), VERSION, _(copyright));

  about_dialog = gtk_dialog_new_with_buttons(_("About uim-dict"), NULL,
					     GTK_DIALOG_MODAL,
					     GTK_STOCK_OK,
					     GTK_RESPONSE_ACCEPT, NULL);
  gtk_container_set_border_width(GTK_CONTAINER(about_dialog), 8);

  label1 = gtk_label_new(NULL);
  gtk_widget_show(label1);
  gtk_label_set_markup(GTK_LABEL(label1), about_name);
  g_free(about_name);
  gtk_box_pack_start(
      GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(about_dialog))),
      label1, FALSE, FALSE, 0);

  gtk_window_set_transient_for(GTK_WINDOW(about_dialog),
			       GTK_WINDOW(window));
  gtk_window_set_position(GTK_WINDOW(about_dialog),
			  GTK_WIN_POS_CENTER_ON_PARENT);
  gtk_dialog_run(GTK_DIALOG(about_dialog));

  gtk_widget_destroy(about_dialog);
#endif
}
예제 #10
0
파일: minifram.cpp 프로젝트: gitrider/wxsj2
bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
      const wxPoint &pos, const wxSize &size,
      long style, const wxString &name )
{
    style = style | wxCAPTION;

    if ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT))
        m_miniTitle = 13;

    m_miniEdge = 3;
    m_isDragging = FALSE;
    m_oldX = -1;
    m_oldY = -1;
    m_diffX = 0;
    m_diffY = 0;

    wxFrame::Create( parent, id, title, pos, size, style, name );

    if (m_parent && (GTK_IS_WINDOW(m_parent->m_widget)))
    {
        gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(m_parent->m_widget) );
    }
    
    if ((style & wxSYSTEM_MENU) &&
        ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT)))
    {
        GdkBitmap *mask = (GdkBitmap*) NULL;
        GdkPixmap *pixmap = gdk_pixmap_create_from_xpm_d
                            (
                                wxGetRootWindow()->window,
                                &mask,
                                NULL,
                                (char **)cross_xpm
                            );

        GtkWidget *pw = gtk_pixmap_new( pixmap, mask );
        gdk_bitmap_unref( mask );
        gdk_pixmap_unref( pixmap );
        gtk_widget_show( pw );

        GtkWidget *close_button = gtk_button_new();
        gtk_container_add( GTK_CONTAINER(close_button), pw );

        gtk_pizza_put( GTK_PIZZA(m_mainWidget),
                         close_button,
                         size.x-16, 4, 11, 11 );

        gtk_widget_show( close_button );

        gtk_signal_connect( GTK_OBJECT(close_button), "clicked",
          GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this );
    }

    /* these are called when the borders are drawn */
    gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event",
        GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this );

#ifndef __WXGTK20__
    gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw",
       GTK_SIGNAL_FUNC(gtk_window_own_draw_callback), (gpointer)this );
#endif

    /* these are required for dragging the mini frame around */
    gtk_signal_connect( GTK_OBJECT(m_mainWidget), "button_press_event",
      GTK_SIGNAL_FUNC(gtk_window_button_press_callback), (gpointer)this );

    gtk_signal_connect( GTK_OBJECT(m_mainWidget), "button_release_event",
      GTK_SIGNAL_FUNC(gtk_window_button_release_callback), (gpointer)this );

    gtk_signal_connect( GTK_OBJECT(m_mainWidget), "motion_notify_event",
      GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback), (gpointer)this );

    return TRUE;
}
GtkWidget *
x264_gtk_encode_status_window (X264_Thread_Data *thread_data)
{
  GtkWidget *win_status;
  GtkWidget *table;
  GtkWidget *label;

  if (!thread_data) return NULL;

  win_status = thread_data->dialog = gtk_dialog_new ();
  gtk_window_set_title  (GTK_WINDOW (win_status), _("Encoding status"));
  thread_data->button = gtk_dialog_add_button (GTK_DIALOG (win_status),
                                               GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
  thread_data->end_button = gtk_dialog_add_button (GTK_DIALOG (thread_data->dialog),
                                                   GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL);
  gtk_widget_set_sensitive (thread_data->end_button, FALSE);

  g_signal_connect (G_OBJECT (win_status),
                    "delete-event",
                    G_CALLBACK (_delete_window_cb),
                    thread_data);
  g_signal_connect (G_OBJECT (win_status),
                    "response",
                    G_CALLBACK (_response_window_cb),
                    thread_data);

  table = gtk_table_new (5, 2, FALSE);
  gtk_table_set_row_spacings (GTK_TABLE (table), 6);
  gtk_table_set_col_spacings (GTK_TABLE (table), 6);
  gtk_container_set_border_width (GTK_CONTAINER (table), 6);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (win_status)->vbox), table,
                      FALSE, FALSE, 0);
  gtk_widget_show (table);

  label = gtk_label_new (_("Current video frame:"));
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1);
  gtk_widget_show (label);

  thread_data->current_video_frame = gtk_entry_new ();
  gtk_editable_set_editable (GTK_EDITABLE (thread_data->current_video_frame), FALSE);
  gtk_table_attach_defaults (GTK_TABLE (table),
                             thread_data->current_video_frame,
                             1, 2, 0, 1);
  gtk_widget_show (thread_data->current_video_frame);

  label = gtk_label_new (_("Video data:"));
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2);
  gtk_widget_show (label);

  thread_data->video_data = gtk_entry_new ();
  gtk_entry_set_text (GTK_ENTRY (thread_data->video_data), _("0KB"));
  gtk_editable_set_editable (GTK_EDITABLE (thread_data->video_data), FALSE);
  gtk_table_attach_defaults (GTK_TABLE (table), thread_data->video_data,
                             1, 2, 1, 2);
  gtk_widget_show (thread_data->video_data);

  label = gtk_label_new (_("Video rendering rate:"));
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 2, 3);
  gtk_widget_show (label);

  thread_data->video_rendering_rate = gtk_entry_new ();
  gtk_editable_set_editable (GTK_EDITABLE (thread_data->video_rendering_rate), FALSE);
  gtk_table_attach_defaults (GTK_TABLE (table),
                             thread_data->video_rendering_rate,
                             1, 2, 2, 3);
  gtk_widget_show (thread_data->video_rendering_rate);

  label = gtk_label_new (_("Time elapsed:"));
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 3, 4);
  gtk_widget_show (label);

  thread_data->time_elapsed = gtk_entry_new ();
  gtk_editable_set_editable (GTK_EDITABLE (thread_data->time_elapsed), FALSE);
  gtk_table_attach_defaults (GTK_TABLE (table), thread_data->time_elapsed,
                             1, 2, 3, 4);
  gtk_widget_show (thread_data->time_elapsed);

  label = gtk_label_new (_("Time remaining (estimated):"));
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 4, 5);
  gtk_widget_show (label);

  thread_data->time_remaining = gtk_entry_new ();
  gtk_editable_set_editable (GTK_EDITABLE (thread_data->time_remaining), FALSE);
  gtk_table_attach_defaults (GTK_TABLE (table), thread_data->time_remaining,
                             1, 2, 4, 5);
  gtk_widget_show (thread_data->time_remaining);

  table = gtk_table_new (1, 2, FALSE);
  gtk_table_set_row_spacings (GTK_TABLE (table), 6);
  gtk_table_set_col_spacings (GTK_TABLE (table), 6);
  gtk_container_set_border_width (GTK_CONTAINER (table), 6);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (win_status)->vbox), table,
                      FALSE, FALSE, 0);
  gtk_widget_show (table);

  label = gtk_label_new (_("Progress:"));
  gtk_misc_set_alignment (GTK_MISC (label),
                          0.0, 0.5);
  gtk_table_attach_defaults (GTK_TABLE (table),
                             label,
                             0, 1,
                             0, 1);
  gtk_widget_show (label);

  thread_data->progress = gtk_progress_bar_new ();
  gtk_table_attach_defaults (GTK_TABLE (table), thread_data->progress,
                             1, 2, 0, 1);
  gtk_widget_show (thread_data->progress);

  return win_status;
}
예제 #12
0
int zar_sprav_m(class zar_sprav_rek *rek,GtkWidget *wpredok)
{

class zar_sprav_m_data data;
char strsql[512];
iceb_u_str kikz;
data.rk=rek;
 
data.window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position( GTK_WINDOW(data.window),ICEB_POS_CENTER);
gtk_window_set_modal(GTK_WINDOW(data.window),TRUE);

GtkWidget *label=NULL;

sprintf(strsql,"%s %s",name_system,gettext("Распечатать справку о зарплате"));

if(data.rk->metka_vr == 1)
 label=gtk_label_new(gettext("Распечатать справку о доходах"));
if(data.rk->metka_vr == 2)
 label=gtk_label_new(gettext("Распечатать расчёт средней зарплаты для начисления больничного"));
if(data.rk->metka_vr == 3)
 label=gtk_label_new(gettext("Распечатать расчёт средней зарплаты для социальной помощи"));
if(data.rk->metka_vr == 4)
 label=gtk_label_new(gettext("Распечатать справку о доходах в счёт месяцев начисления"));
if(data.rk->metka_vr == 6)
 label=gtk_label_new(gettext("Распечатать расчёт отпускных"));

gtk_window_set_title(GTK_WINDOW(data.window),strsql);
gtk_signal_connect(GTK_OBJECT(data.window),"delete_event",GTK_SIGNAL_FUNC(gtk_widget_destroy),NULL);
gtk_signal_connect(GTK_OBJECT(data.window),"destroy",GTK_SIGNAL_FUNC(gtk_main_quit),NULL);
gtk_signal_connect_after(GTK_OBJECT(data.window),"key_press_event",GTK_SIGNAL_FUNC(zar_sprav_m_key_press),&data);

if(wpredok != NULL)
 {
  gdk_window_set_cursor(wpredok->window,gdk_cursor_new(ICEB_CURSOR_GDITE));
  //Удерживать окно над породившем его окном всегда
  gtk_window_set_transient_for(GTK_WINDOW(data.window),GTK_WINDOW(wpredok));
  //Закрыть окно если окно предок удалено
  gtk_window_set_destroy_with_parent(GTK_WINDOW(data.window),TRUE);
 }

GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
GtkWidget *hbox[KOLENTER];
for(int i=0; i < KOLENTER; i++)
 hbox[i] = gtk_hbox_new (FALSE, 0);
GtkWidget *hboxknop = gtk_hbox_new (FALSE, 0);

gtk_container_add (GTK_CONTAINER (data.window), vbox);
gtk_container_add (GTK_CONTAINER (vbox), label);

data.label_fio=gtk_label_new(data.rk->fio.ravno_toutf());
gtk_container_add (GTK_CONTAINER (vbox), data.label_fio);

for(int i=0; i < KOLENTER; i++)
 gtk_container_add (GTK_CONTAINER (vbox), hbox[i]);



gtk_container_add (GTK_CONTAINER (vbox), hboxknop);

GtkTooltips *tooltips_enter[KOLENTER];

sprintf(strsql,"%s",gettext("Табельный номер"));
data.knopka_enter[E_TABNOM]=gtk_button_new_with_label(iceb_u_toutf(strsql));
gtk_box_pack_start (GTK_BOX (hbox[E_TABNOM]), data.knopka_enter[E_TABNOM], FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT(data.knopka_enter[E_TABNOM]),"clicked",GTK_SIGNAL_FUNC(zar_sprav_m_e_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka_enter[E_TABNOM]),(gpointer)E_TABNOM);
tooltips_enter[E_TABNOM]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips_enter[E_TABNOM],data.knopka_enter[E_TABNOM],gettext("Выбор табельного номера"),NULL);

data.entry[E_TABNOM] = gtk_entry_new();
gtk_box_pack_start (GTK_BOX (hbox[E_TABNOM]), data.entry[E_TABNOM], FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT (data.entry[E_TABNOM]), "activate",GTK_SIGNAL_FUNC(zar_sprav_m_vvod),&data);
gtk_entry_set_text(GTK_ENTRY(data.entry[E_TABNOM]),data.rk->tabnom.ravno_toutf());
gtk_object_set_user_data(GTK_OBJECT(data.entry[E_TABNOM]),(gpointer)E_TABNOM);



sprintf(strsql,"%s %s",gettext("Дата начала"),gettext("(м.г)"));
data.knopka_enter[E_DATAN]=gtk_button_new_with_label(iceb_u_toutf(strsql));
gtk_box_pack_start (GTK_BOX (hbox[E_DATAN]), data.knopka_enter[E_DATAN], FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT(data.knopka_enter[E_DATAN]),"clicked",GTK_SIGNAL_FUNC(zar_sprav_m_e_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka_enter[E_DATAN]),(gpointer)E_DATAN);
tooltips_enter[E_DATAN]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips_enter[E_DATAN],data.knopka_enter[E_DATAN],gettext("Выбор даты"),NULL);

data.entry[E_DATAN] = gtk_entry_new_with_max_length (7);
gtk_box_pack_start (GTK_BOX (hbox[E_DATAN]), data.entry[E_DATAN], FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT (data.entry[E_DATAN]), "activate",GTK_SIGNAL_FUNC(zar_sprav_m_vvod),&data);
gtk_entry_set_text(GTK_ENTRY(data.entry[E_DATAN]),data.rk->datan.ravno_toutf());
gtk_object_set_user_data(GTK_OBJECT(data.entry[E_DATAN]),(gpointer)E_DATAN);


sprintf(strsql,"%s %s",gettext("Дата конца"),gettext("(м.г)"));
data.knopka_enter[E_DATAK]=gtk_button_new_with_label(iceb_u_toutf(strsql));
gtk_box_pack_start (GTK_BOX (hbox[E_DATAK]), data.knopka_enter[E_DATAK], FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT(data.knopka_enter[E_DATAK]),"clicked",GTK_SIGNAL_FUNC(zar_sprav_m_e_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka_enter[E_DATAK]),(gpointer)E_DATAK);
tooltips_enter[E_DATAK]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips_enter[E_DATAK],data.knopka_enter[E_DATAK],gettext("Выбор даты"),NULL);

data.entry[E_DATAK] = gtk_entry_new_with_max_length (7);
gtk_box_pack_start (GTK_BOX (hbox[E_DATAK]), data.entry[E_DATAK], FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT (data.entry[E_DATAK]), "activate",GTK_SIGNAL_FUNC(zar_sprav_m_vvod),&data);
gtk_entry_set_text(GTK_ENTRY(data.entry[E_DATAK]),data.rk->datak.ravno_toutf());
gtk_object_set_user_data(GTK_OBJECT(data.entry[E_DATAK]),(gpointer)E_DATAK);






GtkTooltips *tooltips[KOL_FK];

sprintf(strsql,"F2 %s",gettext("Расчёт"));
data.knopka[FK2]=gtk_button_new_with_label(strsql);
tooltips[FK2]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK2],data.knopka[FK2],gettext("Начать расчёт"),NULL);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK2]),"clicked",GTK_SIGNAL_FUNC(zar_sprav_m_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK2]),(gpointer)FK2);
gtk_box_pack_start(GTK_BOX(hboxknop), data.knopka[FK2], TRUE, TRUE, 0);


sprintf(strsql,"F4 %s",gettext("Очистить"));
data.knopka[FK4]=gtk_button_new_with_label(strsql);
tooltips[FK4]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK4],data.knopka[FK4],gettext("Очистить меню от введеноой информации"),NULL);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK4]),"clicked",GTK_SIGNAL_FUNC(zar_sprav_m_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK4]),(gpointer)FK4);
gtk_box_pack_start(GTK_BOX(hboxknop), data.knopka[FK4], TRUE, TRUE, 0);

sprintf(strsql,"F5 %s",gettext("Настройка"));
data.knopka[FK5]=gtk_button_new_with_label(strsql);
tooltips[FK5]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK5],data.knopka[FK5],gettext("Настройка расчёта"),NULL);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK5]),"clicked",GTK_SIGNAL_FUNC(zar_sprav_m_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK5]),(gpointer)FK5);
gtk_box_pack_start(GTK_BOX(hboxknop), data.knopka[FK5], TRUE, TRUE, 0);


sprintf(strsql,"F10 %s",gettext("Выход"));
data.knopka[FK10]=gtk_button_new_with_label(strsql);
tooltips[FK10]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK10],data.knopka[FK10],gettext("Завершение работы в этом окне"),NULL);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK10]),"clicked",GTK_SIGNAL_FUNC(zar_sprav_m_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK10]),(gpointer)FK10);
gtk_box_pack_start(GTK_BOX(hboxknop), data.knopka[FK10], TRUE, TRUE, 0);

gtk_widget_grab_focus(data.entry[0]);

if(data.rk->metka_vr != 2 && data.rk->metka_vr != 6)
  gtk_widget_set_sensitive(GTK_WIDGET(data.knopka[FK5]),FALSE);//Недоступна

gtk_widget_show_all (data.window);

// gtk_widget_hide(data.knopka[FK5]);
 
gtk_main();

if(wpredok != NULL)
  gdk_window_set_cursor(wpredok->window,gdk_cursor_new(ICEB_CURSOR));

return(data.voz);
}
예제 #13
0
static void
gtk_ellipsis_size_allocate (GtkWidget     *widget,
			    GtkAllocation *allocation)
{
  GtkEllipsis *ellipsis;
  GtkBin *bin;
  GtkEllipsisPrivate *priv;
  GtkRequisition child_requisition;
  gint border_width;
  gint focus_width;
  gint focus_pad;

  ellipsis = GTK_ELLIPSIS (widget);
  bin = GTK_BIN (widget);
  priv = ellipsis->priv;

  border_width = GTK_CONTAINER (widget)->border_width;

  gtk_widget_style_get (widget,
			"focus-line-width", &focus_width,
			"focus-padding", &focus_pad,
			NULL);

  child_requisition.width = 0;
  child_requisition.height = 0;
  if (bin->child && priv->expanded)
    gtk_widget_get_child_requisition (bin->child, &child_requisition);

  widget->allocation = *allocation;

  if (priv->label && GTK_WIDGET_VISIBLE (priv->label) && !priv->expanded)
    {
      GtkAllocation label_allocation;
      GtkAllocation ellipsis_allocation;
      GtkRequisition ellipsis_requisition;
      PangoLayout *layout;
      gboolean ltr;

      label_allocation.y = (widget->allocation.y + border_width
			    + focus_width + focus_pad);
      label_allocation.width = MAX (1,
				    allocation->width - 2 * border_width -
				    GTK_ELLIPSIS_SPACING -
				    2 * focus_width - 2 * focus_pad);

      label_allocation.height = get_label_line_height (priv->label);
      label_allocation.height = MIN (label_allocation.height,
				     allocation->height - 2 * border_width -
				     2 * focus_width - 2 * focus_pad);
      label_allocation.height = MAX (label_allocation.height, 1);

      ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL;

      if (priv->ellipsis_label && GTK_WIDGET_VISIBLE (priv->label))
        {
          gtk_widget_get_child_requisition (priv->ellipsis_label,
					    &ellipsis_requisition);

          if (ltr)
            ellipsis_allocation.x = widget->allocation.x
				    + widget->allocation.width - border_width
			            - GTK_ELLIPSIS_OUT_SPACING
			            - ellipsis_requisition.width;
          else
            ellipsis_allocation.x = widget->allocation.x
				    + border_width
            			    + GTK_ELLIPSIS_OUT_SPACING;

          ellipsis_allocation.y = label_allocation.y;
          ellipsis_allocation.width = ellipsis_requisition.width;
          ellipsis_allocation.height = ellipsis_requisition.height;

	  gtk_widget_size_allocate (priv->ellipsis_label,
				    &ellipsis_allocation);

          label_allocation.width = MAX (1, label_allocation.width -
				        ellipsis_allocation.width);
        }

      if (ltr)
	label_allocation.x = (widget->allocation.x +
                              border_width + focus_width + focus_pad);
      else
        label_allocation.x = (widget->allocation.x + widget->allocation.width -
                              (label_allocation.width +
                               border_width + focus_width + focus_pad));

      /* HACK!  We know that GtkLabel only sets the PangoLayout's width
	 in its size_request method, so we are free to do that here.
	 Together with setting the X alignment to 0.0, this truncates
	 the label to whatever fits in the first line.  */
      layout = gtk_label_get_layout (GTK_LABEL (priv->label));
      pango_layout_set_width (layout, label_allocation.width * PANGO_SCALE);
      gtk_widget_size_allocate (priv->label, &label_allocation);

      if (GTK_WIDGET_REALIZED (widget))
        gdk_window_move_resize (priv->event_window,
			        allocation->x + border_width, 
			        allocation->y + border_width, 
			        MAX (allocation->width - 2 * border_width, 1), 
			        MAX (label_allocation.height, 1));
    }

  if (priv->expanded)
    {
      GtkAllocation child_allocation;

      child_allocation.x = widget->allocation.x + border_width;
      child_allocation.y = widget->allocation.y + border_width;
      child_allocation.width = MAX (allocation->width - 2 * border_width, 1);
      child_allocation.height = MAX (allocation->height - 2 * border_width, 1);
      gtk_widget_size_allocate (bin->child, &child_allocation);
    }

}
예제 #14
0
static void
gtk_ellipsis_realize (GtkWidget *widget)
{
  GtkEllipsis *ellipsis;
  GtkEllipsisPrivate *priv;
  GdkWindowAttr attributes;
  gint attributes_mask;
  gint border_width;
  gint label_height;

  ellipsis = GTK_ELLIPSIS (widget);
  priv = ellipsis->priv;
  GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);

  border_width = GTK_CONTAINER (widget)->border_width;

  if (priv->label && GTK_WIDGET_VISIBLE (priv->label))
    {
      gint focus_width, focus_pad;

      gtk_widget_style_get (widget,
			    "focus-line-width", &focus_width,
			    "focus-padding", &focus_pad,
			    NULL);

      label_height = get_label_line_height (priv->label);
      label_height = MIN (label_height,
                          widget->allocation.height - 2 * border_width -
                          2 * focus_width - 2 * focus_pad);
    }
  else
    label_height = 0;

  attributes.window_type = GDK_WINDOW_CHILD;
  attributes.x = widget->allocation.x + border_width;
  attributes.y = widget->allocation.y + border_width;
  attributes.width = MAX (widget->allocation.width - 2 * border_width, 1);
  attributes.height = MAX (label_height, 1);
  attributes.wclass = GDK_INPUT_ONLY;
  attributes.event_mask = gtk_widget_get_events (widget)     |
				GDK_BUTTON_PRESS_MASK        |
				GDK_BUTTON_RELEASE_MASK      |
				GDK_ENTER_NOTIFY_MASK        |
				GDK_LEAVE_NOTIFY_MASK;

  attributes_mask = GDK_WA_X | GDK_WA_Y;
  if (GTK_WIDGET_IS_SENSITIVE (widget))
    {
      attributes.cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
                                                      GTK_ELLIPSIS_CURSOR);
      attributes_mask |= GDK_WA_CURSOR;
    }

  widget->window = gtk_widget_get_parent_window (widget);
  g_object_ref (widget->window);

  priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
				       &attributes, attributes_mask);
  gdk_window_set_user_data (priv->event_window, widget);
  if (attributes_mask & GDK_WA_CURSOR)
    gdk_cursor_unref (attributes.cursor);

  widget->style = gtk_style_attach (widget->style, widget->window);

  if (priv->label && GTK_WIDGET_VISIBLE (priv->label) && !priv->expanded)
    gdk_window_show (priv->event_window);
}
예제 #15
0
파일: gtk_glue.c 프로젝트: claywagnerio/gtk
GtkContainer* cast_GtkContainer(GtkWidget* widget) {
    return GTK_CONTAINER(widget);
}
예제 #16
0
GtkWidget *
prefs_common_page (void)
{
    GtkWidget *main_vbox;
    GtkWidget *vbox1;
    GtkWidget *frame1;
    GtkWidget *button1;
    GtkWidget *button2;
    GSList *vbox1_group = NULL;
    GtkWidget *frame2;
    GtkWidget *vbox2;
    GtkWidget *radiobutton1;
    GtkWidget *radiobutton2;
    GtkWidget *radiobutton3;
    GtkWidget *checkbutton1;
    GtkWidget *checkbutton2;

    main_vbox = gtk_vbox_new (FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 10);

    frame1 = gtk_frame_new (_(" Startup Directory "));
    gtk_box_pack_start (GTK_BOX (main_vbox), frame1, FALSE, FALSE, 0);

    vbox1 = gtk_vbox_new (FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (vbox1), 10);
    gtk_container_add (GTK_CONTAINER (frame1), vbox1);

    radiobutton1 =
	gtk_radio_button_new_with_label (vbox1_group, _("Home directory"));
    vbox1_group = gtk_radio_button_group (GTK_RADIO_BUTTON (radiobutton1));
    gtk_box_pack_start (GTK_BOX (vbox1), radiobutton1, FALSE, FALSE, 0);

    radiobutton2 =
	gtk_radio_button_new_with_label (vbox1_group,
					 _("Go to last visited location"));
    vbox1_group = gtk_radio_button_group (GTK_RADIO_BUTTON (radiobutton2));
    gtk_box_pack_start (GTK_BOX (vbox1), radiobutton2, FALSE, FALSE, 0);

    radiobutton3 =
	gtk_radio_button_new_with_label (vbox1_group,
					 _("Go to this directory:"));
    vbox1_group = gtk_radio_button_group (GTK_RADIO_BUTTON (radiobutton3));
    gtk_box_pack_start (GTK_BOX (vbox1), radiobutton3, FALSE, FALSE, 0);

    prefs_win.startup_dir_table = gtk_table_new (2, 2, FALSE);
    gtk_box_pack_start (GTK_BOX (vbox1), prefs_win.startup_dir_table, TRUE,
			TRUE, 0);

    prefs_win.startup_dir_entry = gtk_entry_new ();
    gtk_table_attach (GTK_TABLE (prefs_win.startup_dir_table),
		      prefs_win.startup_dir_entry, 0, 1, 0, 1,
		      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
		      (GtkAttachOptions) (0), 0, 0);

    button1 = gtk_button_new_with_label (_("Browse..."));
    gtk_table_attach (GTK_TABLE (prefs_win.startup_dir_table), button1, 1, 2,
		      0, 1, (GtkAttachOptions) (GTK_FILL),
		      (GtkAttachOptions) (0), 0, 0);

    button2 = gtk_button_new_with_label (_("Current"));
    gtk_table_attach (GTK_TABLE (prefs_win.startup_dir_table), button2, 1, 2,
		      1, 2, (GtkAttachOptions) (GTK_FILL),
		      (GtkAttachOptions) (0), 0, 0);
    gtk_widget_set_usize (button2, 90, -2);
    gtk_widget_show_all (frame1);

    frame2 = gtk_frame_new (_(" Main Window "));
    gtk_box_pack_start (GTK_BOX (main_vbox), frame2, FALSE, FALSE, 10);

    vbox2 = gtk_vbox_new (FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (vbox2), 10);
    gtk_container_add (GTK_CONTAINER (frame2), vbox2);

    checkbutton1 =
	gtk_check_button_new_with_label (_("Remember window size"));
    gtk_box_pack_start (GTK_BOX (vbox2), checkbutton1, FALSE, FALSE, 0);

    checkbutton2 = gtk_check_button_new_with_label (_("Enable/Disable dock"));
    gtk_box_pack_start (GTK_BOX (vbox2), checkbutton2, FALSE, FALSE, 0);
    gtk_widget_show_all (frame2);

    gtk_widget_set_sensitive (GTK_WIDGET (prefs_win.startup_dir_table),
			      FALSE);

    if (conf.startup_dir_mode == 0)
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton1), TRUE);
    else if (conf.startup_dir_mode == 1)
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton2), TRUE);
    else
    {
	gtk_entry_set_text (GTK_ENTRY (prefs_win.startup_dir_entry),
			    conf.startup_dir);

	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton3), TRUE);
	gtk_widget_set_sensitive (GTK_WIDGET (prefs_win.startup_dir_table),
				  TRUE);
    }

    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton1),
				  conf.save_win_state);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton2),
				  conf.enable_dock);

    gtk_signal_connect (GTK_OBJECT (radiobutton1), "toggled",
			GTK_SIGNAL_FUNC
			(cb_startup_dir_mode), GINT_TO_POINTER (0));

    gtk_signal_connect (GTK_OBJECT (radiobutton2), "toggled",
			GTK_SIGNAL_FUNC
			(cb_startup_dir_mode), GINT_TO_POINTER (1));

    gtk_signal_connect (GTK_OBJECT (radiobutton3), "toggled",
			GTK_SIGNAL_FUNC
			(cb_startup_dir_mode), GINT_TO_POINTER (3));

    gtk_signal_connect (GTK_OBJECT (button1), "clicked",
			GTK_SIGNAL_FUNC (cb_startup_dir_browse), NULL);

    gtk_signal_connect (GTK_OBJECT (button2), "clicked",
			GTK_SIGNAL_FUNC (cb_startup_dir_current), NULL);

    gtk_signal_connect (GTK_OBJECT (prefs_win.startup_dir_entry), "changed",
			GTK_SIGNAL_FUNC (cb_startup_dir_entry), NULL);

    gtk_signal_connect (GTK_OBJECT (checkbutton1), "clicked",
			GTK_SIGNAL_FUNC (cb_save_win_state), checkbutton1);

    gtk_signal_connect (GTK_OBJECT (checkbutton2), "clicked",
			GTK_SIGNAL_FUNC (cb_enable_dock), checkbutton2);

    return main_vbox;
}
예제 #17
0
static void
pgd_form_field_view_set_field (GtkWidget        *field_view,
			       PopplerFormField *field)
{
	GtkWidget  *alignment;
	GtkWidget  *table;
	GEnumValue *enum_value;
	gchar      *text;
	gint        row = 0;

	alignment = gtk_bin_get_child (GTK_BIN (field_view));
	if (alignment) {
		gtk_container_remove (GTK_CONTAINER (field_view), alignment);
	}
	
	alignment = gtk_alignment_new (0.5, 0.5, 1, 1);
	gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 12, 5);
	gtk_container_add (GTK_CONTAINER (field_view), alignment);
	gtk_widget_show (alignment);

	if (!field)
		return;

	table = gtk_table_new (13, 2, FALSE);
	gtk_table_set_col_spacings (GTK_TABLE (table), 6);
	gtk_table_set_row_spacings (GTK_TABLE (table), 6);

	text = poppler_form_field_get_name (field);
	if (text) {
		pgd_table_add_property (GTK_TABLE (table), "<b>Name:</b>", text, &row);
		g_free (text);
	}
	text = poppler_form_field_get_partial_name (field);
	if (text) {
		pgd_table_add_property (GTK_TABLE (table), "<b>Partial Name:</b>", text, &row);
		g_free (text);
	}
	text = poppler_form_field_get_mapping_name (field);
	if (text) {
		pgd_table_add_property (GTK_TABLE (table), "<b>Mapping Name:</b>", text, &row);
		g_free (text);
	}

	switch (poppler_form_field_get_field_type (field)) {
	case POPPLER_FORM_FIELD_BUTTON:
		enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (POPPLER_TYPE_FORM_BUTTON_TYPE),
					       poppler_form_field_button_get_button_type (field));
		pgd_table_add_property (GTK_TABLE (table), "<b>Button Type:</b>", enum_value->value_name, &row);
		pgd_table_add_property (GTK_TABLE (table), "<b>Button State:</b>",
					poppler_form_field_button_get_state (field) ? "Active" : "Inactive", &row);
		break;
	case POPPLER_FORM_FIELD_TEXT:
		enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (POPPLER_TYPE_FORM_TEXT_TYPE),
					       poppler_form_field_text_get_text_type (field));
		pgd_table_add_property (GTK_TABLE (table), "<b>Text Type:</b>", enum_value->value_name, &row);

		text = poppler_form_field_text_get_text (field);
		pgd_table_add_property (GTK_TABLE (table), "<b>Contents:</b>", text, &row);
		g_free (text);

		text = g_strdup_printf ("%d", poppler_form_field_text_get_max_len (field));
		pgd_table_add_property (GTK_TABLE (table), "<b>Max Length:</b>", text, &row);
		g_free (text);

		pgd_table_add_property (GTK_TABLE (table), "<b>Do spellcheck:</b>",
					poppler_form_field_text_do_spell_check (field) ? "Yes" : "No", &row);
		pgd_table_add_property (GTK_TABLE (table), "<b>Do scroll:</b>",
					poppler_form_field_text_do_scroll (field) ? "Yes" : "No", &row);
		pgd_table_add_property (GTK_TABLE (table), "<b>Rich Text:</b>",
					poppler_form_field_text_is_rich_text (field) ? "Yes" : "No", &row);
		pgd_table_add_property (GTK_TABLE (table), "<b>Pasword type:</b>",
					poppler_form_field_text_is_password (field) ? "Yes" : "No", &row);
		break;
	case POPPLER_FORM_FIELD_CHOICE: {
		gchar *item;
		gint   selected;
		
		enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (POPPLER_TYPE_FORM_CHOICE_TYPE),
					       poppler_form_field_choice_get_choice_type (field));
		pgd_table_add_property (GTK_TABLE (table), "<b>Choice Type:</b>", enum_value->value_name, &row);
		pgd_table_add_property (GTK_TABLE (table), "<b>Editable:</b>",
					poppler_form_field_choice_is_editable (field) ? "Yes" : "No", &row);
		pgd_table_add_property (GTK_TABLE (table), "<b>Multiple Selection:</b>",
					poppler_form_field_choice_can_select_multiple (field) ? "Yes" : "No", &row);
		pgd_table_add_property (GTK_TABLE (table), "<b>Do spellcheck:</b>",
					poppler_form_field_choice_do_spell_check (field) ? "Yes" : "No", &row);
		pgd_table_add_property (GTK_TABLE (table), "<b>Commit on Change:</b>",
					poppler_form_field_choice_commit_on_change (field) ? "Yes" : "No", &row);

		text = g_strdup_printf ("%d", poppler_form_field_choice_get_n_items (field));
		pgd_table_add_property (GTK_TABLE (table), "<b>Number of items:</b>", text, &row);
		g_free (text);

		pgd_form_field_view_add_choice_items (GTK_TABLE (table), field, &selected, &row);

		if (poppler_form_field_choice_get_n_items (field) > selected) {
			item = poppler_form_field_choice_get_item (field, selected);
			text = g_strdup_printf ("%d (%s)", selected, item);
			g_free (item);
			pgd_table_add_property (GTK_TABLE (table), "<b>Selected item:</b>", text, &row);
			g_free (text);
		}

		text = poppler_form_field_choice_get_text (field);
		pgd_table_add_property (GTK_TABLE (table), "<b>Contents:</b>", text, &row);
		g_free (text);
	}
		break;
	case POPPLER_FORM_FIELD_SIGNATURE:
	case POPPLER_FORM_FIELD_UNKNOWN:
		break;
	default:
		g_assert_not_reached ();
	}

	gtk_container_add (GTK_CONTAINER (alignment), table);
	gtk_widget_show (table);
}
예제 #18
0
GtkWidget *
prefs_filter_page (void)
{
    GtkWidget *main_vbox, *frame, *frame_vbox, *hbox, *hbox1, *vbox;
    GtkWidget *editlist, *entry;
    GtkWidget *toggle, *label;
    gchar  *titles[] = { _("Extension"), _("Type"), _("Status"), NULL };
    gint    titles_num = sizeof (titles) / sizeof (gchar *);

    main_vbox = gtk_vbox_new (FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 10);

   /********************************************** 
    * Image Types Frame
    **********************************************/
    frame = gtk_frame_new (_("Image Types"));
    gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, TRUE, 0);

    frame_vbox = gtk_vbox_new (FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (frame_vbox), 10);
    gtk_container_add (GTK_CONTAINER (frame), frame_vbox);
    gtk_widget_show (frame_vbox);
    gtk_widget_show (frame);

    editlist = editable_list_new_with_titles (titles_num, titles);
    prefs_win.filter_editlist = editlist;
    editable_list_set_reorderable (EDITABLE_LIST (editlist), FALSE);
    editable_list_set_auto_sort (EDITABLE_LIST (editlist), 0);
    gtk_box_pack_start (GTK_BOX (frame_vbox), editlist, TRUE, TRUE, 0);
    gtk_widget_show (editlist);
    gtk_widget_set_usize (editlist, -2, 320);

    /*
     * entry area 
     */
    hbox = EDITABLE_LIST (editlist)->edit_area;

    vbox = gtk_vbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
    gtk_widget_show (vbox);
    hbox1 = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (vbox), hbox1, TRUE, TRUE, 0);
    gtk_widget_show (hbox1);

    label = gtk_label_new (_("Extension: "));
    gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
    gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
    gtk_widget_show (label);

    entry =
	editable_list_create_entry (EDITABLE_LIST (editlist), 0, NULL, FALSE);
    prefs_win.filter_ext_entry = entry;
    gtk_widget_set_usize (entry, 100, -1);
    gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, TRUE, 0);
    gtk_widget_show (entry);

    vbox = gtk_vbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
    gtk_widget_show (vbox);
    hbox1 = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (vbox), hbox1, TRUE, TRUE, 0);
    gtk_widget_show (hbox1);

    label = gtk_label_new (_("Image Type: "));
    gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
    gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
    gtk_widget_show (label);
    hbox1 = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (vbox), hbox1, TRUE, TRUE, 0);
    gtk_widget_show (hbox1);

    entry = editable_list_create_entry (EDITABLE_LIST (editlist), 1,
					"UNKNOWN", FALSE);
    prefs_win.filter_type_entry = entry;
    gtk_box_pack_start (GTK_BOX (hbox1), entry, TRUE, TRUE, 0);
    gtk_widget_show (entry);

    /*
     * disable check box 
     */
    toggle = editable_list_create_check_button (EDITABLE_LIST (editlist), 2,
						_("Disable"), FALSE,
						_("Disable"), _("Enable"));
    prefs_win.filter_disable_toggle = toggle;
    gtk_box_pack_start (GTK_BOX (hbox1), toggle, FALSE, FALSE, 0);
    gtk_widget_show (toggle);

    /*
     * definition type column 
     */
    editable_list_set_column_funcs (EDITABLE_LIST (editlist),
				    NULL, 3, NULL,
				    cb_filter_deftype_get_data,
				    NULL, NULL, NULL);

    /*
     * for row data 
     */
    editable_list_set_get_row_data_func (EDITABLE_LIST (editlist),
					 cb_filter_get_row_data);

    filter_set_value ();

    gtk_signal_connect (GTK_OBJECT (editlist), "action_confirm",
			GTK_SIGNAL_FUNC (cb_filter_editlist_confirm), NULL);
    gtk_signal_connect (GTK_OBJECT (editlist), "list_updated",
			GTK_SIGNAL_FUNC (cb_filter_editlist_updated), NULL);

    return main_vbox;
}
예제 #19
0
static GtkWidget *
glade_eprop_icon_sources_create_input (GladeEditorProperty * eprop)
{
  GladeEPropIconSources *eprop_sources = GLADE_EPROP_ICON_SOURCES (eprop);
  GtkWidget *vbox, *hbox, *button, *swin;

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);

  /* hbox with comboboxentry add/remove source buttons on the right... */
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);

  eprop_sources->combo = gtk_combo_box_text_new_with_entry ();
  g_signal_connect (G_OBJECT
                    (gtk_bin_get_child (GTK_BIN (eprop_sources->combo))),
                    "activate", G_CALLBACK (icon_name_entry_activated), eprop);

  gtk_box_pack_start (GTK_BOX (hbox), eprop_sources->combo, TRUE, TRUE, 0);
  button = gtk_button_new ();
  gtk_container_set_border_width (GTK_CONTAINER (button), 2);
  gtk_button_set_image (GTK_BUTTON (button),
                        gtk_image_new_from_icon_name ("list-add-symbolic",
						      GTK_ICON_SIZE_BUTTON));
  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
  g_signal_connect (G_OBJECT (button), "clicked",
                    G_CALLBACK (add_clicked), eprop_sources);

  button = gtk_button_new ();
  gtk_button_set_image (GTK_BUTTON (button),
                        gtk_image_new_from_icon_name ("list-remove-symbolic",
						      GTK_ICON_SIZE_BUTTON));
  gtk_container_set_border_width (GTK_CONTAINER (button), 2);
  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (button), "clicked",
                    G_CALLBACK (delete_clicked), eprop_sources);

  /* Pack treeview/swindow on the left... */
  swin = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swin),
                                       GTK_SHADOW_IN);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
  gtk_box_pack_start (GTK_BOX (vbox), swin, TRUE, TRUE, 0);

  eprop_sources->view = build_view (eprop);
  gtk_container_add (GTK_CONTAINER (swin), GTK_WIDGET (eprop_sources->view));

  g_object_set (G_OBJECT (vbox), "height-request", 350, NULL);

  eprop_sources->store = gtk_tree_store_new (NUM_COLUMNS, G_TYPE_STRING,        // COLUMN_TEXT
                                             G_TYPE_INT,        // COLUMN_TEXT_WEIGHT
                                             G_TYPE_BOOLEAN,    // COLUMN_TEXT_EDITABLE
                                             G_TYPE_STRING,     // COLUMN_ICON_NAME
                                             G_TYPE_INT,        // COLUMN_LIST_INDEX
                                             G_TYPE_BOOLEAN,    // COLUMN_DIRECTION_ACTIVE
                                             G_TYPE_STRING,     // COLUMN_DIRECTION
                                             G_TYPE_BOOLEAN,    // COLUMN_SIZE_ACTIVE
                                             G_TYPE_STRING,     // COLUMN_SIZE
                                             G_TYPE_BOOLEAN,    // COLUMN_STATE_ACTIVE,
                                             G_TYPE_STRING);    // COLUMN_STATE

  gtk_tree_view_set_model (eprop_sources->view,
                           GTK_TREE_MODEL (eprop_sources->store));
  g_object_unref (G_OBJECT (eprop_sources->store));     // <-- pass ownership here

  gtk_widget_show_all (vbox);
  return vbox;
}
예제 #20
0
GtkWidget *
prefs_charset_page (void)
{
    GtkWidget *main_vbox, *frame, *frame_vbox, *table, *hbox;
    GtkWidget *label, *combo, *option_menu;

    main_vbox = gtk_vbox_new (FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 10);

    /*
     * common frame 
     */
    frame = gtk_frame_new (_(" Common "));
    gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, TRUE, 0);

    frame_vbox = gtk_vbox_new (FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (frame_vbox), 10);
    gtk_container_add (GTK_CONTAINER (frame), frame_vbox);

    hbox = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (frame_vbox), hbox, TRUE, TRUE, 0);
    table = gtk_table_new (2, 2, FALSE);
    gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, TRUE, 5);

    /*
     * locale charset 
     */
    hbox = gtk_hbox_new (FALSE, 0);
    gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 0, 1,
		      GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
    label = gtk_label_new (_("Locale character set: "));
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
    gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
    combo = gtk_combo_new ();
    gtk_combo_set_popdown_strings (GTK_COMBO (combo),
				   charset_get_known_list (NULL));
    gtk_table_attach (GTK_TABLE (table), combo, 1, 2, 0, 1,
		      GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
    gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (combo)->entry),
			conf.charset_locale);
    gtk_signal_connect (GTK_OBJECT (GTK_COMBO (combo)->entry), "changed",
			GTK_SIGNAL_FUNC (cb_locale_charset_changed), NULL);

    /*
     * internal charset 
     */
    hbox = gtk_hbox_new (FALSE, 0);
    gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 1, 2,
		      GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
    label = gtk_label_new (_("Internal character set: "));
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
    gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
    combo = gtk_combo_new ();
    gtk_combo_set_popdown_strings (GTK_COMBO (combo),
				   charset_get_known_list (NULL));
    gtk_table_attach (GTK_TABLE (table), combo, 1, 2, 1, 2,
		      GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
    gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (combo)->entry),
			conf.charset_internal);
    gtk_signal_connect (GTK_OBJECT (GTK_COMBO (combo)->entry), "changed",
			GTK_SIGNAL_FUNC (cb_internal_charset_changed), NULL);

    /*
     * Language to detect 
     */
    hbox = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (frame_vbox), hbox, FALSE, TRUE, 0);
    label = gtk_label_new (_("Language for auto detecting"));
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 5);
    option_menu = menu_option_simple (charset_auto_detect_labels,
				      conf.charset_auto_detect_lang,
				      &config_changed->
				      charset_auto_detect_lang);
    gtk_box_pack_start (GTK_BOX (hbox), option_menu, FALSE, TRUE, 5);
    gtk_widget_show_all (frame);

    /*
     * filename frame 
     */
    frame = gtk_frame_new (_(" File name "));
    gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, TRUE, 10);

    frame_vbox = gtk_vbox_new (FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (frame_vbox), 10);
    gtk_container_add (GTK_CONTAINER (frame), frame_vbox);

    /*
     * charset for filename 
     */
    hbox = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (frame_vbox), hbox, FALSE, TRUE, 0);
    label = gtk_label_new (_("Character set of file name"));
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 5);

    /*
     * filename charset 
     */
    combo = gtk_combo_new ();
    gtk_widget_set_usize (combo, 120, -1);
    gtk_combo_set_popdown_strings (GTK_COMBO (combo),
				   charset_get_known_list (NULL));
    gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (combo)->entry),
			conf.charset_filename);
    gtk_signal_connect (GTK_OBJECT (GTK_COMBO (combo)->entry), "changed",
			GTK_SIGNAL_FUNC (cb_filename_charset_changed), NULL);

    option_menu = menu_option (charset_to_internal_items,
			       conf.charset_filename_mode,
			       cb_filename_charset_conv, combo);

    gtk_box_pack_start (GTK_BOX (hbox), option_menu, FALSE, TRUE, 5);
    gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
    gtk_widget_show_all (frame);

    set_sensitive_filename_charset_mode (conf.charset_filename_mode, combo);

    return main_vbox;
}
예제 #21
0
파일: combo-flags.c 프로젝트: GNOME/anjuta
static gboolean
cg_combo_flags_popup_idle (gpointer data)
{
	CgComboFlags *combo;
	CgComboFlagsPrivate *priv;
	GtkTreeSelection* selection;
	GtkWidget *toplevel;
	GtkWidget *scrolled;
	GdkWindow *window;
	GdkDeviceManager* device_manager;
	gint height, width, x, y;

	combo = CG_COMBO_FLAGS (data);
	priv = CG_COMBO_FLAGS_PRIVATE (combo);

	g_assert (priv->window == NULL);
	priv->window = gtk_window_new (GTK_WINDOW_POPUP);

	g_object_ref (G_OBJECT (priv->window));
	gtk_window_set_resizable (GTK_WINDOW (priv->window), FALSE);

	g_signal_connect (G_OBJECT (priv->window), "key_press_event",
	                  G_CALLBACK (cg_combo_flags_window_key_press_cb),
	                  combo);

	g_signal_connect (G_OBJECT (priv->window), "button_press_event",
	                  G_CALLBACK (cg_combo_flags_window_button_press_cb),
	                  combo);

	scrolled = gtk_scrolled_window_new (NULL, NULL);
	gtk_container_add (GTK_CONTAINER (priv->window), scrolled);

	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
									     GTK_SHADOW_ETCHED_IN);

	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
  								    GTK_POLICY_NEVER, GTK_POLICY_NEVER);

	gtk_widget_show (scrolled);

	priv->treeview = gtk_tree_view_new_with_model (priv->model);
	gtk_widget_show (priv->treeview);
	gtk_container_add (GTK_CONTAINER (scrolled), priv->treeview);

	g_signal_connect (G_OBJECT (priv->treeview), "key_press_event",
	                  G_CALLBACK (cg_combo_flags_treeview_key_press_cb),
	                  combo);

	g_signal_connect (G_OBJECT (priv->treeview), "button_press_event",
	                  G_CALLBACK (cg_combo_flags_treeview_button_press_cb),
	                  combo);

	priv->column = gtk_tree_view_column_new ();
	g_object_ref (G_OBJECT (priv->column));
	cg_combo_flags_sync_cells (combo, GTK_CELL_LAYOUT (priv->column));
	gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview), priv->column);

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
	gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);

	gtk_tree_view_set_enable_search (GTK_TREE_VIEW (priv->treeview), FALSE);
	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->treeview), FALSE);
	gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (priv->treeview), TRUE);

	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (combo));
	if (GTK_IS_WINDOW (toplevel))
	{
		gtk_window_group_add_window (gtk_window_get_group (
		                             GTK_WINDOW (toplevel)),
		                             GTK_WINDOW (priv->window));

		gtk_window_set_transient_for (GTK_WINDOW (priv->window),
		                              GTK_WINDOW (toplevel));

	}
	
	gtk_window_set_screen (GTK_WINDOW (priv->window),
                           gtk_widget_get_screen (GTK_WIDGET (combo)));

	cg_combo_flags_get_position (combo, &x, &y, &width, &height);
	gtk_widget_set_size_request (priv->window, width, height);
	gtk_window_move (GTK_WINDOW(priv->window), x, y);
	gtk_widget_show (priv->window);

	gtk_widget_grab_focus (priv->window);
	if (!gtk_widget_has_focus (priv->treeview))
		gtk_widget_grab_focus (priv->treeview);

	window = gtk_widget_get_window (priv->window);

	device_manager = gdk_display_get_device_manager (gdk_window_get_display (window));
	priv->pointer_device = gdk_device_manager_get_client_pointer (device_manager);
	priv->keyboard_device = gdk_device_get_associated_device (priv->pointer_device);

	gtk_grab_add (priv->window);

	gdk_device_grab (priv->pointer_device, window, GDK_OWNERSHIP_NONE, TRUE,
	                 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK,
	                 NULL, GDK_CURRENT_TIME);

	gdk_device_grab (priv->keyboard_device, window, GDK_OWNERSHIP_NONE, TRUE,
	                 GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
	                 NULL, GDK_CURRENT_TIME);
	return FALSE;
}
예제 #22
0
void ACDBuildDialog(GtkWidget *dialog)
{
  GtkWidget *table1 = gtk_table_new(7, 3, FALSE);
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table1, FALSE, FALSE, 0);
  gtk_container_set_border_width(GTK_CONTAINER(table1), 5);
  gtk_table_set_row_spacings(GTK_TABLE(table1), 5);
  gtk_table_set_col_spacings(GTK_TABLE(table1), 5);

  GtkWidget *label1 = gtk_label_new(_("select below"));
  gtk_table_attach(GTK_TABLE(table1), label1, 0, 1, 0, 1,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
  gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);

  GtkWidget *label2 = gtk_label_new(_("description"));
  gtk_table_attach(GTK_TABLE(table1), label2, 2, 3, 0, 1,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
  gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);

  rbtnCW = gtk_radio_button_new_with_mnemonic(NULL, _("copy clockwise"));
  gtk_table_attach(GTK_TABLE(table1), rbtnCW, 0, 1, 2, 3,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
  GSList *rbtn1_group = NULL;
  gtk_radio_button_set_group(GTK_RADIO_BUTTON(rbtnCW), rbtn1_group);
  rbtn1_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(rbtnCW));

  rbtnCCW = gtk_radio_button_new_with_mnemonic(NULL, _("copy counter\nclockwise"));
  gtk_table_attach(GTK_TABLE(table1), rbtnCCW, 0, 1, 4, 5,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
  gtk_radio_button_set_group(GTK_RADIO_BUTTON(rbtnCCW), rbtn1_group);
  rbtn1_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(rbtnCCW));

  rbtnDETAIL = gtk_radio_button_new_with_mnemonic(NULL, _("copy detail"));
  gtk_table_attach(GTK_TABLE(table1), rbtnDETAIL, 0, 1, 6, 7,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
  gtk_radio_button_set_group(GTK_RADIO_BUTTON(rbtnDETAIL), rbtn1_group);
  rbtn1_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(rbtnDETAIL));

  GtkWidget *hbox1 = gtk_hbox_new(FALSE, 5);
  gtk_table_attach(GTK_TABLE(table1), hbox1, 2, 3, 2, 3,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);

  optAC2 = gtk_option_menu_new();
  gtk_box_pack_start(GTK_BOX(hbox1), optAC2, FALSE, FALSE, 0);

  GtkWidget *label3 = gtk_label_new(_("1.from south direction\n  to southwest direction\n2.from west direction\n  to northwest direction\n...\n"));
  gtk_box_pack_start(GTK_BOX(hbox1), label3, FALSE, TRUE, 0);

  GtkWidget *hbox2 = gtk_hbox_new(FALSE, 5);
  gtk_table_attach(GTK_TABLE(table1), hbox2, 2, 3, 4, 5,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);

  optAC3 = gtk_option_menu_new();
  gtk_box_pack_start(GTK_BOX(hbox2), optAC3, FALSE, TRUE, 0);

  GtkWidget *label4 = gtk_label_new(_("1.from southwest direction\n  to south direction\n2.from northwest direction\n  to west direction\n...\n"));
  gtk_box_pack_start(GTK_BOX(hbox2), label4, FALSE, TRUE, 0);

  GtkWidget *hseparator7 = gtk_hseparator_new();
  gtk_table_attach(GTK_TABLE(table1), hseparator7, 2, 3, 3, 4,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);

  GtkWidget *hseparator3 = gtk_hseparator_new();
  gtk_table_attach(GTK_TABLE(table1), hseparator3, 0, 1, 1, 2,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);

  GtkWidget *hseparator4 = gtk_hseparator_new();
  gtk_table_attach(GTK_TABLE(table1), hseparator4, 2, 3, 1, 2,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);

  GtkWidget *hseparator9 = gtk_hseparator_new();
  gtk_table_attach(GTK_TABLE(table1), hseparator9, 0, 1, 3, 4,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);

  GtkWidget *vseparator5 = gtk_vseparator_new();
  gtk_table_attach(GTK_TABLE(table1), vseparator5, 1, 2, 0, 1,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);

  GtkWidget *vseparator2 = gtk_vseparator_new();
  gtk_table_attach(GTK_TABLE(table1), vseparator2, 1, 2, 2, 3,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);

  GtkWidget *vseparator3 = gtk_vseparator_new();
  gtk_table_attach(GTK_TABLE(table1), vseparator3, 1, 2, 4, 5,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);

  GtkWidget *vseparator4 = gtk_vseparator_new();
  gtk_table_attach(GTK_TABLE(table1), vseparator4, 1, 2, 6, 7,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);

  GtkWidget *hseparator11 = gtk_hseparator_new();
  gtk_table_attach(GTK_TABLE(table1), hseparator11, 2, 3, 5, 6,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);

  GtkWidget *hseparator12 = gtk_hseparator_new();
  gtk_table_attach(GTK_TABLE(table1), hseparator12, 0, 1, 5, 6,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);

  GtkWidget *hbox3 = gtk_hbox_new(FALSE, 8);
  gtk_table_attach(GTK_TABLE(table1), hbox3, 2, 3, 6, 7,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);

  GtkWidget *table2 = gtk_table_new(2, 2, FALSE);
  gtk_box_pack_start(GTK_BOX(hbox3), table2, TRUE, TRUE, 0);
  gtk_table_set_row_spacings(GTK_TABLE(table2), 5);
  gtk_table_set_col_spacings(GTK_TABLE(table2), 5);

  GtkWidget *label5 = gtk_label_new(_("From:"));
  gtk_table_attach(GTK_TABLE(table2), label5, 0, 1, 0, 1,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
  gtk_misc_set_alignment(GTK_MISC(label5), 0, 0.5);

  optAC11 = gtk_option_menu_new();
  gtk_table_attach(GTK_TABLE(table2), optAC11, 1, 2, 0, 1,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);

  GtkWidget *table4 = gtk_table_new(3, 3, FALSE);
  gtk_table_attach(GTK_TABLE(table2), table4, 1, 2, 1, 2,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0);

  GSList *rbtn0_group = NULL;
  for (int i=0; i<3; i++) {
    rbtnAC[0][i+3] = gtk_radio_button_new_with_mnemonic(NULL, "");
    gtk_table_attach(GTK_TABLE(table4), rbtnAC[0][i+3], i, i+1, 0, 1,
      (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
    gtk_radio_button_set_group(GTK_RADIO_BUTTON(rbtnAC[0][i+3]), rbtn0_group);
    rbtn0_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(rbtnAC[0][i+3]));
  }
  rbtnAC[0][2] = gtk_radio_button_new_with_mnemonic(NULL, "");
  gtk_table_attach(GTK_TABLE(table4), rbtnAC[0][2], 0, 1, 1, 2,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
  gtk_radio_button_set_group(GTK_RADIO_BUTTON(rbtnAC[0][2]), rbtn0_group);
  rbtn0_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(rbtnAC[0][2]));

  rbtnAC[0][6] = gtk_radio_button_new_with_mnemonic(NULL, "");
  gtk_table_attach(GTK_TABLE(table4), rbtnAC[0][6], 2, 3, 1, 2,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
  gtk_radio_button_set_group(GTK_RADIO_BUTTON(rbtnAC[0][6]), rbtn0_group);
  rbtn0_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(rbtnAC[0][6]));

  rbtnAC[0][1] = gtk_radio_button_new_with_mnemonic(NULL, "");
  gtk_table_attach(GTK_TABLE(table4), rbtnAC[0][1], 0, 1, 2, 3,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
  gtk_radio_button_set_group(GTK_RADIO_BUTTON(rbtnAC[0][1]), rbtn0_group);
  rbtn0_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(rbtnAC[0][1]));

  rbtnAC[0][0] = gtk_radio_button_new_with_mnemonic(NULL, "");
  gtk_table_attach(GTK_TABLE(table4), rbtnAC[0][0], 1, 2, 2, 3,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
  gtk_radio_button_set_group(GTK_RADIO_BUTTON(rbtnAC[0][0]), rbtn0_group);
  rbtn0_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(rbtnAC[0][0]));

  rbtnAC[0][7] = gtk_radio_button_new_with_mnemonic(NULL, "");
  gtk_table_attach(GTK_TABLE(table4), rbtnAC[0][7], 2, 3, 2, 3,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
  gtk_radio_button_set_group(GTK_RADIO_BUTTON(rbtnAC[0][7]), rbtn0_group);
  rbtn0_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(rbtnAC[0][7]));

  GtkWidget *table3 = gtk_table_new(2, 2, FALSE);
  gtk_box_pack_start(GTK_BOX(hbox3), table3, TRUE, TRUE, 0);
  gtk_table_set_row_spacings(GTK_TABLE(table3), 5);
  gtk_table_set_col_spacings(GTK_TABLE(table3), 5);

  GtkWidget *label6 = gtk_label_new(_("To:"));
  gtk_table_attach(GTK_TABLE(table3), label6, 0, 1, 0, 1,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
  gtk_misc_set_alignment(GTK_MISC(label6), 0, 0.5);

  optAC12 = gtk_option_menu_new();
  gtk_table_attach(GTK_TABLE(table3), optAC12, 1, 2, 0, 1,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);

  GtkWidget *table5 = gtk_table_new(3, 3, FALSE);
  gtk_table_attach(GTK_TABLE(table3), table5, 1, 2, 1, 2,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);

  GSList *rbtn10_group = NULL;
  for (int i=0; i<3; i++) {
    rbtnAC[1][i+3] = gtk_radio_button_new_with_mnemonic(NULL, "");
    gtk_table_attach(GTK_TABLE(table5), rbtnAC[1][i+3], i, i+1, 0, 1,
      (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
    gtk_radio_button_set_group(GTK_RADIO_BUTTON(rbtnAC[1][i+3]), rbtn10_group);
    rbtn10_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(rbtnAC[1][i+3]));
  }
  rbtnAC[1][2] = gtk_radio_button_new_with_mnemonic(NULL, "");
  gtk_table_attach(GTK_TABLE(table5), rbtnAC[1][2], 0, 1, 1, 2,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
  gtk_radio_button_set_group(GTK_RADIO_BUTTON(rbtnAC[1][2]), rbtn10_group);
  rbtn10_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(rbtnAC[1][2]));

  rbtnAC[1][6] = gtk_radio_button_new_with_mnemonic(NULL, "");
  gtk_table_attach(GTK_TABLE(table5), rbtnAC[1][6], 2, 3, 1, 2,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
  gtk_radio_button_set_group(GTK_RADIO_BUTTON(rbtnAC[1][6]), rbtn10_group);
  rbtn10_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(rbtnAC[1][6]));

  rbtnAC[1][1] = gtk_radio_button_new_with_mnemonic(NULL, "");
  gtk_table_attach(GTK_TABLE(table5), rbtnAC[1][1], 0, 1, 2, 3,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
  gtk_radio_button_set_group(GTK_RADIO_BUTTON(rbtnAC[1][1]), rbtn10_group);
  rbtn10_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(rbtnAC[1][1]));

  rbtnAC[1][0] = gtk_radio_button_new_with_mnemonic(NULL, "");
  gtk_table_attach(GTK_TABLE(table5), rbtnAC[1][0], 1, 2, 2, 3,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
  gtk_radio_button_set_group(GTK_RADIO_BUTTON(rbtnAC[1][0]), rbtn10_group);
  rbtn10_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(rbtnAC[1][0]));

  rbtnAC[1][7] = gtk_radio_button_new_with_mnemonic(NULL, "");
  gtk_table_attach(GTK_TABLE(table5), rbtnAC[1][7], 2, 3, 2, 3,
    (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
  gtk_radio_button_set_group(GTK_RADIO_BUTTON(rbtnAC[1][7]), rbtn10_group);
  rbtn10_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(rbtnAC[1][7]));
}
예제 #23
0
파일: lib.c 프로젝트: SenorNaddy/darktable
static void edit_preset(const char *name_in, dt_lib_module_info_t *minfo)
{
  gchar *name = NULL;
  if(name_in == NULL)
  {
    name = get_active_preset_name(minfo);
    if(name == NULL) return;
  }
  else
    name = g_strdup(name_in);

  GtkWidget *dialog;
  /* Create the widgets */
  char title[1024];
  GtkWidget *window = dt_ui_main_window(darktable.gui->ui);
  snprintf(title, sizeof(title), _("edit `%s'"), name);
  dialog = gtk_dialog_new_with_buttons(title, GTK_WINDOW(window), GTK_DIALOG_DESTROY_WITH_PARENT, _("_OK"),
                                       GTK_RESPONSE_ACCEPT, _("_Cancel"), GTK_RESPONSE_REJECT, NULL);
  GtkContainer *content_area = GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog)));
  GtkBox *box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 5));
  gtk_widget_set_margin_start(GTK_WIDGET(box), DT_PIXEL_APPLY_DPI(10));
  gtk_widget_set_margin_end(GTK_WIDGET(box), DT_PIXEL_APPLY_DPI(10));
  gtk_widget_set_margin_top(GTK_WIDGET(box), DT_PIXEL_APPLY_DPI(10));
  gtk_widget_set_margin_bottom(GTK_WIDGET(box), DT_PIXEL_APPLY_DPI(10));
  gtk_container_add(content_area, GTK_WIDGET(box));

  dt_lib_presets_edit_dialog_t *g
      = (dt_lib_presets_edit_dialog_t *)g_malloc0(sizeof(dt_lib_presets_edit_dialog_t));
  g->old_id = -1;
  g_strlcpy(g->plugin_name, minfo->plugin_name, sizeof(g->plugin_name));
  g->version = minfo->version;
  g->params_size = minfo->params_size;
  g->params = minfo->params;
  g->name = GTK_ENTRY(gtk_entry_new());
  g->module = minfo->module;
  g->original_name = name;
  gtk_entry_set_text(g->name, name);
  gtk_box_pack_start(box, GTK_WIDGET(g->name), FALSE, FALSE, 0);
  g_object_set(G_OBJECT(g->name), "tooltip-text", _("name of the preset"), (char *)NULL);

  g->description = GTK_ENTRY(gtk_entry_new());
  gtk_box_pack_start(box, GTK_WIDGET(g->description), FALSE, FALSE, 0);
  g_object_set(G_OBJECT(g->description), "tooltip-text", _("description or further information"),
               (char *)NULL);

  sqlite3_stmt *stmt;
  DT_DEBUG_SQLITE3_PREPARE_V2(
      dt_database_get(darktable.db),
      "select rowid, description from presets where name = ?1 and operation = ?2 and op_version = ?3", -1,
      &stmt, NULL);
  DT_DEBUG_SQLITE3_BIND_TEXT(stmt, 1, name, -1, SQLITE_TRANSIENT);
  DT_DEBUG_SQLITE3_BIND_TEXT(stmt, 2, minfo->plugin_name, -1, SQLITE_TRANSIENT);
  DT_DEBUG_SQLITE3_BIND_INT(stmt, 3, minfo->version);
  if(sqlite3_step(stmt) == SQLITE_ROW)
  {
    g->old_id = sqlite3_column_int(stmt, 0);
    gtk_entry_set_text(g->description, (const char *)sqlite3_column_text(stmt, 1));
  }
  sqlite3_finalize(stmt);

  g_signal_connect(dialog, "response", G_CALLBACK(edit_preset_response), g);
  gtk_widget_show_all(dialog);
}
예제 #24
0
bool wxListBox::Create( wxWindow *parent, wxWindowID id,
                        const wxPoint &pos, const wxSize &size,
                        int n, const wxString choices[],
                        long style, const wxValidator& validator,
                        const wxString &name )
{
    if (!PreCreation( parent, pos, size ) ||
        !CreateBase( parent, id, pos, size, style, validator, name ))
    {
        wxFAIL_MSG( wxT("wxListBox creation failed") );
        return false;
    }

    m_widget = gtk_scrolled_window_new( NULL, NULL );
    g_object_ref(m_widget);
    if (style & wxLB_ALWAYS_SB)
    {
      gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget),
        GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS );
    }
    else
    {
      gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget),
        GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
    }


    GTKScrolledWindowSetBorder(m_widget, style);

    m_treeview = GTK_TREE_VIEW( gtk_tree_view_new( ) );

    //wxListBox doesn't have a header :)
    //NB: If enabled SetFirstItem doesn't work correctly
    gtk_tree_view_set_headers_visible(m_treeview, FALSE);

#if wxUSE_CHECKLISTBOX
    if(m_hasCheckBoxes)
        ((wxCheckListBox*)this)->DoCreateCheckList();
#endif // wxUSE_CHECKLISTBOX

    // Create the data column
    gtk_tree_view_insert_column_with_attributes(m_treeview, -1, "",
                                                gtk_cell_renderer_text_new(),
                                                "text",
                                                WXLISTBOX_DATACOLUMN, NULL);

    // Now create+set the model (GtkListStore) - first argument # of columns
#if wxUSE_CHECKLISTBOX
    if(m_hasCheckBoxes)
        m_liststore = gtk_list_store_new(2, G_TYPE_BOOLEAN,
                                            WX_TYPE_TREE_ENTRY);
    else
#endif
        m_liststore = gtk_list_store_new(1, WX_TYPE_TREE_ENTRY);

    gtk_tree_view_set_model(m_treeview, GTK_TREE_MODEL(m_liststore));

    g_object_unref (m_liststore); //free on treeview destruction

    // Disable the pop-up textctrl that enables searching - note that
    // the docs specify that even if this disabled (which we are doing)
    // the user can still have it through the start-interactive-search
    // key binding...either way we want to provide a searchequal callback
    // NB: If this is enabled a doubleclick event (activate) gets sent
    //     on a successful search
    gtk_tree_view_set_search_column(m_treeview, WXLISTBOX_DATACOLUMN);
    gtk_tree_view_set_search_equal_func(m_treeview,
       (GtkTreeViewSearchEqualFunc) gtk_listbox_searchequal_callback,
                                        this,
                                        NULL);

    gtk_tree_view_set_enable_search(m_treeview, FALSE);

    GtkSelectionMode mode;
    // GTK_SELECTION_EXTENDED is a deprecated synonym for GTK_SELECTION_MULTIPLE
    if ( style & (wxLB_MULTIPLE | wxLB_EXTENDED) )
    {
        mode = GTK_SELECTION_MULTIPLE;
    }
    else // no multi-selection flags specified
    {
        m_windowStyle |= wxLB_SINGLE;

        // Notice that we must use BROWSE and not GTK_SELECTION_SINGLE because
        // the latter allows to not select any items at all while a single
        // selection listbox is supposed to always have a selection (at least
        // once the user selected something, it might not have any initially).
        mode = GTK_SELECTION_BROWSE;
    }

    GtkTreeSelection* selection = gtk_tree_view_get_selection( m_treeview );
    gtk_tree_selection_set_mode( selection, mode );

    // Handle sortable stuff
    if(HasFlag(wxLB_SORT))
    {
        // Setup sorting in ascending (wx) order
        gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(m_liststore),
                                             WXLISTBOX_DATACOLUMN,
                                             GTK_SORT_ASCENDING);

        // Set the sort callback
        gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(m_liststore),
                                        WXLISTBOX_DATACOLUMN,
                   (GtkTreeIterCompareFunc) gtk_listbox_sort_callback,
                                        this, //userdata
                                        NULL //"destroy notifier"
                                       );
    }


    gtk_container_add (GTK_CONTAINER (m_widget), GTK_WIDGET(m_treeview) );

    gtk_widget_show( GTK_WIDGET(m_treeview) );
    m_focusWidget = GTK_WIDGET(m_treeview);

    Append(n, choices); // insert initial items

    // generate dclick events
    g_signal_connect_after(m_treeview, "row-activated",
                     G_CALLBACK(gtk_listbox_row_activated_callback), this);

    // for intercepting dclick generation by <ENTER>
    g_signal_connect (m_treeview, "key_press_event",
                      G_CALLBACK (gtk_listbox_key_press_callback),
                           this);
    m_parent->DoAddChild( this );

    PostCreation(size);
    SetInitialSize(size); // need this too because this is a wxControlWithItems

    g_signal_connect_after (selection, "changed",
                            G_CALLBACK (gtk_listitem_changed_callback), this);

    return true;
}
예제 #25
0
void
gnibbles_preferences_cb (GtkWidget * widget, gpointer data)
{
  GtkWidget *notebook;
  GtkWidget *label;
  GtkWidget *frame;
  GtkWidget *button;
  GtkWidget *levelspinner;
  GtkWidget *vbox, *vbox2;
  GtkObject *adjustment;
  GtkWidget *label2;
  GtkWidget *table, *table2;
  GtkWidget *omenu;
  GtkWidget *controls;
  gchar *buffer;
  gint i;
  gint running = 0;

  if (pref_dialog) {
    gtk_window_present (GTK_WINDOW (pref_dialog));
    return;
  }

  if (!paused) {
    unpause = 1;
    pause_game_cb (NULL, 0);
  }

  if (game_running ())
    running = 1;

  pref_dialog = gtk_dialog_new_with_buttons (_("Nibbles Preferences"),
					     GTK_WINDOW (window), 0,
					     GTK_STOCK_CLOSE,
					     GTK_RESPONSE_CLOSE, NULL);
  gtk_dialog_set_has_separator (GTK_DIALOG (pref_dialog), FALSE);
  gtk_container_set_border_width (GTK_CONTAINER (pref_dialog), 5);
  gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (pref_dialog)->vbox), 2);

  notebook = gtk_notebook_new ();
  gtk_container_set_border_width (GTK_CONTAINER (notebook), 5);
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (pref_dialog)->vbox),
		     notebook);

  label = gtk_label_new (_("Game"));
  table = gtk_table_new (1, 2, FALSE);
  gtk_table_set_col_spacings (GTK_TABLE (table), 18);
  gtk_container_set_border_width (GTK_CONTAINER (table), 12);

  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), table, label);

  frame = games_frame_new (_("Speed"));
  if (running)
    gtk_widget_set_sensitive (frame, FALSE);

  gtk_table_attach (GTK_TABLE (table), frame, 0, 1, 0, 1, 0,
		    GTK_FILL | GTK_EXPAND, 0, 0);

  vbox = gtk_vbox_new (FALSE, 6);
  gtk_container_add (GTK_CONTAINER (frame), vbox);

  button = gtk_radio_button_new_with_label (NULL, _("Nibbles newbie"));

  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
  if (properties->gamespeed == 4)
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
  g_signal_connect (GTK_OBJECT (button), "toggled", G_CALLBACK
		    (game_speed_cb), (gpointer) 4);

  button = gtk_radio_button_new_with_label (gtk_radio_button_get_group
					    (GTK_RADIO_BUTTON (button)),
					    _("My second day"));

  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
  if (properties->gamespeed == 3)
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
  g_signal_connect (GTK_OBJECT (button), "toggled", G_CALLBACK
		    (game_speed_cb), (gpointer) 3);

  button = gtk_radio_button_new_with_label (gtk_radio_button_get_group
					    (GTK_RADIO_BUTTON (button)),
					    _("Not too shabby"));

  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
  if (properties->gamespeed == 2)
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
  g_signal_connect (GTK_OBJECT (button), "toggled", G_CALLBACK
		    (game_speed_cb), (gpointer) 2);

  button = gtk_radio_button_new_with_label (gtk_radio_button_get_group
					    (GTK_RADIO_BUTTON (button)),
					    _("Finger-twitching good"));

  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
  if (properties->gamespeed == 1)
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
  g_signal_connect (GTK_OBJECT (button), "toggled", G_CALLBACK
		    (game_speed_cb), (gpointer) 1);


  /* Options */
  frame = games_frame_new (_("Options"));
  gtk_table_attach_defaults (GTK_TABLE (table), frame, 1, 2, 0, 1);

  vbox = gtk_vbox_new (FALSE, 6);
  gtk_container_add (GTK_CONTAINER (frame), vbox);

  button =
    gtk_check_button_new_with_mnemonic (_("_Play levels in random order"));
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

  if (running || ggz_network_mode)
    gtk_widget_set_sensitive (button, FALSE);
  if (properties->random)
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
  g_signal_connect (GTK_OBJECT (button), "toggled", G_CALLBACK
		    (random_order_cb), NULL);

  button = gtk_check_button_new_with_mnemonic (_("_Enable fake bonuses"));
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

  if (running)
    gtk_widget_set_sensitive (button, FALSE);
  if (properties->fakes)
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
  g_signal_connect (GTK_OBJECT (button), "toggled", G_CALLBACK
		    (fake_bonus_cb), NULL);

  button = gtk_check_button_new_with_mnemonic (_("E_nable sounds"));
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
  if (properties->sound)
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
  g_signal_connect (GTK_OBJECT (button), "toggled", G_CALLBACK
		    (sound_cb), NULL);

  table2 = gtk_table_new (3, 2, FALSE);
  gtk_box_pack_start (GTK_BOX (vbox), table2, FALSE, FALSE, 0);
  gtk_table_set_row_spacings (GTK_TABLE (table2), 6);
  gtk_table_set_col_spacings (GTK_TABLE (table2), 12);
  gtk_container_set_border_width (GTK_CONTAINER (table2), 0);

  label2 = gtk_label_new_with_mnemonic (_("_Starting level:"));
  start_level_label = label2;
  gtk_widget_set_name (label2, "StartLevelLabel");
  gtk_misc_set_alignment (GTK_MISC (label2), 0, 0.5);

  if (properties->random)
    gtk_widget_set_sensitive (GTK_WIDGET (label2), FALSE);
  if (running)
    gtk_widget_set_sensitive (GTK_WIDGET (label2), FALSE);
  gtk_table_attach (GTK_TABLE (table2), label2, 0, 1, 0, 1, GTK_FILL, 0, 0,
		    0);

  adjustment = gtk_adjustment_new ((gfloat) properties->startlevel, 1.0,
				   MAXLEVEL, 1.0, 5.0, 0.0);

  levelspinner = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 0, 0);
  start_level_spin_button = levelspinner;
  gtk_widget_set_name (levelspinner, "StartLevelSpinButton");
  gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (levelspinner), FALSE);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label2), levelspinner);

  if (properties->random)
    gtk_widget_set_sensitive (GTK_WIDGET (levelspinner), FALSE);
  if (running)
    gtk_widget_set_sensitive (GTK_WIDGET (levelspinner), FALSE);
  gtk_table_attach_defaults (GTK_TABLE (table2), levelspinner, 1, 2, 0, 1);
  g_signal_connect (GTK_OBJECT (adjustment), "value_changed",
		    G_CALLBACK (start_level_cb), levelspinner);

  label2 = gtk_label_new_with_mnemonic (_("Number of _human players:"));
  gtk_misc_set_alignment (GTK_MISC (label2), 0, 0.5);

  gtk_table_attach (GTK_TABLE (table2), label2, 0, 1, 1, 2, GTK_FILL, 0, 0,
		    0);
  if (running || ggz_network_mode)
    gtk_widget_set_sensitive (label2, FALSE);

  adjustment = gtk_adjustment_new ((gfloat) properties->human, 0.0,
				   NUMWORMS, 1.0, 1.0, 0.0);

  num_human = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 0, 0);
  gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (num_human), FALSE);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label2), num_human);

  gtk_table_attach_defaults (GTK_TABLE (table2), num_human, 1, 2, 1, 2);
  if (running || ggz_network_mode)
    gtk_widget_set_sensitive (num_human, FALSE);
  g_signal_connect (GTK_OBJECT (adjustment), "value_changed",
		    G_CALLBACK (num_worms_cb), num_human);

  label2 = gtk_label_new_with_mnemonic (_("Number of _AI players:"));
  gtk_misc_set_alignment (GTK_MISC (label2), 0, 0.5);

  gtk_table_attach (GTK_TABLE (table2), label2, 0, 1, 2, 3, GTK_FILL, 0, 0,
		    0);
  if (running || ggz_network_mode)
    gtk_widget_set_sensitive (label2, FALSE);

  adjustment = gtk_adjustment_new ((gfloat) properties->ai, 0.0,
				   NUMWORMS, 1.0, 1.0, 0.0);

  num_ai = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 0, 0);
  gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (num_ai), FALSE);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label2), num_ai);

  gtk_table_attach_defaults (GTK_TABLE (table2), num_ai, 1, 2, 2, 3);
  if (running || ggz_network_mode)
    gtk_widget_set_sensitive (num_ai, FALSE);
  g_signal_connect (GTK_OBJECT (adjustment), "value_changed",
		    G_CALLBACK (num_worms_cb), num_ai);

  for (i = 0; i < NUMWORMS; i++) {
    char up_key[64];
    char down_key[64];
    char left_key[64];
    char right_key[64];

    buffer = g_strdup_printf ("%s %d", _("Worm"), i + 1);
    label = gtk_label_new (buffer);
    g_free (buffer);

    vbox = gtk_vbox_new (FALSE, 18);
    gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);

    gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, label);

    frame = games_frame_new (_("Keyboard Controls"));

    controls = games_controls_list_new (KEY_PREFERENCES_GROUP);

    g_snprintf (left_key, sizeof (left_key), KEY_WORM_LEFT, i);
    g_snprintf (right_key, sizeof (right_key), KEY_WORM_RIGHT, i);
    g_snprintf (up_key, sizeof (up_key), KEY_WORM_UP, i);
    g_snprintf (down_key, sizeof (down_key), KEY_WORM_DOWN, i);

    games_controls_list_add_controls (GAMES_CONTROLS_LIST (controls),
				      left_key, _("Move left"), GDK_Left,
                                      right_key, _("Move right"), GDK_Right,
                                      up_key, _("Move up"), GDK_Up,
                                      down_key, _("Move down"), GDK_Down,
				      NULL);
    gtk_container_add (GTK_CONTAINER (frame), controls);

    gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);

    frame = games_frame_new (_("Options"));
    gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);

    vbox2 = gtk_vbox_new (FALSE, 6);
    gtk_container_add (GTK_CONTAINER (frame), vbox2);

    button = gtk_check_button_new_with_mnemonic (_("_Use relative movement"));
    gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);

    table2 = gtk_table_new (1, 2, FALSE);
    gtk_table_set_col_spacings (GTK_TABLE (table2), 12);
    gtk_box_pack_start (GTK_BOX (vbox2), table2, FALSE, FALSE, 0);

    label2 = gtk_label_new_with_mnemonic (_("_Worm color:"));
    gtk_misc_set_alignment (GTK_MISC (label2), 0, 0.5);
    gtk_table_attach (GTK_TABLE (table2), label2, 0, 1, 0, 1, 0, 0, 0, 0);

    omenu = gtk_combo_box_new_text ();
    gtk_label_set_mnemonic_widget (GTK_LABEL (label2), omenu);
    gtk_combo_box_append_text (GTK_COMBO_BOX (omenu), _("Red"));
    gtk_combo_box_append_text (GTK_COMBO_BOX (omenu), _("Green"));
    gtk_combo_box_append_text (GTK_COMBO_BOX (omenu), _("Blue"));
    gtk_combo_box_append_text (GTK_COMBO_BOX (omenu), _("Yellow"));
    gtk_combo_box_append_text (GTK_COMBO_BOX (omenu), _("Cyan"));
    gtk_combo_box_append_text (GTK_COMBO_BOX (omenu), _("Purple"));
    gtk_combo_box_append_text (GTK_COMBO_BOX (omenu), _("Gray"));
    g_signal_connect (GTK_OBJECT (omenu), "changed",
		      G_CALLBACK (set_worm_color_cb),
		      GINT_TO_POINTER (i));
    gtk_combo_box_set_active (GTK_COMBO_BOX (omenu),
			      properties->wormprops[i]->color - WORMRED);
    gtk_table_attach_defaults (GTK_TABLE (table2), omenu, 1, 2, 0, 1);

    set_worm_controls_sensitivity (i, properties->wormprops[i]->relmove);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
				  properties->wormprops[i]->relmove);
    g_signal_connect (G_OBJECT (button), "toggled",
		      G_CALLBACK (worm_relative_movement_cb),
		      GINT_TO_POINTER (i));
  }

  g_signal_connect (G_OBJECT (pref_dialog), "response",
		    G_CALLBACK (apply_cb), NULL);
  g_signal_connect (G_OBJECT (pref_dialog), "destroy",
		    G_CALLBACK (destroy_cb), NULL);
  g_signal_connect (G_OBJECT (pref_dialog), "close",
		    G_CALLBACK (destroy_cb), NULL);

  gtk_widget_show_all (pref_dialog);

}
예제 #26
0
/*!
 * \brief GUI thread only create a plot surface and periodically call a
 * gui_handler that redraws the plot after a short timeout
 */
static gpointer
gui_thread (gpointer data)
{
  GtkWidget *window;
  GtkWidget *drawing_area;
    /* Create the Widgets */
  GtkWidget *vbox, *menubar, *filemenu,*editmenu,*viewmenu,*helpmenu,
  *file, *edit, *view, *help,*pref_1,*toolbar,*help_Dialog,*about_Dialog,
  *new,*sep1,*sep2, *open,*save,*dialog, *save_as,*export,*export_diag, *quit, *sep, *tog_stat,*statusbar, *tog_tool;
  gdk_threads_enter();
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   /* Some nesseary inits */
  GtkAccelGroup *accel_group = NULL;
  GtkToolItem *test_item;
  GtkToolItem *item_1;
  GtkToolItem *item_2;
  GtkToolItem *item_3;
  GtkToolItem *item_4; 
  /* Set the window title */
  gtk_window_set_title(GTK_WINDOW(window), "eStick Control Center V0.0-ecc");
  /* Add Window Icon max size 128x128 Pixel current 64x64 used */
  gtk_window_set_icon(GTK_WINDOW(window), create_pixbuf("window_symbol.png"));
  /* Default Window size at startup */
  gtk_window_set_default_size (GTK_WINDOW(window), xsize+xoff, ysize+yoff);
  /* Set Border With of the window in Pixels */
  gtk_container_set_border_width(GTK_CONTAINER(window), 0);
    /* Create a new Vertical Box, FALSE= WIdgets have not equal space, 0 pixels between widgets */
  vbox = gtk_vbox_new(FALSE, 0);
  /* Add the Vertical Box to the main window */
  gtk_container_add(GTK_CONTAINER(window), vbox);
  drawing_area = gtk_drawing_area_new ();
  gtk_widget_set_size_request (drawing_area, xsize, ysize);
  
   /* Create the Menu Bar */
  menubar = gtk_menu_bar_new();
  /* Create the Toolbar Bar */
  toolbar = gtk_toolbar_new();
  gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
  gtk_container_set_border_width(GTK_CONTAINER(toolbar), 0);
  /* Create a new Statusbar*/
  statusbar = gtk_statusbar_new();
  /* Create the Handlers for the submenus*/
  filemenu = gtk_menu_new();
  editmenu = gtk_menu_new();
  viewmenu = gtk_menu_new();
  helpmenu = gtk_menu_new();
  /* Create new accelerator Group */
  accel_group = gtk_accel_group_new();
  gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
  /* Create the File Drop Down Point in the menu bar with mnemonic character */
  file = gtk_menu_item_new_with_mnemonic("_File");
  /* Create the Edit Drop Down Point in the menu bar with mnemonic character */
  edit = gtk_menu_item_new_with_mnemonic("_Edit");
  /* Create the View Drop Down Point in the menu bar with mnemonic character */
  view = gtk_menu_item_new_with_mnemonic("_View");
  /* Create the Help Drop Down Point in the menu bar with mnemonic character */
  help = gtk_menu_item_new_with_mnemonic("_Help");
    /* ############################# Items for the Menu Bar################## */
  /* Use the open point from the libary and the stock symbol */
  open = gtk_image_menu_item_new_from_stock(GTK_STOCK_OPEN, NULL);
  g_signal_connect(G_OBJECT(open), "activate",G_CALLBACK(file_open),file_open);
  /*Connect signal to display the Message for the Save Menu Item in the statusbar, when the mouse cursors hovers over*/
  g_signal_connect (G_OBJECT (open), "enter-notify-event",G_CALLBACK (statusbar_hint), statusbar);
  /*Remove Message from the statusbar when the mouse cursors leaves this menu point*/ 
  g_signal_connect (G_OBJECT (open), "leave-notify-event",G_CALLBACK (statusbar_hint), statusbar); 
  /*Attach the text for the statusbar to the Menu Item*/
  g_object_set_data (G_OBJECT (open), "menuhint",(gpointer) "Open a recorded File");
  /* Create vertical seperator line in the file menu */
  sep1 = gtk_separator_menu_item_new();
  /* Use the save point from the libary and the stock symbol */
  save = gtk_image_menu_item_new_from_stock(GTK_STOCK_SAVE, NULL);
  g_signal_connect(G_OBJECT(save), "activate",G_CALLBACK(file_save),(gpointer) window);
  /*Connect signal to display the Message for the Save Menu Item in the statusbar, when the mouse cursors hovers over*/
  g_signal_connect (G_OBJECT (save), "enter-notify-event",G_CALLBACK (statusbar_hint), statusbar);
  /*Remove Message from the statusbar when the mouse cursors leaves this menu point*/ 
  g_signal_connect (G_OBJECT (save), "leave-notify-event",G_CALLBACK (statusbar_hint), statusbar); 
  /*Attach the text for the statusbar to the Menu Item*/
  g_object_set_data (G_OBJECT (save), "menuhint",(gpointer) "Save to specified File");
  /* Use the save_as point from the libary and the stock symbol */
  save_as = gtk_image_menu_item_new_from_stock(GTK_STOCK_SAVE_AS, NULL);
  g_signal_connect(G_OBJECT(save_as), "activate",G_CALLBACK(file_save_as),(gpointer) window);
  /*Connect signal to display the Message for the Save_as Menu Item in the statusbar, when the mouse cursors hovers over*/
  g_signal_connect (G_OBJECT (save_as), "enter-notify-event",G_CALLBACK (statusbar_hint), statusbar);
  /*Remove Message from the statusbar when the mouse cursors leaves this menu point*/ 
  g_signal_connect (G_OBJECT (save_as), "leave-notify-event",G_CALLBACK (statusbar_hint), statusbar); 
  /*Attach the text for the statusbar to the Menu Item*/
  g_object_set_data (G_OBJECT (save_as), "menuhint",(gpointer) "Save to a new File");
  /* Create vertical seperator line in the file menu */
  sep2 = gtk_separator_menu_item_new();
  /* For the export function, no stock symbol exists, used instead a point with only a label*/
  export = gtk_menu_item_new_with_label("Export");
static GtkCellEditable *
egg_cell_renderer_keys_start_editing (GtkCellRenderer      *cell,
				      GdkEvent             *event,
				      GtkWidget            *widget,
				      const gchar          *path,
				      const GdkRectangle   *background_area,
				      const GdkRectangle   *cell_area,
				      GtkCellRendererState  flags)
{
  GtkCellRendererText *celltext;
  EggCellRendererKeys *keys;
  GdkDisplay *display;
  GdkSeat *seat;
  GtkWidget *label;
  GtkWidget *eventbox;
  GValue celltext_editable = {0};

  celltext = GTK_CELL_RENDERER_TEXT (cell);
  keys = EGG_CELL_RENDERER_KEYS (cell);

  /* If the cell isn't editable we return NULL. */
  g_value_init (&celltext_editable, G_TYPE_BOOLEAN);
  g_object_get_property (G_OBJECT (celltext), "editable", &celltext_editable);
  if (g_value_get_boolean (&celltext_editable) == FALSE)
    return NULL;
  g_return_val_if_fail (gtk_widget_get_window (widget) != NULL, NULL);

  display = gtk_widget_get_display (widget);
  seat = gdk_display_get_default_seat (display);

  if (gdk_seat_grab (seat,
                     gtk_widget_get_window (widget),
                     GDK_SEAT_CAPABILITY_ALL,
                     FALSE,
                     NULL,
                     event,
                     NULL,
                     NULL) != GDK_GRAB_SUCCESS)
    return NULL;

  keys->grab_widget = widget;

  g_signal_connect (G_OBJECT (widget), "key_press_event",
                    G_CALLBACK (grab_key_callback),
                    keys);

  eventbox = g_object_new (pointless_eventbox_subclass_get_type (),
                           NULL);
  keys->edit_widget = eventbox;
  g_object_add_weak_pointer (G_OBJECT (keys->edit_widget),
                             (void**) &keys->edit_widget);

  label = gtk_label_new (NULL);
  gtk_label_set_xalign (GTK_LABEL (label), 0.0);

  gtk_widget_modify_bg (eventbox, GTK_STATE_NORMAL,
                        &gtk_widget_get_style (widget)->bg[GTK_STATE_SELECTED]);

  gtk_widget_modify_fg (label, GTK_STATE_NORMAL,
                        &gtk_widget_get_style (widget)->fg[GTK_STATE_SELECTED]);

  gtk_label_set_text (GTK_LABEL (label),
		  TOOLTIP_TEXT);

  gtk_container_add (GTK_CONTAINER (eventbox), label);

  g_object_set_data_full (G_OBJECT (keys->edit_widget), EGG_CELL_RENDERER_TEXT_PATH,
                          g_strdup (path), g_free);

  gtk_widget_show_all (keys->edit_widget);

  g_signal_connect (G_OBJECT (keys->edit_widget), "unrealize",
                    G_CALLBACK (ungrab_stuff), keys);

  keys->edit_key = keys->accel_key;

  return GTK_CELL_EDITABLE (keys->edit_widget);
}
예제 #28
0
static void show_auth_dialog(WebKitAuthData* authData, const char* login, const char* password)
{
    GtkWidget* toplevel;
    GtkWidget* widget;
    GtkDialog* dialog;
    GtkWindow* window;
    GtkWidget* entryContainer;
    GtkWidget* hbox;
    GtkWidget* mainVBox;
    GtkWidget* vbox;
    GtkWidget* icon;
    GtkWidget* table;
    GtkWidget* messageLabel;
    char* message;
    SoupURI* uri;
    GtkWidget* rememberBox;
    GtkWidget* checkButton;

    /* From GTK+ gtkmountoperation.c, modified and simplified. LGPL 2 license */

    widget = gtk_dialog_new();
    window = GTK_WINDOW(widget);
    dialog = GTK_DIALOG(widget);

    gtk_dialog_add_buttons(dialog,
                           GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                           GTK_STOCK_OK, GTK_RESPONSE_OK,
                           NULL);

    /* Set the dialog up with HIG properties */
    gtk_dialog_set_has_separator(dialog, FALSE);
    gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
    gtk_box_set_spacing(GTK_BOX(dialog->vbox), 2); /* 2 * 5 + 2 = 12 */
    gtk_container_set_border_width(GTK_CONTAINER(dialog->action_area), 5);
    gtk_box_set_spacing(GTK_BOX(dialog->action_area), 6);

    gtk_window_set_resizable(window, FALSE);
    gtk_window_set_title(window, "");
    gtk_window_set_icon_name(window, GTK_STOCK_DIALOG_AUTHENTICATION);

    gtk_dialog_set_default_response(dialog, GTK_RESPONSE_OK);

    /* Get the current toplevel */
    g_signal_emit(authData->manager, signals[CURRENT_TOPLEVEL], 0, authData->msg, &toplevel);

    if (toplevel)
        gtk_window_set_transient_for(window, GTK_WINDOW(toplevel));

    /* Build contents */
    hbox = gtk_hbox_new(FALSE, 12);
    gtk_container_set_border_width(GTK_CONTAINER(hbox), 5);
    gtk_box_pack_start(GTK_BOX(dialog->vbox), hbox, TRUE, TRUE, 0);

    icon = gtk_image_new_from_stock(GTK_STOCK_DIALOG_AUTHENTICATION,
                                    GTK_ICON_SIZE_DIALOG);

    gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0);
    gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, 0);

    mainVBox = gtk_vbox_new(FALSE, 18);
    gtk_box_pack_start(GTK_BOX(hbox), mainVBox, TRUE, TRUE, 0);

    uri = soup_message_get_uri(authData->msg);
    message = g_strdup_printf(_("A username and password are being requested by the site %s"), uri->host);
    messageLabel = gtk_label_new(message);
    g_free(message);
    gtk_misc_set_alignment(GTK_MISC(messageLabel), 0.0, 0.5);
    gtk_label_set_line_wrap(GTK_LABEL(messageLabel), TRUE);
    gtk_box_pack_start(GTK_BOX(mainVBox), GTK_WIDGET(messageLabel),
                       FALSE, FALSE, 0);

    vbox = gtk_vbox_new(FALSE, 6);
    gtk_box_pack_start(GTK_BOX(mainVBox), vbox, FALSE, FALSE, 0);

    /* The table that holds the entries */
    entryContainer = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);

    gtk_alignment_set_padding(GTK_ALIGNMENT(entryContainer),
                              0, 0, 0, 0);

    gtk_box_pack_start(GTK_BOX(vbox), entryContainer,
                       FALSE, FALSE, 0);

    table = gtk_table_new(2, 2, FALSE);
    gtk_table_set_col_spacings(GTK_TABLE(table), 12);
    gtk_table_set_row_spacings(GTK_TABLE(table), 6);
    gtk_container_add(GTK_CONTAINER(entryContainer), table);

    authData->loginEntry = table_add_entry(table, 0, _("Username:"******"Password:"******"_Remember password"));
        if (login && password)
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkButton), TRUE);
        gtk_label_set_line_wrap(GTK_LABEL(gtk_bin_get_child(GTK_BIN(checkButton))), TRUE);
        gtk_box_pack_start(GTK_BOX(rememberBox), checkButton, FALSE, FALSE, 0);
        authData->checkButton = checkButton;
    }

    g_signal_connect(dialog, "response", G_CALLBACK(response_callback), authData);
    gtk_widget_show_all(widget);
}
예제 #29
0
static void
wrap_table_layout (EelWrapTable *wrap_table)
{
    GList *iterator;
    EelIPoint pos;
    EelDimensions max_child_dimensions;
    EelIRect content_bounds;
    guint num_cols;
    GtkAllocation allocation;

    g_assert (EEL_IS_WRAP_TABLE (wrap_table));

    max_child_dimensions = wrap_table_get_max_child_dimensions (wrap_table);
    max_child_dimensions.width = MAX (max_child_dimensions.width, 1);
    max_child_dimensions.height = MAX (max_child_dimensions.height, 1);

    content_bounds = wrap_table_get_content_bounds (wrap_table);
    pos.x = content_bounds.x0;
    pos.y = content_bounds.y0;

    gtk_widget_get_allocation (GTK_WIDGET (wrap_table), &allocation);
    num_cols = wrap_table_get_num_fitting (allocation.width -
                                           gtk_container_get_border_width (GTK_CONTAINER (wrap_table)) * 2,
                                           wrap_table->details->x_spacing,
                                           max_child_dimensions.width);
    if (num_cols != wrap_table->details->cols)
    {
        wrap_table->details->cols = num_cols;
        gtk_widget_queue_resize (GTK_WIDGET (wrap_table));
        return;
    }

    for (iterator = wrap_table->details->children; iterator; iterator = iterator->next)
    {
        GtkWidget *item;

        item = iterator->data;

        if (gtk_widget_get_visible (item))
        {
            GtkAllocation item_allocation;

            if (wrap_table->details->homogeneous)
            {
                item_allocation.x = pos.x;
                item_allocation.y = pos.y;
                item_allocation.width = max_child_dimensions.width;
                item_allocation.height = max_child_dimensions.height;

                if ((pos.x + max_child_dimensions.width) > content_bounds.x1)
                {
                    pos.x = content_bounds.x0 + wrap_table->details->x_spacing + max_child_dimensions.width;
                    pos.y += (max_child_dimensions.height + wrap_table->details->y_spacing);
                    item_allocation.x = content_bounds.x0;
                    item_allocation.y = pos.y;
                }
                else
                {
                    pos.x += (wrap_table->details->x_spacing + max_child_dimensions.width);
                }
            }
            else
            {
                GtkRequisition item_requisition;

                gtk_widget_size_request (item, &item_requisition);

                item_allocation.x = pos.x;
                item_allocation.y = pos.y;
                item_allocation.width = item_requisition.width;
                item_allocation.height = item_requisition.height;

                g_assert (item_allocation.width <= max_child_dimensions.width);
                g_assert (item_allocation.height <= max_child_dimensions.height);

                if ((pos.x + max_child_dimensions.width) > content_bounds.x1)
                {
                    pos.x = content_bounds.x0 + wrap_table->details->x_spacing + max_child_dimensions.width;
                    pos.y += (max_child_dimensions.height + wrap_table->details->y_spacing);
                    item_allocation.x = content_bounds.x0;
                    item_allocation.y = pos.y;
                }
                else
                {
                    pos.x += (wrap_table->details->x_spacing + max_child_dimensions.width);
                }

                switch (wrap_table->details->x_justification)
                {
                case EEL_JUSTIFICATION_MIDDLE:
                    item_allocation.x += (max_child_dimensions.width - (int) item_allocation.width) / 2;
                    break;
                case EEL_JUSTIFICATION_END:
                    item_allocation.x += (max_child_dimensions.width - (int) item_allocation.width);
                    break;
                default:
                    break;
                }

                switch (wrap_table->details->y_justification)
                {
                case EEL_JUSTIFICATION_MIDDLE:
                    item_allocation.y += (max_child_dimensions.height - (int) item_allocation.height) / 2;
                    break;
                case EEL_JUSTIFICATION_END:
                    item_allocation.y += (max_child_dimensions.height - (int) item_allocation.height);
                    break;
                default:
                    break;
                }
            }

            gtk_widget_size_allocate (item, &item_allocation);
        }
    }
}
예제 #30
0
int I_PickIWad_Gtk (WadStuff *wads, int numwads, bool showwin, int defaultiwad)
{
	GtkWidget *window;
	GtkWidget *vbox;
	GtkWidget *hbox;
	GtkWidget *bbox;
	GtkWidget *widget;
	GtkWidget *tree;
	GtkWidget *check;
	GtkListStore *store;
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;
	GtkTreeSelection *selection;
	GtkTreeIter iter, defiter;
	int close_style = 0;
	int i;
	char caption[100];

	// Create the dialog window.
	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	mysnprintf(caption, countof(caption), GAMESIG " %s: Select an IWAD to use", GetVersionString());
	gtk_window_set_title (GTK_WINDOW(window), caption);
	gtk_window_set_position (GTK_WINDOW(window), GTK_WIN_POS_CENTER);
	gtk_container_set_border_width (GTK_CONTAINER(window), 10);
	g_signal_connect (window, "delete_event", G_CALLBACK(gtk_main_quit), NULL);
	g_signal_connect (window, "key_press_event", G_CALLBACK(CheckEscape), NULL);

	// Create the vbox container.
	vbox = gtk_vbox_new (FALSE, 10);
	gtk_container_add (GTK_CONTAINER(window), vbox);

	// Create the top label.
	widget = gtk_label_new ("ZDoom found more than one IWAD\nSelect from the list below to determine which one to use:");
	gtk_box_pack_start (GTK_BOX(vbox), widget, false, false, 0);
	gtk_misc_set_alignment (GTK_MISC(widget), 0, 0);

	// Create a list store with all the found IWADs.
	store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT);
	for (i = 0; i < numwads; ++i)
	{
		const char *filepart = strrchr (wads[i].Path, '/');
		if (filepart == NULL)
			filepart = wads[i].Path;
		else
			filepart++;
		gtk_list_store_append (store, &iter);
		gtk_list_store_set (store, &iter,
			0, filepart,
			1, wads[i].Name.GetChars(),
			2, i,
			-1);
		if (i == defaultiwad)
		{
			defiter = iter;
		}
	}

	// Create the tree view control to show the list.
	tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store));
	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes ("IWAD", renderer, "text", 0, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW(tree), column);
	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes ("Game", renderer, "text", 1, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW(tree), column);
	gtk_box_pack_start (GTK_BOX(vbox), GTK_WIDGET(tree), true, true, 0);
	g_signal_connect(G_OBJECT(tree), "button_press_event", G_CALLBACK(DoubleClickChecker), &close_style);
	g_signal_connect(G_OBJECT(tree), "key_press_event", G_CALLBACK(AllowDefault), window);

	// Select the default IWAD.
	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(tree));
	gtk_tree_selection_select_iter (selection, &defiter);

	// Create the hbox for the bottom row.
	hbox = gtk_hbox_new (FALSE, 0);
	gtk_box_pack_end (GTK_BOX(vbox), hbox, false, false, 0);

	// Create the "Don't ask" checkbox.
	check = gtk_check_button_new_with_label ("Don't ask me this again");
	gtk_box_pack_start (GTK_BOX(hbox), check, false, false, 0);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(check), !showwin);

	// Create the OK/Cancel button box.
	bbox = gtk_hbutton_box_new ();
	gtk_button_box_set_layout (GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
	gtk_box_set_spacing (GTK_BOX(bbox), 10);
	gtk_box_pack_end (GTK_BOX(hbox), bbox, false, false, 0);

	// Create the OK button.
	widget = gtk_button_new_from_stock (GTK_STOCK_OK);
	gtk_box_pack_start (GTK_BOX(bbox), widget, false, false, 0);
	GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_DEFAULT);
	gtk_widget_grab_default (widget);
	g_signal_connect (widget, "clicked", G_CALLBACK(ClickedOK), &close_style);
	g_signal_connect (widget, "activate", G_CALLBACK(ClickedOK), &close_style);

	// Create the cancel button.
	widget = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
	gtk_box_pack_start (GTK_BOX(bbox), widget, false, false, 0);
	g_signal_connect (widget, "clicked", G_CALLBACK(gtk_main_quit), &window);

	// Finally we can show everything.
	gtk_widget_show_all (window);

	gtk_main ();

	if (close_style == 1)
	{
		GtkTreeModel *model;
		GValue value = { 0, { {0} } };
		
		// Find out which IWAD was selected.
		gtk_tree_selection_get_selected (selection, &model, &iter);
		gtk_tree_model_get_value (GTK_TREE_MODEL(model), &iter, 2, &value);
		i = g_value_get_int (&value);
		g_value_unset (&value);
		
		// Set state of queryiwad based on the checkbox.
		queryiwad = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(check));
	}
	else
	{
		i = -1;
	}
	
	if (GTK_IS_WINDOW(window))
	{
		gtk_widget_destroy (window);
		// If we don't do this, then the X window might not actually disappear.
		while (g_main_context_iteration (NULL, FALSE)) {}
	}

	return i;
}