static void
xplayer_search_entry_init (XplayerSearchEntry *self)
{
	GtkWidget *entry;
	GtkWidget *button;

	self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, XPLAYER_TYPE_SEARCH_ENTRY, XplayerSearchEntryPrivate);

	/* Entry */
	entry = GTK_WIDGET (gd_tagged_entry_new ());
	gd_tagged_entry_set_tag_button_visible (GD_TAGGED_ENTRY (entry), FALSE);
	gtk_box_pack_start (GTK_BOX (self),
			    entry,
			    TRUE, TRUE, 0);
	gtk_widget_show (entry);

	self->priv->entry = entry;

	/* Button */
	button = gtk_menu_button_new ();
	gtk_box_pack_start (GTK_BOX (self),
			    button,
			    FALSE, TRUE, 0);
	gtk_widget_show (button);

	self->priv->button = button;

	/* Connect signals */
	g_signal_connect (self->priv->entry, "activate",
			  G_CALLBACK (entry_activate_cb), self);
}
Example #2
0
static void
ephy_notebook_constructed (GObject *object)
{
  EphyNotebook *notebook = EPHY_NOTEBOOK (object);
  GtkWidget *hbox;
  GtkWidget *button;
  EphyPagesPopover *popover;

  G_OBJECT_CLASS (ephy_notebook_parent_class)->constructed (object);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  gtk_notebook_set_action_widget (GTK_NOTEBOOK (notebook), hbox, GTK_PACK_END);
  gtk_widget_show (hbox);

  button = gtk_menu_button_new ();
  gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
  /* Translators: tooltip for the tab switcher menu button */
  gtk_widget_set_tooltip_text (button, _("View open tabs"));
  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
  gtk_widget_show (button);

  notebook->tab_menu = g_menu_new ();
  /* Remove this when popover menus become scrollable. */
  gtk_menu_button_set_use_popover (GTK_MENU_BUTTON (button), TRUE);

  popover = ephy_pages_popover_new (GTK_WIDGET (button));
  ephy_pages_popover_set_notebook (popover, notebook);
  gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), GTK_WIDGET (popover));
}
static GtkWidget *
garu_headerbar_create_settings_button (GaruHeaderbar *self)
{
  GList           *list;
  GtkWidget       *button, *image;
  GaruApplication *app;
  GMenuModel      *menu_model;

  app = GARU_APPLICATION (g_application_get_default ());

  list = gtk_container_get_children (GTK_CONTAINER (self));
  list = g_list_last (list);
  button = gtk_menu_button_new ();
  gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
  image = gtk_image_new_from_icon_name ("emblem-system-symbolic",
                                        GTK_ICON_SIZE_SMALL_TOOLBAR);
  gtk_button_set_image (GTK_BUTTON (button), image);
  gtk_widget_show (button);
  gtk_box_pack_start (GTK_BOX (list->data), button, FALSE, FALSE, 0);

  /* create menu */
  menu_model = G_MENU_MODEL (garu_application_get_menu (app));
  gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), menu_model);
  g_print ("Removiendo\n");
  g_object_unref (menu_model);

  return button;
}
Example #4
0
GtkWidget *
_gtk_menu_button_new_for_header_bar (void)
{
	GtkWidget *button;

	button = gtk_menu_button_new ();
	_gtk_menu_button_set_style_for_header_bar (button);

	return button;
}
Example #5
0
static void
activate (GApplication *app,
          gpointer      user_data)
{
    GtkWidget *win;
    GtkWidget *button;
    GSimpleActionGroup *doc_actions;
    GtkBuilder *builder;
    GMenuModel *doc_menu;
    GMenuModel *win_menu;
    GMenu *button_menu;
    GMenuItem *section;

    if (gtk_application_get_windows (GTK_APPLICATION (app)) != NULL)
        return;

    win = gtk_application_window_new (GTK_APPLICATION (app));

    doc_actions = g_simple_action_group_new ();
    g_action_map_add_action_entries (G_ACTION_MAP (doc_actions), doc_entries, G_N_ELEMENTS (doc_entries), win);

    g_action_map_add_action_entries (G_ACTION_MAP (win), win_entries,
                                     G_N_ELEMENTS (win_entries), win);

    builder = gtk_builder_new ();
    gtk_builder_add_from_string (builder, menu_ui, -1, NULL);

    doc_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "doc-menu"));
    win_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "win-menu"));

    button_menu = g_menu_new ();

    section = g_menu_item_new_section (NULL, doc_menu);
    g_menu_item_set_attribute (section, "action-namespace", "s", "doc");
    g_menu_append_item (button_menu, section);
    g_object_unref (section);

    section = g_menu_item_new_section (NULL, win_menu);
    g_menu_item_set_attribute (section, "action-namespace", "s", "win");
    g_menu_append_item (button_menu, section);
    g_object_unref (section);

    button = gtk_menu_button_new ();
    gtk_button_set_label (GTK_BUTTON (button), "Menu");
    gtk_widget_insert_action_group (button, "doc", G_ACTION_GROUP (doc_actions));
    gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), G_MENU_MODEL (button_menu));

    gtk_container_add (GTK_CONTAINER (win), button);
    gtk_container_set_border_width (GTK_CONTAINER (win), 12);
    gtk_widget_show_all (win);

    g_object_unref (button_menu);
    g_object_unref (doc_actions);
    g_object_unref (builder);
}
Example #6
0
File: start.c Project: y20k/ezeedo
/**
 * Creates window menu
 */
GtkWidget
*create_windowmenu (ezeedo_wrapper_structure *ezeedo)
{
    // define widgets
    GtkWidget *windowmenu_button;
    GtkWidget *win;
    GMenu     *windowmenu;

    win = ezeedo->window;

    // define actions
    GSimpleAction *toggle_action;

    // create gear menu
    windowmenu = g_menu_new ();
    g_menu_append (windowmenu,
                   "Toggle sidebar",
                   "win.toggle_sidebar");

    // create actions
    toggle_action = g_simple_action_new ("toggle_sidebar",
                                         NULL);
    g_signal_connect (toggle_action, "activate",
                      G_CALLBACK(toggle_sidebar), ezeedo);
    g_action_map_add_action (G_ACTION_MAP(win),
                             G_ACTION(toggle_action));

    // activate ctrl-h
    const gchar* toggle_accels[2] = { "<Ctrl>H", NULL };
    gtk_application_set_accels_for_action (GTK_APPLICATION(ezeedo->application),
                                           "win.toggle_sidebar",
                                            toggle_accels);

    // create window menu 
    windowmenu_button  = gtk_menu_button_new ();
    gtk_menu_button_set_direction (GTK_MENU_BUTTON(windowmenu_button),
                                   GTK_ARROW_NONE);

    // attach window menu to button
    gtk_menu_button_set_use_popover (GTK_MENU_BUTTON(windowmenu_button),
                                     true);
    gtk_menu_button_set_menu_model (GTK_MENU_BUTTON(windowmenu_button),
                                    G_MENU_MODEL(windowmenu)); 

    // return button with window menu
    return (windowmenu_button);
}
Example #7
0
static void
ekiga_window_init_actions_toolbar (EkigaWindow *mw)
{
  GtkWidget *image = NULL;
  GtkWidget *button = NULL;
  GtkWidget *switcher = NULL;

  g_return_if_fail (EKIGA_IS_WINDOW (mw));

  mw->priv->actions_toolbar = gtk_header_bar_new ();
  gtk_window_set_titlebar (GTK_WINDOW (mw), mw->priv->actions_toolbar);

  /* Start packing buttons */
  button = gtk_button_new ();
  image = gtk_image_new_from_icon_name ("call-start-symbolic", GTK_ICON_SIZE_MENU);
  gtk_button_set_image (GTK_BUTTON (button), image);
  gtk_widget_set_tooltip_text (GTK_WIDGET (button),
                               _("Call the selected contact"));
  gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (button), "win.call");
  gtk_header_bar_pack_start (GTK_HEADER_BAR (mw->priv->actions_toolbar), button);

  mw->priv->preview_button = gtk_toggle_button_new ();
  image = gtk_image_new_from_icon_name ("camera-web-symbolic", GTK_ICON_SIZE_MENU);
  gtk_button_set_image (GTK_BUTTON (mw->priv->preview_button), image);
  gtk_widget_set_tooltip_text (GTK_WIDGET (mw->priv->preview_button),
                               _("Display images from your camera device"));

  gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (mw->priv->preview_button),
                                           "win.enable-preview");
  gtk_header_bar_pack_start (GTK_HEADER_BAR (mw->priv->actions_toolbar), mw->priv->preview_button);

  switcher = gtk_stack_switcher_new ();
  gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (mw->priv->main_stack));
  gtk_header_bar_set_custom_title (GTK_HEADER_BAR (mw->priv->actions_toolbar), switcher);
  gtk_widget_set_margin_end (GTK_WIDGET (switcher), 6);

  mw->priv->menu_button = gtk_menu_button_new ();
  g_object_set (G_OBJECT (mw->priv->menu_button), "use-popover", true, NULL);
  image = gtk_image_new_from_icon_name ("open-menu-symbolic", GTK_ICON_SIZE_MENU);
  gtk_button_set_image (GTK_BUTTON (mw->priv->menu_button), image);
  gtk_header_bar_pack_end (GTK_HEADER_BAR (mw->priv->actions_toolbar), mw->priv->menu_button);
  gtk_widget_show_all (mw->priv->actions_toolbar);

  gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (mw->priv->actions_toolbar), TRUE);
}
Example #8
0
static void
activate (GtkApplication *app,
          gpointer        user_data)
{
  GMenu *submenu;
  GtkWidget *grid;
  GMenu *menumodel;
  GtkWidget *window;
  GtkWidget *menubutton;
  GSimpleAction *about_action;

  window = gtk_application_window_new (app);
  grid = gtk_grid_new ();

  gtk_window_set_title (GTK_WINDOW (window), "MenuButton Example");
  gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);

  menubutton = gtk_menu_button_new ();
  gtk_widget_set_size_request (menubutton, 80, 35);

  gtk_grid_attach (GTK_GRID (grid), menubutton, 0, 0, 1, 1);
  gtk_container_add (GTK_CONTAINER (window), grid);

  menumodel = g_menu_new ();
  g_menu_append (menumodel, "New", "app.new");
  g_menu_append (menumodel, "About", "win.about");

  submenu = g_menu_new ();
  g_menu_append_submenu (menumodel, "Other", G_MENU_MODEL (submenu));
  g_menu_append (submenu, "Quit", "app.quit");
  gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (menubutton), G_MENU_MODEL (menumodel));

  about_action = g_simple_action_new ("about", NULL);
  g_signal_connect (about_action, "activate", G_CALLBACK (about_callback),
                    GTK_WINDOW (window));
  g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (about_action));

  gtk_widget_show_all (window);
}
Example #9
0
static GtkWidget *
toolbar_create_toolbutton (NautilusToolbar *self,
			   gboolean create_menu,
			   gboolean create_toggle,
			   const gchar *name,
			   const gchar *tooltip)
{
	GtkWidget *button, *image;
	GtkActionGroup *action_group;
	GtkAction *action;

	action_group = nautilus_window_get_main_action_group (self->priv->window);

	if (create_menu) {
		button = gtk_menu_button_new ();
	} else if (create_toggle) {
		button = gtk_toggle_button_new ();
	} else {
		button = gtk_button_new ();
	}

	image = gtk_image_new ();

	gtk_button_set_image (GTK_BUTTON (button), image);

	if (create_menu) {
		gtk_image_set_from_icon_name (GTK_IMAGE (image), name,
					      GTK_ICON_SIZE_MENU);
		gtk_widget_set_tooltip_text (button, tooltip);
	} else {
		action = gtk_action_group_get_action (action_group, name);
		gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), action);
		gtk_button_set_label (GTK_BUTTON (button), NULL);
		gtk_widget_set_tooltip_text (button, gtk_action_get_tooltip (action));
	}

	return button;
}
Example #10
0
File: widgets.c Project: GNOME/gtk
static WidgetInfo *
create_menu_button (void)
{
  GtkWidget *widget;
  GtkWidget *image;
  GtkWidget *menu;
  GtkWidget *vbox;

  widget = gtk_menu_button_new ();
  image = gtk_image_new ();
  gtk_image_set_from_icon_name (GTK_IMAGE (image), "emblem-system-symbolic");
  gtk_container_add (GTK_CONTAINER (widget), image);
  menu = gtk_menu_new ();
  gtk_menu_button_set_popup (GTK_MENU_BUTTON (widget), menu);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
  gtk_container_add (GTK_CONTAINER (vbox), widget);
  gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
  gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);

  gtk_container_add (GTK_CONTAINER (vbox), gtk_label_new ("Menu Button"));

  return new_widget_info ("menu-button", vbox, SMALL);
}
Example #11
0
static void
scrollable_policy (void)
{
  GtkWidget *window, *swindow, *hbox, *vbox, *frame, *cntl, *listbox;
  GtkWidget *viewport, *label, *expander, *widget, *popover;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  hbox   = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
  vbox   = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);

  gtk_container_set_border_width (GTK_CONTAINER (window), 8);

  gtk_widget_show (vbox);
  gtk_widget_show (hbox);
  gtk_container_add (GTK_CONTAINER (window), hbox);
  gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);

  frame = gtk_frame_new ("Scrolled Window");
  gtk_widget_show (frame);
  gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);

  swindow = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  
  gtk_widget_show (swindow);
  gtk_container_add (GTK_CONTAINER (frame), swindow);

  viewport = gtk_viewport_new (NULL, NULL);
  label = gtk_label_new ("Here is a wrapping label with a minimum width-chars of 40 and "
			 "a natural max-width-chars of 100 to demonstrate the usage of "
			 "scrollable widgets \"hscroll-policy\" and \"vscroll-policy\" "
			 "properties. Note also that when playing with the window height, "
			 "one can observe that the vscrollbar disappears as soon as there "
			 "is enough height to fit the content vertically if the window were "
			 "to be allocated a width without a vscrollbar present");

  gtk_label_set_line_wrap  (GTK_LABEL (label), TRUE);
  gtk_label_set_width_chars  (GTK_LABEL (label), 40);
  gtk_label_set_max_width_chars  (GTK_LABEL (label), 100);

  gtk_widget_show (label);
  gtk_widget_show (viewport);
  gtk_container_add (GTK_CONTAINER (viewport), label);
  gtk_container_add (GTK_CONTAINER (swindow), viewport);

  /* Add controls here */
  expander = gtk_expander_new ("Controls");
  gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE);
  cntl = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
  gtk_widget_show (cntl);
  gtk_widget_show (expander);
  gtk_container_add (GTK_CONTAINER (expander), cntl);
  gtk_box_pack_start (GTK_BOX (vbox), expander, FALSE, FALSE, 0);

  /* Add Horizontal policy control here */
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
  gtk_widget_show (hbox);

  widget = gtk_label_new ("hscroll-policy");
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);

  widget = gtk_combo_box_text_new ();
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Minimum");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Natural");
  gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
  gtk_widget_show (widget);

  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (cntl), hbox, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (horizontal_policy_changed), viewport);

  /* Add Vertical policy control here */
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
  gtk_widget_show (hbox);

  widget = gtk_label_new ("vscroll-policy");
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);

  widget = gtk_combo_box_text_new ();
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Minimum");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Natural");
  gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
  gtk_widget_show (widget);

  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (cntl), hbox, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (vertical_policy_changed), viewport);

  /* Content size controls */
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);

  widget = gtk_label_new ("min-content-width");
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);

  widget = gtk_spin_button_new_with_range (100.0, 1000.0, 10.0);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (cntl), hbox, FALSE, FALSE, 0);
  gtk_widget_show (widget);
  gtk_widget_show (hbox);

  g_signal_connect (G_OBJECT (widget), "value-changed",
                    G_CALLBACK (content_width_changed), swindow);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);

  widget = gtk_label_new ("min-content-height");
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);

  widget = gtk_spin_button_new_with_range (100.0, 1000.0, 10.0);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (cntl), hbox, FALSE, FALSE, 0);
  gtk_widget_show (widget);
  gtk_widget_show (hbox);

  g_signal_connect (G_OBJECT (widget), "value-changed",
                    G_CALLBACK (content_height_changed), swindow);

  /* Add Label orientation control here */
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
  gtk_widget_show (hbox);

  widget = gtk_label_new ("label-flip");
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);

  widget = gtk_combo_box_text_new ();
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Horizontal");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Vertical");
  gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
  gtk_widget_show (widget);

  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (cntl), hbox, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (label_flip_changed), label);

  /* Add Kinetic scrolling control here */
  widget = gtk_check_button_new_with_label ("Kinetic scrolling");
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (cntl), widget, TRUE, TRUE, 0);
  g_signal_connect (G_OBJECT (widget), "toggled",
                    G_CALLBACK (kinetic_scrolling_changed), swindow);

  gtk_widget_show (window);

  /* Popover */
  popover = gtk_popover_new (NULL);

  widget = gtk_menu_button_new ();
  gtk_menu_button_set_popover (GTK_MENU_BUTTON (widget), popover);
  gtk_container_add (GTK_CONTAINER (widget), gtk_label_new ("Popover"));
  gtk_box_pack_start (GTK_BOX (cntl), widget, FALSE, FALSE, 0);
  gtk_widget_show_all (widget);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  gtk_container_add (GTK_CONTAINER (popover), vbox);
  gtk_widget_show (vbox);

  /* Popover's scrolled window */
  swindow = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

  gtk_box_pack_end (GTK_BOX (vbox), swindow, FALSE, FALSE, 0);
  gtk_widget_show (swindow);
  gtk_widget_show (hbox);

  /* Listbox */
  listbox = gtk_list_box_new ();
  gtk_container_add (GTK_CONTAINER (swindow), listbox);
  gtk_widget_show (listbox);

  /* Min content */
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);

  widget = gtk_label_new ("min-content-width");
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);

  widget = gtk_spin_button_new_with_range (0.0, 150.0, 10.0);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
  gtk_widget_show (widget);
  gtk_widget_show (hbox);

  g_object_bind_property (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)),
                          "value",
                          swindow,
                          "min-content-width",
                          G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);

  widget = gtk_label_new ("min-content-height");
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);


  widget = gtk_spin_button_new_with_range (0.0, 150.0, 10.0);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
  gtk_widget_show (widget);
  gtk_widget_show (hbox);

  g_object_bind_property (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)),
                          "value",
                          swindow,
                          "min-content-height",
                          G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);

  /* Max content */
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);

  widget = gtk_label_new ("max-content-width");
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);

  widget = gtk_spin_button_new_with_range (250.0, 1000.0, 10.0);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
  gtk_widget_show (widget);
  gtk_widget_show (hbox);

  g_object_bind_property (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)),
                          "value",
                          swindow,
                          "max-content-width",
                          G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);

  widget = gtk_label_new ("max-content-height");
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);

  widget = gtk_spin_button_new_with_range (250.0, 1000.0, 10.0);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
  gtk_widget_show (widget);
  gtk_widget_show (hbox);

  g_object_bind_property (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)),
                          "value",
                          swindow,
                          "max-content-height",
                          G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);

  /* Add and Remove buttons */
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);

  widget = gtk_button_new_with_label ("Remove");
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);

  g_signal_connect (widget, "clicked",
                    G_CALLBACK (remove_row), listbox);

  widget = gtk_button_new_with_label ("Add");
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
  gtk_widget_show (widget);
  gtk_widget_show (hbox);

  g_signal_connect (widget, "clicked",
                    G_CALLBACK (add_row), listbox);
}
Example #12
0
int
main (int argc, char *argv[])
{
  GtkWidget *win;
  GtkWidget *box;
  GtkWidget *button;
  GtkWidget *button2;
  GtkBuilder *builder;
  GMenuModel *model;
  GSimpleActionGroup *actions;
  GtkWidget *overlay;
  GtkWidget *grid;
  GtkWidget *popover;
  GtkWidget *popover2;
  GtkWidget *label;
  GtkWidget *check;
  GtkWidget *combo;

  gtk_init (&argc, &argv);

  win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (win), 400, 600);
  actions = g_simple_action_group_new ();
  g_action_map_add_action_entries (G_ACTION_MAP (actions), entries, G_N_ELEMENTS (entries), NULL);

  gtk_widget_insert_action_group (win, "top", G_ACTION_GROUP (actions));

  overlay = gtk_overlay_new ();
  gtk_container_add (GTK_CONTAINER (win), overlay);

  grid = gtk_grid_new ();
  gtk_widget_set_halign (grid, GTK_ALIGN_FILL);
  gtk_widget_set_valign (grid, GTK_ALIGN_FILL);
  gtk_grid_set_row_spacing (GTK_GRID (grid), 10);
  gtk_grid_set_column_spacing (GTK_GRID (grid), 10);
  gtk_container_add (GTK_CONTAINER (overlay), grid);

  label = gtk_label_new ("");
  gtk_widget_set_hexpand (label, TRUE);
  gtk_widget_set_vexpand (label, TRUE);
  gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);

  label = gtk_label_new ("");
  gtk_widget_set_hexpand (label, TRUE);
  gtk_widget_set_vexpand (label, TRUE);
  gtk_grid_attach (GTK_GRID (grid), label, 3, 6, 1, 1);

  builder = gtk_builder_new_from_file ("popover.ui");
  model = (GMenuModel *)gtk_builder_get_object (builder, "menu");

  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
  button = gtk_menu_button_new ();
  gtk_container_add (GTK_CONTAINER (box), button);
  button2 = gtk_menu_button_new ();
  gtk_container_add (GTK_CONTAINER (box), button2);

  gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), model);
  gtk_menu_button_set_use_popover (GTK_MENU_BUTTON (button), TRUE);
  popover = GTK_WIDGET (gtk_menu_button_get_popover (GTK_MENU_BUTTON (button)));

  builder = gtk_builder_new_from_file ("popover2.ui");
  popover2 = (GtkWidget *)gtk_builder_get_object (builder, "popover");
  gtk_menu_button_set_popover (GTK_MENU_BUTTON (button2), popover2);

  g_object_set (box, "margin", 10, NULL);
  gtk_widget_set_halign (box, GTK_ALIGN_END);
  gtk_widget_set_valign (box, GTK_ALIGN_START);
  gtk_overlay_add_overlay (GTK_OVERLAY (overlay), box);

  label = gtk_label_new ("Popover hexpand");
  check = gtk_check_button_new ();
  g_object_bind_property (check, "active", popover, "hexpand", G_BINDING_DEFAULT);
  g_object_bind_property (check, "active", popover2, "hexpand", G_BINDING_DEFAULT);
  gtk_grid_attach (GTK_GRID (grid), label , 1, 1, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), check, 2, 1, 1, 1);

  label = gtk_label_new ("Popover vexpand");
  check = gtk_check_button_new ();
  g_object_bind_property (check, "active", popover, "vexpand", G_BINDING_DEFAULT);
  g_object_bind_property (check, "active", popover2, "vexpand", G_BINDING_DEFAULT);
  gtk_grid_attach (GTK_GRID (grid), label , 1, 2, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), check, 2, 2, 1, 1);

  label = gtk_label_new ("Button direction");
  combo = gtk_combo_box_text_new ();
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "up", "Up");
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "down", "Down");
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "left", "Left");
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "right", "Right");

  g_object_bind_property (combo, "active", button, "direction", G_BINDING_DEFAULT);
  g_object_bind_property (combo, "active", button2, "direction", G_BINDING_DEFAULT);
  gtk_grid_attach (GTK_GRID (grid), label , 1, 3, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), combo, 2, 3, 1, 1);

  label = gtk_label_new ("Button halign");
  combo = gtk_combo_box_text_new ();
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "fill", "Fill");
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "start", "Start");
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "end", "End");
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "center", "Center");
  g_object_bind_property (combo, "active", box, "halign", G_BINDING_DEFAULT);
  gtk_grid_attach (GTK_GRID (grid), label , 1, 4, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), combo, 2, 4, 1, 1);

  label = gtk_label_new ("Button valign");
  combo = gtk_combo_box_text_new ();
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "fill", "Fill");
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "start", "Start");
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "end", "End");
  gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "center", "Center");
  g_object_bind_property (combo, "active", box, "valign", G_BINDING_DEFAULT);
  gtk_grid_attach (GTK_GRID (grid), label , 1, 5, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), combo, 2, 5, 1, 1);


  gtk_widget_show_all (win);

  gtk_main ();

  return 0;
}
Example #13
0
int main (int argc, char **argv)
{
	GtkWidget *window;
	GtkWidget *button;
	GtkWidget *grid;
	GtkWidget *entry;
	GtkWidget *menu_widget;
	GtkAccelGroup *accel_group;
	guint i;
	GMenu *menu;

	gtk_init (&argc, &argv);

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_resize (GTK_WINDOW (window), 400, 300);

	grid = gtk_grid_new ();
	gtk_container_add (GTK_CONTAINER (window), grid);

	accel_group = gtk_accel_group_new ();
	gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);

	/* Button next to entry */
	entry = gtk_entry_new ();
	gtk_grid_attach (GTK_GRID (grid),
			 entry,
			 0, 0,
			 1, 1);
	button = gtk_menu_button_new ();
	gtk_grid_attach (GTK_GRID (grid),
			 button,
			 1, 0,
			 1, 1);

	/* Button with GtkMenu */
	menu_widget = gtk_menu_new ();
	for (i = 5; i > 0; i--) {
		GtkWidget *item;

		if (i == 3) {
			item = gtk_menu_item_new_with_mnemonic ("_Copy");
		} else {
			char *label;

			label = g_strdup_printf ("Item _%d", i);
			item = gtk_menu_item_new_with_mnemonic (label);
			g_free (label);
		}
		gtk_menu_item_set_use_underline (GTK_MENU_ITEM (item), TRUE);
		gtk_menu_attach (GTK_MENU (menu_widget),
				 item,
				 0, 1,
				 i - 1, i);
	}
	gtk_widget_show_all (menu_widget);

	button = gtk_menu_button_new ();
	gtk_menu_button_set_popup (GTK_MENU_BUTTON (button), menu_widget);
	gtk_grid_attach (GTK_GRID (grid),
			 button,
			 1, 1,
			 1, 1);
	gtk_widget_show (create_prop_editor (G_OBJECT (button), 0));

	/* Button with GMenuModel */
	menu = g_menu_new ();
	for (i = 5; i > 0; i--) {
		char *label;
                GMenuItem *item;
		label = g_strdup_printf ("Item _%d", i);
                item = g_menu_item_new (label, NULL);
                if (i == 3)
                  g_menu_item_set_attribute (item, "icon", "s", "preferences-desktop-locale-symbolic");
		g_menu_insert_item (menu, i - 1, item);
                g_object_unref (item);
		g_free (label);
	}
	button = gtk_menu_button_new ();
	gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), G_MENU_MODEL (menu));
	gtk_grid_attach (GTK_GRID (grid),
			 button,
			 1, 2,
			 1, 1);

	gtk_widget_show_all (window);

	gtk_main ();

	return 0;
}
Example #14
0
static void
gdaui_dsn_editor_init (GdauiDsnEditor *config, G_GNUC_UNUSED GdauiDsnEditorClass *klass)
{
	GtkWidget *grid;
	GtkWidget *label;
	GtkWidget *exp;
	gchar *str;

	g_return_if_fail (GDAUI_IS_DSN_EDITOR (config));

	gtk_orientable_set_orientation (GTK_ORIENTABLE (config), GTK_ORIENTATION_VERTICAL);

	/* allocate private structure */
	config->priv = g_new0 (GdauiDsnEditorPrivate, 1);
	config->priv->dsn_info = g_new0 (GdaDsnInfo, 1);
	config->priv->no_change_signal = TRUE;

	/* data source's name and icon */
	GtkWidget *hbox_header;
	hbox_header = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_box_pack_start (GTK_BOX (config), hbox_header, FALSE, FALSE, 6);
	config->priv->icon = gtk_image_new ();
	gtk_widget_set_size_request (config->priv->icon, -1, SUPPORT_ICON_SIZE);
	gtk_box_pack_start (GTK_BOX (hbox_header), config->priv->icon, FALSE, FALSE, 0);
	config->priv->wname = gtk_label_new ("");
	gtk_box_pack_start (GTK_BOX (hbox_header), config->priv->wname, FALSE, FALSE, 10);

	GtkWidget *menu_button;
	menu_button = gtk_menu_button_new ();
	gtk_box_pack_end (GTK_BOX (hbox_header), menu_button, FALSE, FALSE, 0);

	GtkWidget *menu_icon;
        menu_icon = gtk_image_new_from_icon_name ("open-menu-symbolic", GTK_ICON_SIZE_MENU);
        gtk_button_set_image (GTK_BUTTON (menu_button), menu_icon);

	GMenu *smenu;
        smenu = g_menu_new ();
        gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (menu_button), G_MENU_MODEL (smenu));

	GMenuItem *mitem;
        mitem = g_menu_item_new ("Test data source", "win.DSNTest");
        g_menu_insert_item (smenu, -1, mitem);
        mitem = g_menu_item_new ("Reset data source's changes", "win.DSNReset");
        g_menu_insert_item (smenu, -1, mitem);
        mitem = g_menu_item_new ("Duplicate data source", "win.DSNCopy");
        g_menu_insert_item (smenu, -1, mitem);

	GtkWindow *win;
	win = gtk_application_get_active_window (GTK_APPLICATION (g_application_get_default ()));
	g_action_map_add_action_entries (G_ACTION_MAP (win), win_entries, G_N_ELEMENTS (win_entries), config);

	/* stack in a scrolled window */
	GtkWidget *sw;
	sw = gtk_scrolled_window_new (NULL, NULL);
	gtk_widget_set_vexpand (sw, TRUE);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_NONE);
	gtk_box_pack_start (GTK_BOX (config), sw, TRUE, TRUE, 6);

	/* Stack */
	config->priv->stack = gtk_stack_new ();
	gtk_stack_set_transition_type (GTK_STACK (config->priv->stack), GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT);
	gtk_container_add (GTK_CONTAINER (sw), config->priv->stack);
	
	/* set up widgets */
	grid = gtk_grid_new ();
	gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
	gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
	gtk_widget_show (grid);

	label = gtk_label_new_with_mnemonic (_("_System wide data source:"));
	gtk_widget_set_halign (label, GTK_ALIGN_START);
	gtk_widget_set_hexpand (label, FALSE);
	g_object_set (G_OBJECT (label), "xalign", 0., NULL);
	gtk_widget_show (label);
	gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);
	config->priv->is_system = gtk_check_button_new ();
	gtk_widget_show (config->priv->is_system);
	g_signal_connect (G_OBJECT (config->priv->is_system), "toggled",
			  G_CALLBACK (field_toggled_cb), config);
	gtk_grid_attach (GTK_GRID (grid), config->priv->is_system, 1, 1, 1, 1);

	str = g_strdup_printf ("%s <span foreground='red' weight='bold'>*</span>", _("_Provider:"));
	label = gtk_label_new ("");
	gtk_label_set_markup_with_mnemonic (GTK_LABEL (label), str);
	g_free (str);
	gtk_widget_set_halign (label, GTK_ALIGN_START);
	gtk_widget_set_hexpand (label, FALSE);
	g_object_set (G_OBJECT (label), "xalign", 0., NULL);
	gtk_widget_show (label);
	gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1);
	config->priv->wprovider = gdaui_provider_selector_new ();
	gtk_widget_set_hexpand (config->priv->wprovider, TRUE);
	gtk_label_set_mnemonic_widget (GTK_LABEL (label), config->priv->wprovider);
	gtk_widget_show (config->priv->wprovider);
	g_signal_connect (G_OBJECT (config->priv->wprovider), "changed",
			  G_CALLBACK (field_changed_cb), config);
	gtk_grid_attach (GTK_GRID (grid), config->priv->wprovider, 1, 2, 1, 1);

	label = gtk_label_new_with_mnemonic (_("_Description:"));
	gtk_widget_set_halign (label, GTK_ALIGN_START);
	gtk_widget_set_hexpand (label, FALSE);
	g_object_set (G_OBJECT (label), "xalign", 0., NULL);
	gtk_widget_show (label);
	gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 1, 1);

	sw = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER);
	config->priv->wdesc = gtk_text_view_new ();
	gtk_container_add (GTK_CONTAINER (sw), config->priv->wdesc);
	gtk_text_view_set_editable (GTK_TEXT_VIEW (config->priv->wdesc), TRUE);
	gtk_widget_set_vexpand (config->priv->wdesc, TRUE);
	gtk_label_set_mnemonic_widget (GTK_LABEL (label), config->priv->wdesc);
	g_signal_connect (gtk_text_view_get_buffer (GTK_TEXT_VIEW (config->priv->wdesc)), "changed",
			  G_CALLBACK (field_changed_cb), config);
	gtk_grid_attach (GTK_GRID (grid), sw, 1, 3, 1, 1);

	config->priv->warning = gtk_label_new (NULL);
	gtk_label_set_markup (GTK_LABEL (config->priv->warning),
			      _("<span foreground='red'>The database provider used by this data source is not available,\n"
				"editing the data source's attributes is disabled</span>"));
	gtk_widget_set_halign (config->priv->warning, GTK_ALIGN_CENTER);
	gtk_widget_set_hexpand (config->priv->warning, TRUE);
	g_object_set (G_OBJECT (config->priv->warning), "xalign", 0.5, NULL);
	gtk_label_set_justify (GTK_LABEL (config->priv->warning), GTK_JUSTIFY_CENTER);
	gtk_label_set_line_wrap (GTK_LABEL (config->priv->warning), TRUE);
	gtk_grid_attach (GTK_GRID (grid), config->priv->warning, 0, 8, 2, 1);
	gtk_stack_add_named (GTK_STACK (config->priv->stack), grid, PANE_DEFINITION);

	/* connection's spec */
	config->priv->dsn_spec = _gdaui_provider_spec_editor_new (gdaui_provider_selector_get_provider 
								 (GDAUI_PROVIDER_SELECTOR (config->priv->wprovider)));
	g_signal_connect (G_OBJECT (config->priv->dsn_spec), "changed",
			  G_CALLBACK (field_changed_cb), config);
	gtk_widget_show (config->priv->dsn_spec);
	gtk_stack_add_named (GTK_STACK (config->priv->stack), config->priv->dsn_spec, PANE_PARAMS);

	/* connection's authentication */
	config->priv->dsn_auth = _gdaui_provider_auth_editor_new (gdaui_provider_selector_get_provider 
								 (GDAUI_PROVIDER_SELECTOR (config->priv->wprovider)));
	g_signal_connect (G_OBJECT (config->priv->dsn_auth), "changed",
			  G_CALLBACK (field_changed_cb), config);
	gtk_widget_show (config->priv->dsn_auth);
	gtk_stack_add_named (GTK_STACK (config->priv->stack), config->priv->dsn_auth, PANE_AUTH);

	config->priv->no_change_signal = FALSE;
}
Example #15
0
static void
GyahtzeeCreateMainWindow (GApplication *app, gpointer user_data)
{
  GtkWidget *hbox, *vbox;
  GtkWidget *toolbar;
  GtkWidget *tmp;
  GtkWidget *dicebox;
  GtkWidget *undo_button;
  GtkWidget *menu_button;
  GtkWidget *icon;
  GtkBuilder *builder;
  GMenuModel *appmenu;
  int i, j;

  window = gtk_application_window_new (application);
  gtk_window_set_application (GTK_WINDOW (window), application);
  gtk_window_set_title (GTK_WINDOW (window), _(appName));
  gtk_window_set_hide_titlebar_when_maximized (GTK_WINDOW (window), FALSE);
  gtk_window_set_icon_name (GTK_WINDOW (window), "org.gnome.Tali");

  //games_conf_add_window (GTK_WINDOW (window), NULL);

  g_signal_connect (GTK_WIDGET (window), "key_press_event",
		    G_CALLBACK (key_press), NULL);

  g_action_map_add_action_entries (G_ACTION_MAP (application), app_entries, G_N_ELEMENTS (app_entries), application);
  const gchar *vaccels_help[] = {"F1", NULL};
  const gchar *vaccels_new[] = {"<Primary>n", NULL};
  const gchar *vaccels_roll[] = {"<Primary>r", NULL};
  const gchar *vaccels_undo[] = {"<Primary>z", NULL};

  gtk_application_set_accels_for_action (application, "app.help", vaccels_help);
  gtk_application_set_accels_for_action (application, "app.new-game", vaccels_new);
  gtk_application_set_accels_for_action (application, "app.roll", vaccels_roll);
  gtk_application_set_accels_for_action (application, "app.undo", vaccels_undo);

  scores_action = g_action_map_lookup_action (G_ACTION_MAP (application), "scores");
  undo_action   = g_action_map_lookup_action (G_ACTION_MAP (application), "undo");
  update_undo_sensitivity ();

        /*--- Headerbar ---*/
  hbar = gtk_header_bar_new ();
  gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (hbar), TRUE);
  gtk_header_bar_set_title (GTK_HEADER_BAR (hbar), _(appName));
  gtk_widget_show (hbar);
  gtk_window_set_titlebar (GTK_WINDOW (window), hbar);

  if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)
    undo_button = gtk_button_new_from_icon_name ("edit-undo-rtl-symbolic", GTK_ICON_SIZE_BUTTON);
  else
    undo_button = gtk_button_new_from_icon_name ("edit-undo-symbolic", GTK_ICON_SIZE_BUTTON);
  gtk_widget_set_valign (undo_button, GTK_ALIGN_CENTER);
  gtk_actionable_set_action_name (GTK_ACTIONABLE (undo_button), "app.undo");
  gtk_widget_set_tooltip_text (undo_button, _("Undo your most recent move"));
  gtk_widget_show (undo_button);
  gtk_header_bar_pack_start (GTK_HEADER_BAR (hbar), undo_button);

  builder = gtk_builder_new_from_resource ("/org/gnome/Tali/ui/menus.ui");
  appmenu = (GMenuModel *) gtk_builder_get_object (builder, "app-menu");

  menu_button = gtk_menu_button_new();
  icon = gtk_image_new_from_icon_name ("open-menu-symbolic", GTK_ICON_SIZE_BUTTON);
  gtk_button_set_image (GTK_BUTTON (menu_button), icon);
  gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (menu_button), appmenu);
  gtk_widget_show (menu_button);
  gtk_header_bar_pack_end (GTK_HEADER_BAR (hbar), menu_button);

	/*---- Content ----*/

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);

  gtk_container_add (GTK_CONTAINER (window), vbox);

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

  /* Retreive dice pixmaps from memory or files */
  LoadDicePixmaps ();

  /* Put all the dice in a vertical column */
  dicebox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  gtk_box_pack_start (GTK_BOX (hbox), dicebox, FALSE, TRUE, 0);
  gtk_widget_show (dicebox);

  rollLabel = gtk_label_new (NULL);
  gtk_label_set_use_markup (GTK_LABEL (rollLabel), TRUE);
  gtk_widget_show (rollLabel);
  gtk_box_pack_start (GTK_BOX (dicebox), rollLabel, FALSE, TRUE, 5);

  mbutton = gtk_button_new_with_label (_("Roll!"));
  gtk_box_pack_end (GTK_BOX (dicebox), mbutton, FALSE, FALSE, 5);
  g_signal_connect (GTK_BUTTON (mbutton), "clicked",
		    G_CALLBACK (roll_button_pressed_cb), NULL);
  gtk_widget_show (GTK_WIDGET (mbutton));

  toolbar = gtk_toolbar_new ();
  gtk_orientable_set_orientation (GTK_ORIENTABLE (toolbar),
			       GTK_ORIENTATION_VERTICAL);
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
  gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), FALSE);
  gtk_box_pack_end (GTK_BOX (dicebox), toolbar, TRUE, TRUE, 0);

  for (i = 0; i < NUMBER_OF_DICE; i++) {
    tmp = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);

    for (j = 0; j < NUMBER_OF_PIXMAPS; j++) {
      gtk_box_pack_start (GTK_BOX (tmp), dicePixmaps[i][j][GAME_YAHTZEE], FALSE, FALSE, 0);
      gtk_box_pack_start (GTK_BOX (tmp), dicePixmaps[i][j][GAME_KISMET], FALSE, FALSE, 0);
    }

    diceBox[i] = gtk_toggle_tool_button_new ();
    gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (diceBox[i]), tmp);
    g_signal_connect (GTK_TOOL_BUTTON (diceBox[i]), "clicked",
		      G_CALLBACK (modify_dice), &DiceValues[i]);

    gtk_toolbar_insert (GTK_TOOLBAR (toolbar),
			GTK_TOOL_ITEM (diceBox[i]), -1);

    gtk_widget_show (GTK_WIDGET (diceBox[i]));
    gtk_widget_show (tmp);
  /*gtk_widget_show (dicePixmaps[i][0][game_type]);*/
  }
  gtk_widget_show (toolbar);

  /* Scores displayed in score list */
  ScoreList = create_score_list ();
  gtk_box_pack_end (GTK_BOX (hbox), ScoreList, TRUE, TRUE, 0);
  setup_score_list (ScoreList);
  gtk_widget_show (ScoreList);

  gtk_widget_show (hbox);
  gtk_widget_show (vbox);
}
Example #16
0
static gboolean
append_menu (RBButtonBar *bar, GMenuModel *menu, gboolean need_separator)
{
	int i;
	gulong id;

	id = g_signal_connect (menu, "items-changed", G_CALLBACK (items_changed_cb), bar);
	g_hash_table_insert (bar->priv->handlers, (gpointer)id, g_object_ref (menu));

	for (i = 0; i < g_menu_model_get_n_items (menu); i++) {
		char *label_text;
		char *accel;
		GtkWidget *button;
		GtkWidget *label;
		GMenuModel *submenu;

		/* recurse into sections */
		submenu = g_menu_model_get_item_link (menu, i, G_MENU_LINK_SECTION);
		if (submenu != NULL) {
			need_separator = append_menu (bar, submenu, TRUE);
			continue;
		}

		/* if this item and the previous item are in different sections, add
		 * a separator between them.  this may not be a good idea.
		 */
		if (need_separator) {
			GtkWidget *sep;

			if (bar->priv->position > 0) {
				sep = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
				gtk_widget_show (sep);
				g_object_set (sep, "margin-start", 6, "margin-end", 6, NULL);
				gtk_grid_attach (GTK_GRID (bar), sep, bar->priv->position++, 0, 1, 1);
			}

			need_separator = FALSE;
		}

		button = NULL;

		/* submenus become menu buttons, normal items become buttons */
		submenu = g_menu_model_get_item_link (menu, i, G_MENU_LINK_SUBMENU);

		if (submenu != NULL) {
			button = gtk_menu_button_new ();
			gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), submenu);

			g_object_set_data_full (G_OBJECT (button), "rb-menu-model", g_object_ref (submenu), (GDestroyNotify)g_object_unref);
		} else {
			GMenuAttributeIter *iter;
			const char *name;
			GVariant *value;
			char *str;
			guint signal_id;
		
			/* we can't do more than one of action and rb-property-bind
			 * and rb-signal-bind, so just do whichever turns up first
			 * in the iterator
			 */
			iter = g_menu_model_iterate_item_attributes (menu, i);
			while (g_menu_attribute_iter_get_next (iter, &name, &value)) {
				if (g_str_equal (name, "action")) {
					button = gtk_button_new ();
					g_variant_get (value, "s", &str, NULL);
					gtk_actionable_set_action_name (GTK_ACTIONABLE (button), str);
					/* action target too somehow? */
					g_free (str);
					break;
				} else if (g_str_equal (name, "rb-property-bind")) {
					/* property has to be a boolean, can't do inverts, etc. etc. */
					button = gtk_toggle_button_new ();
					g_variant_get (value, "s", &str, NULL);
					g_object_bind_property (bar->priv->target, str,
								button, "active",
								G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
					g_free (str);
					break;
				} else if (g_str_equal (name, "rb-signal-bind")) {
					button = gtk_button_new ();
					g_variant_get (value, "s", &str, NULL);
					signal_id = g_signal_lookup (str, G_OBJECT_TYPE (bar->priv->target));
					if (signal_id != 0) {
						g_object_set_data (G_OBJECT (button), "rb-signal-bind-id", GUINT_TO_POINTER (signal_id));
						g_signal_connect (button, "clicked", G_CALLBACK (signal_button_clicked_cb), bar);
					}
					g_free (str);
					break;
				}
			}

			g_object_unref (iter);
		}

		if (button == NULL) {
			g_warning ("no idea what's going on here");
			continue;
		}

		gtk_widget_set_hexpand (button, FALSE);
		gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);

		label_text = NULL;
		g_menu_model_get_item_attribute (menu, i, "label", "s", &label_text);
		label = gtk_label_new (g_dgettext (NULL, label_text));
		g_object_set (label, "margin-left", 6, "margin-right", 6, NULL);
		gtk_container_add (GTK_CONTAINER (button), label);

		if (g_menu_model_get_item_attribute (menu, i, "accel", "s", &accel)) {
			g_object_set_data_full (G_OBJECT (button), "rb-accel", accel, (GDestroyNotify) g_free);
		}

		gtk_widget_show_all (button);
		gtk_size_group_add_widget (bar->priv->size_group, button);
		gtk_grid_attach (GTK_GRID (bar), button, bar->priv->position++, 0, 1, 1);

		g_free (label_text);
	}

	return need_separator;
}
Example #17
0
GtkWidget *
reader_window_new(GtkApplication *application,
                  CainteoirSettings *settings,
                  CainteoirSpeechSynthesizers *synthesizers,
                  const gchar *filename)
{
	ReaderWindow *reader = READER_WINDOW(g_object_new(READER_TYPE_WINDOW,
		"application", application,
		nullptr));
	ReaderWindowPrivate *priv = READER_WINDOW_PRIVATE(reader);
	priv->self = GTK_WIDGET(reader);
	priv->settings = CAINTEOIR_SETTINGS(g_object_ref(G_OBJECT(settings)));
	priv->tts = CAINTEOIR_SPEECH_SYNTHESIZERS(g_object_ref(G_OBJECT(synthesizers)));
	priv->application = READER_APPLICATION(application);

	gtk_window_set_default_size(GTK_WINDOW(reader), INDEX_PANE_WIDTH + DOCUMENT_PANE_WIDTH + 5, 300);
	gtk_window_set_title(GTK_WINDOW(reader), i18n("Cainteoir Text-to-Speech"));

	GtkWidget *layout = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
	gtk_container_add(GTK_CONTAINER(reader), layout);

	priv->header = gtk_header_bar_new();
	gtk_header_bar_set_title(GTK_HEADER_BAR(priv->header), i18n("Cainteoir Text-to-Speech"));
	if (cainteoir_settings_get_boolean(priv->settings, "window", "have-csd", TRUE))
	{
		// Use client-side decorations (e.g. on Gnome Shell and Unity) ...
		gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(priv->header), TRUE);
		gtk_window_set_titlebar(GTK_WINDOW(reader), priv->header);
	}
	else
	{
		// Don't use client-side decorations (e.g. on KDE) ...
		gtk_box_pack_start(GTK_BOX(layout), priv->header, FALSE, FALSE, 0);
	}

	priv->actions = create_action_group(priv);
	gtk_widget_insert_action_group(GTK_WIDGET(reader), "cainteoir", G_ACTION_GROUP(priv->actions));

	priv->view = reader_document_view_new(priv->settings);
	gtk_box_pack_start(GTK_BOX(layout), priv->view, TRUE, TRUE, 0);
	reader_document_view_set_index_pane_close_action_name(READER_DOCUMENT_VIEW(priv->view), "cainteoir.side-pane");

	GtkWidget *bottombar = gtk_toolbar_new();
	gtk_widget_set_size_request(bottombar, -1, 45);
	gtk_style_context_add_class(gtk_widget_get_style_context(bottombar), "bottombar");
	gtk_box_pack_start(GTK_BOX(layout), bottombar, FALSE, FALSE, 0);

	GtkToolItem *record = gtk_tool_button_new(gtk_image_new_from_icon_name("media-record-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR), nullptr);
	gtk_toolbar_insert(GTK_TOOLBAR(bottombar), record, -1);
	gtk_actionable_set_action_name(GTK_ACTIONABLE(record), "cainteoir.record");

	priv->play_stop = gtk_tool_button_new(nullptr, nullptr);
	gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(priv->play_stop), "media-playback-start-symbolic");
	gtk_toolbar_insert(GTK_TOOLBAR(bottombar), priv->play_stop, -1);
	gtk_actionable_set_action_name(GTK_ACTIONABLE(priv->play_stop), "cainteoir.play-stop");

	GtkToolItem *open = gtk_tool_button_new(gtk_image_new_from_icon_name("document-open-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR), nullptr);
	gtk_toolbar_insert(GTK_TOOLBAR(bottombar), open, -1);
	gtk_actionable_set_action_name(GTK_ACTIONABLE(open), "cainteoir.open");

	GtkToolItem *timebar = gtk_tool_item_new();
	gtk_tool_item_set_expand(GTK_TOOL_ITEM(timebar), TRUE);
	gtk_toolbar_insert(GTK_TOOLBAR(bottombar), timebar, -1);

	priv->timebar = cainteoir_timebar_new();
	gtk_style_context_add_class(gtk_widget_get_style_context(priv->timebar), "timebar");
	gtk_container_add(GTK_CONTAINER(timebar), priv->timebar);

	priv->previous = gtk_button_new();
	gtk_button_set_image(GTK_BUTTON(priv->previous), gtk_image_new_from_icon_name("go-previous-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR));
	gtk_header_bar_pack_start(GTK_HEADER_BAR(priv->header), priv->previous);
	gtk_actionable_set_action_name(GTK_ACTIONABLE(priv->previous), "cainteoir.view-previous");

	GtkWidget *menu_button = gtk_menu_button_new();
	gtk_button_set_image(GTK_BUTTON(menu_button), gtk_image_new_from_icon_name(HAMBURGER_MENU_ICON, GTK_ICON_SIZE_SMALL_TOOLBAR));
	gtk_menu_button_set_menu_model(GTK_MENU_BUTTON(menu_button), create_main_menu());
	gtk_header_bar_pack_end(GTK_HEADER_BAR(priv->header), menu_button);

	g_signal_connect(reader, "window-state-event", G_CALLBACK(on_window_state_changed), priv->settings);
	g_signal_connect(reader, "delete_event", G_CALLBACK(on_window_delete), priv);
	g_signal_connect(reader, "show", G_CALLBACK(on_window_show), priv);
	g_signal_connect(priv->tts, "speaking", G_CALLBACK(on_speaking), priv);
	g_signal_connect(priv->tts, "text-range-changed", G_CALLBACK(on_text_range_changed), priv);

	gtk_window_resize(GTK_WINDOW(reader),
	                  cainteoir_settings_get_integer(priv->settings, "window", "width",  700),
	                  cainteoir_settings_get_integer(priv->settings, "window", "height", 445));
	gtk_window_move(GTK_WINDOW(reader),
	                cainteoir_settings_get_integer(priv->settings, "window", "left", 0),
	                cainteoir_settings_get_integer(priv->settings, "window", "top",  0));
	if (cainteoir_settings_get_boolean(priv->settings, "window", "maximized", FALSE))
		gtk_window_maximize(GTK_WINDOW(reader));

	if (filename)
		reader_window_load_document(reader, filename);
	else
	{
		gchar *prev_filename = cainteoir_settings_get_string(priv->settings, "document", "filename", nullptr);
		if (prev_filename)
		{
			reader_window_load_document(reader, prev_filename);
			g_free(prev_filename);
		}
	}

	gchar *anchor = cainteoir_settings_get_string(priv->settings, "highlight", "anchor", "none");
	if (anchor)
	{
		if (!strcmp(anchor, "top"))
			reader_window_set_highlight_anchor(reader, GTK_ALIGN_START);
		else if (!strcmp(anchor, "middle"))
			reader_window_set_highlight_anchor(reader, GTK_ALIGN_CENTER);
		else if (!strcmp(anchor, "bottom"))
			reader_window_set_highlight_anchor(reader, GTK_ALIGN_END);
		g_free(anchor);
	}

	return GTK_WIDGET(reader);
}
/*********************************************************************** Menu */
void
bmd_construct_menu (GtkApplication *app, gpointer data)
{
	GtkWidget *headerbar;
	// the application menu displayed in the GNOME panel
	GMenu *appmenu;
	GMenu *editmenu;

	GtkWidget *openbutton;
	GtkWidget *savebutton;

	// the menu displayed as a popover below the gears button
	GMenu *gearmenu;
	GtkWidget *gearmenubutton;
	GtkWidget *gearicon;

	bmd_widgets *a = (bmd_widgets *) data;

	// define keyboard accelerators
	const gchar *open_accels[2] = { "<Ctrl>O", NULL };
	const gchar *save_accels[2] = { "<Ctrl>S", NULL };
	const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };
	const gchar *add_accels[2] = { "<Ctrl>A", NULL };
	const gchar *del_accels[2] = { "<Ctrl>D", NULL };
	const gchar *find_accels[2] = { "<Ctrl>F", NULL };
	const gchar *help_accels[2] = { "F1", NULL };

	// create and fill in the application menu in the GNOME panel
	appmenu = g_menu_new();
	g_menu_append (appmenu, "About", "app.about");
	g_menu_append (appmenu, "Help", "app.help");
	g_menu_append (appmenu, "_Quit", "app.quit");
	gtk_application_set_app_menu (GTK_APPLICATION (app), G_MENU_MODEL (appmenu));
	g_object_unref (appmenu);

	// create a headerbar
	headerbar = gtk_header_bar_new ();
	gtk_widget_show (headerbar);
	gtk_header_bar_set_title (GTK_HEADER_BAR (headerbar), "Book Management");
	gtk_header_bar_set_subtitle (GTK_HEADER_BAR (headerbar), "Simple Demo Application");
	gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (headerbar), TRUE);
	gtk_window_set_titlebar (GTK_WINDOW (a->window), headerbar);

	// create an OPEN button, add it to the headerbar and connect the callbacks
	openbutton = gtk_button_new_with_label ("Open");
	gtk_header_bar_pack_start (GTK_HEADER_BAR (headerbar), openbutton);
	gtk_actionable_set_action_name (GTK_ACTIONABLE (openbutton), "app.open");

	// create the gear menu button
	gearmenubutton = gtk_menu_button_new();
	gearicon = gtk_image_new_from_icon_name ("emblem-system-symbolic",
						 GTK_ICON_SIZE_SMALL_TOOLBAR);
	gtk_button_set_image (GTK_BUTTON (gearmenubutton), gearicon);
	gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), gearmenubutton);
	// create a menu for the gear button
	gearmenu = g_menu_new();
	g_menu_append (gearmenu, "Save As ...", "app.saveAs");
	editmenu = g_menu_new();
	g_menu_append (editmenu, "_Find", "app.find");
	g_menu_append (editmenu, "_Add", "app.add");
	g_menu_append (editmenu, "_Delete", "app.delete");
	g_menu_append_section (gearmenu, NULL, G_MENU_MODEL (editmenu));
	gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (gearmenubutton),
					G_MENU_MODEL (gearmenu));
	g_object_unref (editmenu);
	g_object_unref (gearmenu);

	// create an SAVE button, add it to the headerbar and connect the callbacks
	savebutton = gtk_button_new_with_label ("Save");
	gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), savebutton);
	gtk_actionable_set_action_name (GTK_ACTIONABLE (savebutton), "app.save");

	// connect keyboard accelerators
	gtk_application_set_accels_for_action (GTK_APPLICATION (app),
					       "app.open", open_accels);
	gtk_application_set_accels_for_action (GTK_APPLICATION (app),
					       "app.save", save_accels);
	gtk_application_set_accels_for_action (GTK_APPLICATION (app),
					       "app.quit", quit_accels);
	gtk_application_set_accels_for_action (GTK_APPLICATION (app),
					       "app.add", add_accels);
	gtk_application_set_accels_for_action (GTK_APPLICATION (app),
					       "app.delete", del_accels);
	gtk_application_set_accels_for_action (GTK_APPLICATION (app),
					       "app.find", find_accels);
	gtk_application_set_accels_for_action (GTK_APPLICATION (app),
					       "app.help", help_accels);
}
static void
gth_contact_sheet_theme_dialog_init (GthContactSheetThemeDialog *self)
{
	GtkWidget *content;

	self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_CONTACT_SHEET_THEME_DIALOG, GthContactSheetThemeDialogPrivate);
	self->priv->builder = _gtk_builder_new_from_file ("contact-sheet-theme-properties.ui", "contact_sheet");
	self->priv->theme = NULL;
	self->priv->all_themes = NULL;

	gtk_window_set_title (GTK_WINDOW (self), _("Theme Properties"));
	gtk_window_set_resizable (GTK_WINDOW (self), TRUE);
	gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), 5);
	gtk_container_set_border_width (GTK_CONTAINER (self), 5);

	content = _gtk_builder_get_widget (self->priv->builder, "theme_properties");
	gtk_container_set_border_width (GTK_CONTAINER (content), 5);
	gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), content, TRUE, TRUE, 0);

	/* "Copy from" button */

	self->priv->copy_from_button = gtk_menu_button_new ();
	gtk_container_add (GTK_CONTAINER (self->priv->copy_from_button), gtk_label_new_with_mnemonic (_("Copy _From")));
	gtk_widget_show_all (self->priv->copy_from_button);

	self->priv->copy_from_menu = gtk_menu_new ();
	gtk_menu_button_set_popup (GTK_MENU_BUTTON (self->priv->copy_from_button), self->priv->copy_from_menu);

	gtk_dialog_add_action_widget (GTK_DIALOG (self), self->priv->copy_from_button, 100);

	/* other buttons */

	gtk_dialog_add_button (GTK_DIALOG (self),
			       _GTK_LABEL_CANCEL,
			       GTK_RESPONSE_CANCEL);
	gtk_dialog_add_button (GTK_DIALOG (self),
			       _GTK_LABEL_SAVE,
			       GTK_RESPONSE_OK);
	gtk_dialog_set_default_response (GTK_DIALOG (self), GTK_RESPONSE_OK);

	g_signal_connect (GET_WIDGET ("preview_area"),
			  "draw",
			  G_CALLBACK (preview_area_draw_cb),
			  self);
	g_signal_connect_swapped (GET_WIDGET ("solid_color_radiobutton"),
			  	  "toggled",
			  	  G_CALLBACK (update_preview),
			  	  self);
	g_signal_connect_swapped (GET_WIDGET ("gradient_radiobutton"),
			  	  "toggled",
			  	  G_CALLBACK (update_preview),
			  	  self);
	g_signal_connect_swapped (GET_WIDGET ("h_gradient_checkbutton"),
			  	  "toggled",
			  	  G_CALLBACK (update_preview),
			  	  self);
	g_signal_connect_swapped (GET_WIDGET ("v_gradient_checkbutton"),
			  	  "toggled",
			  	  G_CALLBACK (update_preview),
			  	  self);
	g_signal_connect_swapped (GET_WIDGET ("solid_color_colorpicker"),
			  	  "color-set",
			  	  G_CALLBACK (update_preview),
			  	  self);
	g_signal_connect_swapped (GET_WIDGET ("h_gradient_1_colorpicker"),
			  	  "color-set",
			  	  G_CALLBACK (update_preview),
			  	  self);
	g_signal_connect_swapped (GET_WIDGET ("h_gradient_2_colorpicker"),
			  	  "color-set",
			  	  G_CALLBACK (update_preview),
			  	  self);
	g_signal_connect_swapped (GET_WIDGET ("v_gradient_1_colorpicker"),
			  	  "color-set",
			  	  G_CALLBACK (update_preview),
			  	  self);
	g_signal_connect_swapped (GET_WIDGET ("v_gradient_2_colorpicker"),
			  	  "color-set",
			  	  G_CALLBACK (update_preview),
			  	  self);
	g_signal_connect_swapped (GET_WIDGET ("frame_colorpicker"),
			  	  "color-set",
			  	  G_CALLBACK (update_preview),
			  	  self);
	g_signal_connect_swapped (GET_WIDGET ("header_colorpicker"),
			  	  "color-set",
			  	  G_CALLBACK (update_preview),
			  	  self);
	g_signal_connect_swapped (GET_WIDGET ("footer_colorpicker"),
			  	  "color-set",
			  	  G_CALLBACK (update_preview),
			  	  self);
	g_signal_connect_swapped (GET_WIDGET ("caption_colorpicker"),
			  	  "color-set",
			  	  G_CALLBACK (update_preview),
			  	  self);
	g_signal_connect_swapped (GET_WIDGET ("frame_style_combobox"),
			  	  "changed",
			  	  G_CALLBACK (update_preview),
			  	  self);
	g_signal_connect_swapped (GET_WIDGET ("header_fontpicker"),
			  	  "font-set",
			  	  G_CALLBACK (update_preview),
			  	  self);
	g_signal_connect_swapped (GET_WIDGET ("footer_fontpicker"),
			  	  "font-set",
			  	  G_CALLBACK (update_preview),
			  	  self);
	g_signal_connect_swapped (GET_WIDGET ("caption_fontpicker"),
			  	  "font-set",
			  	  G_CALLBACK (update_preview),
			  	  self);
	g_signal_connect (GET_WIDGET ("h_gradient_swap_button"),
			  "clicked",
			  G_CALLBACK (h_gradient_swap_button_clicked_cb),
			  self);
	g_signal_connect (GET_WIDGET ("v_gradient_swap_button"),
			  "clicked",
			  G_CALLBACK (v_gradient_swap_button_clicked_cb),
			  self);
}
Example #20
0
void main_window_enable_csd(MainWindow *wnd)
{
	GIcon *open_icon;
	GIcon *fullscreen_icon;
	GIcon *menu_icon;

	open_icon = g_themed_icon_new_with_default_fallbacks
				("list-add-symbolic");

	fullscreen_icon = g_themed_icon_new_with_default_fallbacks
				("view-fullscreen-symbolic");

	menu_icon = g_themed_icon_new_with_default_fallbacks
				("view-list-symbolic");

	wnd->playlist_width = PLAYLIST_DEFAULT_WIDTH+PLAYLIST_CSD_OFFSET;
	wnd->open_hdr_btn = gtk_menu_button_new();
	wnd->fullscreen_hdr_btn = gtk_button_new();
	wnd->menu_hdr_btn = gtk_menu_button_new();

	gtk_widget_set_can_focus(wnd->open_hdr_btn, FALSE);
	gtk_widget_set_can_focus(wnd->fullscreen_hdr_btn, FALSE);
	gtk_widget_set_can_focus(wnd->menu_hdr_btn, FALSE);

	gtk_button_set_image
		(	GTK_BUTTON(wnd->fullscreen_hdr_btn),
			gtk_image_new_from_gicon
				(fullscreen_icon, GTK_ICON_SIZE_MENU ));

	gtk_button_set_image
		(	GTK_BUTTON(wnd->open_hdr_btn),
			gtk_image_new_from_gicon
				(open_icon, GTK_ICON_SIZE_MENU ));

	gtk_button_set_image
		(	GTK_BUTTON(wnd->menu_hdr_btn),
			gtk_image_new_from_gicon
				(menu_icon, GTK_ICON_SIZE_MENU ));

	gtk_menu_button_set_menu_model
		(	GTK_MENU_BUTTON(wnd->open_hdr_btn),
			G_MENU_MODEL(open_btn_build_menu()) );

	gtk_menu_button_set_menu_model
		(	GTK_MENU_BUTTON(wnd->menu_hdr_btn),
			G_MENU_MODEL(menu_btn_build_menu()) );

	gtk_header_bar_pack_start
		(GTK_HEADER_BAR(wnd->header_bar), wnd->open_hdr_btn);

	gtk_header_bar_pack_end
		(GTK_HEADER_BAR(wnd->header_bar), wnd->menu_hdr_btn);

	gtk_header_bar_pack_end
		(GTK_HEADER_BAR(wnd->header_bar), wnd->fullscreen_hdr_btn);

	gtk_actionable_set_action_name
		(GTK_ACTIONABLE(wnd->fullscreen_hdr_btn), "app.fullscreen");

	gtk_paned_set_position(	GTK_PANED(wnd->vid_area_paned),
				MAIN_WINDOW_DEFAULT_WIDTH
				-PLAYLIST_DEFAULT_WIDTH
				-PLAYLIST_CSD_OFFSET );

	gtk_window_set_titlebar(GTK_WINDOW(wnd), wnd->header_bar);
	gtk_window_set_title(GTK_WINDOW(wnd), g_get_application_name());
}