gboolean
reader_window_load_document(ReaderWindow *reader,
                            const gchar *filename)
{
	ReaderWindowPrivate *priv = READER_WINDOW_PRIVATE(reader);
	if (reader_document_view_load_document(READER_DOCUMENT_VIEW(priv->view), filename))
	{
		CainteoirDocument *doc = reader_document_view_get_document(READER_DOCUMENT_VIEW(priv->view));
		CainteoirMetadata *metadata = cainteoir_document_get_metadata(doc);
		gchar *title = cainteoir_metadata_get_string(metadata, CAINTEOIR_METADATA_TITLE);

		reader_application_set_active_document(priv->application, doc);

		const gchar *doc_title = title ? title : i18n("Cainteoir Text-to-Speech");
		gtk_header_bar_set_title(GTK_HEADER_BAR(priv->header), doc_title);

		if (title) g_free(title);
		g_object_unref(G_OBJECT(metadata));
		g_object_unref(G_OBJECT(doc));

		reset_timebar(priv);
		return TRUE;
	}
	return FALSE;
}
Beispiel #2
0
static void
selection_cb (GtkTreeSelection *selection,
              GtkTreeModel     *model)
{
  GtkTreeIter iter;
  char *name;
  char *filename;
  char *title;

  if (! gtk_tree_selection_get_selected (selection, NULL, &iter))
    return;

  gtk_tree_model_get (model, &iter,
                      NAME_COLUMN, &name,
                      TITLE_COLUMN, &title,
                      FILENAME_COLUMN, &filename,
                      -1);

  if (filename)
    load_file (name, filename);

  gtk_header_bar_set_title (GTK_HEADER_BAR (headerbar), title);

  g_free (name);
  g_free (title);
  g_free (filename);
}
GtkWidget *
create_header_bar (GtkWidget *dialog, const gchar *title)
{
    static GtkWidget *header_bar = NULL;
    header_bar = gtk_header_bar_new();
    gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (header_bar), FALSE);
    gtk_header_bar_set_title (GTK_HEADER_BAR (header_bar), title);
    gtk_header_bar_set_has_subtitle (GTK_HEADER_BAR (header_bar), FALSE);
    gtk_window_set_titlebar (GTK_WINDOW (dialog), header_bar);

    return header_bar;
}
Beispiel #4
0
static void
change_title (GtkButton *button, gpointer data)
{
  GtkWidget *headerbar = GTK_WIDGET (data);

  if (gtk_header_bar_get_custom_title (GTK_HEADER_BAR (headerbar)) == NULL)
    {
      gtk_header_bar_set_custom_title (GTK_HEADER_BAR (headerbar), gtk_check_button_new_with_label ("Middle"));
    }
  else
    {
      gtk_header_bar_set_custom_title (GTK_HEADER_BAR (headerbar), NULL);
      gtk_header_bar_set_title (GTK_HEADER_BAR (headerbar), "Middle");
    }
}
Beispiel #5
0
static void
change_header (GtkButton *button, gpointer data)
{
  GtkWidget *window = GTK_WIDGET (data);
  GtkWidget *label;
  GtkWidget *widget;
  GtkWidget *image;
  GtkWidget *box;

  if (button && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
    {
      header = gtk_event_box_new ();
      gtk_style_context_add_class (gtk_widget_get_style_context (header), "titlebar");
      gtk_style_context_add_class (gtk_widget_get_style_context (header), "header-bar");
      box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
      g_object_set (box, "margin", 10, NULL);
      gtk_container_add (GTK_CONTAINER (header), box);
      label = gtk_label_new ("Label");
      gtk_box_pack_start (GTK_BOX (box), label, FALSE, TRUE);
      widget = gtk_level_bar_new ();
      gtk_level_bar_set_value (GTK_LEVEL_BAR (widget), 0.4);
      gtk_box_pack_start (GTK_BOX (box), widget, TRUE, TRUE);
      gtk_widget_show_all (header);
    }
  else
    {
      header = gtk_header_bar_new ();
      gtk_style_context_add_class (gtk_widget_get_style_context (header), "titlebar");
      gtk_header_bar_set_title (GTK_HEADER_BAR (header), "Example header");

      widget = gtk_button_new_with_label ("_Close");
      gtk_button_set_use_underline (GTK_BUTTON (widget), TRUE);
      gtk_style_context_add_class (gtk_widget_get_style_context (widget), "suggested-action");
      g_signal_connect (widget, "clicked", G_CALLBACK (gtk_main_quit), NULL);

      gtk_header_bar_pack_end (GTK_HEADER_BAR (header), widget);

      widget= gtk_button_new ();
      image = gtk_image_new_from_icon_name ("bookmark-new-symbolic", GTK_ICON_SIZE_BUTTON);
      g_signal_connect (widget, "clicked", G_CALLBACK (on_bookmark_clicked), window);
      gtk_container_add (GTK_CONTAINER (widget), image);

      gtk_header_bar_pack_start (GTK_HEADER_BAR (header), widget);
      gtk_widget_show_all (header);
    }

  gtk_window_set_titlebar (GTK_WINDOW (window), header);
}
Beispiel #6
0
static void
g_paste_ui_header_init (GPasteUiHeader *self)
{
    GPasteUiHeaderPrivate *priv = g_paste_ui_header_get_instance_private (self);
    GtkHeaderBar *header_bar = GTK_HEADER_BAR (self);
    GtkWidget *settings = g_paste_ui_settings_new ();
    GtkWidget *search = g_paste_ui_search_new ();

    priv->settings = GTK_BUTTON (settings);
    priv->search = GTK_BUTTON (search);

    gtk_header_bar_set_title(header_bar, PACKAGE_STRING);
    gtk_header_bar_set_show_close_button (header_bar, TRUE);
    gtk_header_bar_pack_end (header_bar, settings);
    gtk_header_bar_pack_end (header_bar, search);
}
void WebInspectorProxy::updateInspectorWindowTitle() const
{
    ASSERT(m_inspectorWindow);
    if (m_inspectedURLString.isEmpty()) {
        gtk_window_set_title(GTK_WINDOW(m_inspectorWindow), _("Web Inspector"));
        return;
    }

#if GTK_CHECK_VERSION(3, 10, 0)
    gtk_header_bar_set_title(GTK_HEADER_BAR(m_headerBar), _("Web Inspector"));
    gtk_header_bar_set_subtitle(GTK_HEADER_BAR(m_headerBar), m_inspectedURLString.utf8().data());
#else
    GUniquePtr<gchar> title(g_strdup_printf("%s - %s", _("Web Inspector"), m_inspectedURLString.utf8().data()));
    gtk_window_set_title(GTK_WINDOW(m_inspectorWindow), title.get());
#endif
}
Beispiel #8
0
static void
gtimer_window_construct_ui (GTimerWindow *window)
{
	GtkWidget *headerbar;
	GtkWidget *gtimer_face;

	g_return_if_fail (GTIMER_IS_WINDOW (window));

	headerbar = gtk_header_bar_new ();
	gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (headerbar), TRUE);
	gtk_header_bar_set_title (GTK_HEADER_BAR (headerbar), g_get_application_name ());
	gtk_window_set_titlebar (GTK_WINDOW (window), headerbar);

	gtimer_face = gtimer_face_new ();
	gtk_container_add (GTK_CONTAINER (window), gtimer_face);

	gtk_widget_show_all (GTK_WIDGET (window));
}
Beispiel #9
0
static void
conversation_page_update_title_and_status (ConversationPage* self)
{
  g_free (self->priv->title);
  guint unread_count = self->priv->conversation->get_unread_messages_count ();
  if (unread_count > 0) {

    self->priv->title = g_strdup_printf ("[%d] %s",
					 unread_count,
					 self->priv->conversation->get_title ().c_str ());
  } else {

    self->priv->title = g_strdup_printf ("%s",
					 self->priv->conversation->get_title ().c_str ());
  }
  gtk_header_bar_set_title (GTK_HEADER_BAR (self->priv->header), self->priv->title);
  gtk_header_bar_set_subtitle (GTK_HEADER_BAR (self->priv->header),
			       self->priv->conversation->get_status ().c_str ());
}
Beispiel #10
0
GtkWidget *
do_paint (GtkWidget *toplevel)
{
  static GtkWidget *window = NULL;

  if (!window)
    {
      GtkWidget *draw_area, *headerbar, *colorbutton;

      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

      draw_area = drawing_area_new ();
      gtk_container_add (GTK_CONTAINER (window), draw_area);

      headerbar = gtk_header_bar_new ();
      gtk_header_bar_set_title (GTK_HEADER_BAR (headerbar), "Paint");
      gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (headerbar), TRUE);

      colorbutton = gtk_color_button_new ();
      g_signal_connect (colorbutton, "color-set",
                        G_CALLBACK (color_button_color_set), draw_area);
      g_signal_connect (draw_area, "color-set",
                        G_CALLBACK (drawing_area_color_set), colorbutton);
      gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (colorbutton),
                                  &(GdkRGBA) { 0, 0, 0, 1 });

      gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), colorbutton);
      gtk_window_set_titlebar (GTK_WINDOW (window), headerbar);

      g_signal_connect (window, "destroy",
                        G_CALLBACK (gtk_widget_destroyed), &window);

    }

  if (!gtk_widget_get_visible (window))
    gtk_widget_show (window);
  else
    gtk_widget_destroy (window);

  return window;
}
Beispiel #11
0
int
main (int argc, char *argv[])
{
  GtkWidget *window;
  GtkWidget *box;
  GtkWidget *header;
  GtkWidget *footer;
  GtkWidget *button;
  GtkWidget *image;
  GtkWidget *content;
  GtkCssProvider *provider;

  gtk_init (NULL, NULL);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  header = gtk_header_bar_new ();
  gtk_style_context_add_class (gtk_widget_get_style_context (header), "titlebar");
  provider = gtk_css_provider_new ();
  gtk_css_provider_load_from_data (provider, css, -1, NULL);
  gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (window),
                                             GTK_STYLE_PROVIDER (provider),
                                             GTK_STYLE_PROVIDER_PRIORITY_USER);

  gtk_header_bar_set_title (GTK_HEADER_BAR (header), "Example header");

  button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
  gtk_style_context_add_class (gtk_widget_get_style_context (button), "suggested-action");
  g_signal_connect (button, "clicked", G_CALLBACK (gtk_main_quit), NULL);

  gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);

  button = gtk_button_new ();
  image = gtk_image_new_from_icon_name ("bookmark-new-symbolic", GTK_ICON_SIZE_BUTTON);
  gtk_container_add (GTK_CONTAINER (button), image);

  gtk_header_bar_pack_start (GTK_HEADER_BAR (header), button);

  gtk_window_set_titlebar (GTK_WINDOW (window), header);

  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  gtk_container_add (GTK_CONTAINER (window), box);

  footer = gtk_header_bar_new ();
  button = gtk_button_new_with_label ("Start");
  g_signal_connect (button, "clicked", G_CALLBACK (change_title), footer);
  gtk_header_bar_pack_start (GTK_HEADER_BAR (footer), button);
  gtk_header_bar_set_custom_title (GTK_HEADER_BAR (footer), gtk_check_button_new_with_label ("Middle"));
  button = gtk_button_new_with_label ("End 1");
  g_signal_connect (button, "clicked", G_CALLBACK (change_subtitle), header);
  gtk_header_bar_pack_end (GTK_HEADER_BAR (footer), button);
  gtk_header_bar_pack_end (GTK_HEADER_BAR (footer), gtk_button_new_with_label ("End 2"));
  gtk_box_pack_end (GTK_BOX (box), footer, FALSE, FALSE, 0);

  content = gtk_image_new_from_icon_name ("start-here-symbolic", GTK_ICON_SIZE_DIALOG);
  gtk_image_set_pixel_size (GTK_IMAGE (content), 512);

  gtk_box_pack_start (GTK_BOX (box), content, FALSE, TRUE, 0);

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}
static void
set_dialog_properties (GtkAppChooserDialog *self)
{
  gchar *name;
  gchar *extension;
  gchar *description;
  gchar *string;
  gboolean unknown;
  gchar *title;
  gchar *subtitle;
  gboolean use_header;
  GtkWidget *header;

  name = NULL;
  extension = NULL;
  description = NULL;
  unknown = TRUE;

  if (self->priv->gfile != NULL)
    {
      name = g_file_get_basename (self->priv->gfile);
      extension = get_extension (name);
    }

  if (self->priv->content_type)
    {
      description = g_content_type_get_description (self->priv->content_type);
      unknown = g_content_type_is_unknown (self->priv->content_type);
    }

  if (name != NULL)
    {
      title = g_strdup (_("Select Application"));
      /* Translators: %s is a filename */
      subtitle = g_strdup_printf (_("Opening “%s”."), name);
      string = g_strdup_printf (_("No applications found for “%s”"), name);
    }
  else
    {
      title = g_strdup (_("Select Application"));
      /* Translators: %s is a file type description */
      subtitle = g_strdup_printf (_("Opening “%s” files."), 
                                  unknown ? self->priv->content_type : description);
      string = g_strdup_printf (_("No applications found for “%s” files"),
                                unknown ? self->priv->content_type : description);
    }

  g_object_get (self, "use-header-bar", &use_header, NULL); 
  if (use_header)
    {
      header = gtk_dialog_get_header_bar (GTK_DIALOG (self));
      gtk_header_bar_set_title (GTK_HEADER_BAR (header), title);
      gtk_header_bar_set_subtitle (GTK_HEADER_BAR (header), subtitle);
    }
  else
    {
      gtk_window_set_title (GTK_WINDOW (self), _("Select Application"));
    }

  if (self->priv->heading != NULL)
    {
      gtk_label_set_markup (GTK_LABEL (self->priv->label), self->priv->heading);
      gtk_widget_show (self->priv->label);
    }
  else
    {
      gtk_widget_hide (self->priv->label);
    }

  gtk_app_chooser_widget_set_default_text (GTK_APP_CHOOSER_WIDGET (self->priv->app_chooser_widget),
                                           string);

  g_free (title);
  g_free (subtitle);
  g_free (name);
  g_free (extension);
  g_free (description);
  g_free (string);
}
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);
}
Beispiel #14
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);
}
Beispiel #15
0
static void
ev_window_title_update (EvWindowTitle *window_title)
{
	GtkWindow *window = GTK_WINDOW (window_title->window);
	GtkHeaderBar *toolbar = GTK_HEADER_BAR (ev_window_get_toolbar (EV_WINDOW (window)));
	char *title = NULL, *p;
	char *subtitle = NULL, *title_header = NULL;

        if (window_title->type == EV_WINDOW_TITLE_RECENT) {
                gtk_header_bar_set_subtitle (toolbar, NULL);
                gtk_window_set_title (window, _("Recent Documents"));
                return;
        }

	if (window_title->doc_title && window_title->uri) {
                title = g_strdup (window_title->doc_title);
                ev_window_title_sanitize_title (window_title, &title);

		subtitle = get_filename_from_uri (window_title->uri);

		title_header = title;
		title = g_strdup_printf ("%s — %s", subtitle, title);

                for (p = title; *p; ++p) {
                        /* an '\n' byte is always ASCII, no need for UTF-8 special casing */
                        if (*p == '\n')
                                *p = ' ';
                }
	} else if (window_title->uri) {
		title = get_filename_from_uri (window_title->uri);
	} else if (!title) {
		title = g_strdup (_("Document Viewer"));
	}

	switch (window_title->type) {
	case EV_WINDOW_TITLE_DOCUMENT:
		gtk_window_set_title (window, title);
		if (title_header && subtitle) {
			gtk_header_bar_set_title (toolbar, title_header);
			gtk_header_bar_set_subtitle (toolbar, subtitle);
		}
		break;
	case EV_WINDOW_TITLE_PASSWORD: {
                gchar *password_title;

		password_title = g_strdup_printf ("%s — %s", title, _("Password Required"));
		gtk_window_set_title (window, password_title);
		g_free (password_title);

                gtk_header_bar_set_title (toolbar, _("Password Required"));
                gtk_header_bar_set_subtitle (toolbar, title);
        }
		break;
        case EV_WINDOW_TITLE_RECENT:
                g_assert_not_reached ();
                break;
	}

	g_free (title);
	g_free (subtitle);
	g_free (title_header);
}
Beispiel #16
0
MidiogreApp *midiogre_app_init(void)
{
    MidiogreApp *app;

    GtkWidget *header;
    GtkWidget *separator;
    GtkWidget *scrolled;
    GtkWidget *label,*frame;
    GtkWidget *button;
    GtkBox *box;

    gint i;
    GError *err;

    /* Allocate app */
    app = calloc(1, sizeof(MidiogreApp));


    /* Setup window */
    app->window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
    gtk_window_set_default_size(GTK_WINDOW(app->window), 600, 400);
    g_signal_connect(app->window, "destroy", G_CALLBACK(gtk_widget_destroyed), NULL);
    g_signal_connect(app->window, "key-release-event", G_CALLBACK(key_event), NULL);
    gtk_window_set_icon(app->window,gdk_pixbuf_new_from_resource("/org/prozum/midiogre/midiogre_logo.png",&err));


    /* Setup header bar */
    header = gtk_header_bar_new();
    gtk_header_bar_set_title (GTK_HEADER_BAR(header), "Midiogre");
    gtk_window_set_titlebar(app->window, header);

    /* Setup close button */
    button = gtk_button_new();
    gtk_container_add (GTK_CONTAINER(button), gtk_image_new_from_resource("/org/prozum/midiogre/icons/window-close-symbolic.symbolic.png"));
    gtk_header_bar_pack_end(GTK_HEADER_BAR(header), button);
    g_signal_connect_swapped(button, "clicked", G_CALLBACK(gtk_main_quit), app->window);


    /* Add seperator */
    separator = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
    gtk_header_bar_pack_end(GTK_HEADER_BAR(header), separator);


    /* Setup folder button */
    button = gtk_button_new();
    gtk_container_add (GTK_CONTAINER(button), gtk_image_new_from_resource("/org/prozum/midiogre/icons/document-open-symbolic.symbolic.png"));
    gtk_header_bar_pack_end(GTK_HEADER_BAR(header), button);
    g_signal_connect_swapped(button, "clicked", G_CALLBACK(folder_chooser), app->window);

    /* Global horizontal box */
    app->win_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
    gtk_container_add(GTK_CONTAINER(app->window), GTK_WIDGET(app->win_box));


    /* Scroll container for sidepanel */
    scrolled = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_box_pack_start(app->win_box, scrolled, FALSE, FALSE, 0);


    /* Sidepanel box */
    app->panel_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
    gtk_container_add(GTK_CONTAINER (scrolled), GTK_WIDGET(app->panel_box));
    gtk_container_set_border_width(GTK_CONTAINER(app->panel_box), 10);


    /* Frame with favorit info */
    frame = gtk_frame_new("Favorite");
    gtk_box_pack_start(app->panel_box, frame, FALSE, FALSE, 0);
    app->fav_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(app->fav_box));


    /* Current favorite */
    app->fav_title_label = GTK_LABEL(gtk_label_new(""));
    gtk_label_set_max_width_chars(app->fav_title_label, 20);
    gtk_label_set_width_chars(app->fav_title_label, 20);
    gtk_box_pack_start(app->fav_box, GTK_WIDGET(app->fav_title_label), FALSE, FALSE, 0);
    app->fav_artist_label = GTK_LABEL(gtk_label_new("No favorite selected!"));
    gtk_label_set_max_width_chars(app->fav_artist_label, 20);
    gtk_label_set_width_chars(app->fav_artist_label, 20);
    gtk_box_pack_start(app->fav_box, GTK_WIDGET(app->fav_artist_label), FALSE, FALSE, 0);
    app->fav_album_label = GTK_LABEL(gtk_label_new(""));
    gtk_label_set_max_width_chars(app->fav_album_label, 20);
    gtk_label_set_width_chars(app->fav_album_label, 20);
    gtk_box_pack_start(app->fav_box, GTK_WIDGET(app->fav_album_label), FALSE, FALSE, 0);


    /* Frame with search criteria widgets */
    frame = gtk_frame_new("Search");
    gtk_box_pack_start(app->panel_box, frame, FALSE, FALSE, 0);

    app->search_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 10));
    gtk_container_set_border_width(GTK_CONTAINER(app->search_box), 10);

    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(app->search_box));


    /* Title entry */
    frame = gtk_frame_new("Title");
    gtk_box_pack_start(app->search_box, frame, FALSE, FALSE, 0);

    box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(box));
    gtk_container_set_border_width(GTK_CONTAINER(box), 10);

    app->title_entry = GTK_ENTRY(gtk_entry_new());
    gtk_box_pack_start(box, GTK_WIDGET(app->title_entry), TRUE, FALSE, 0);


    /* Artist entry */
    frame = gtk_frame_new("Artist");
    gtk_box_pack_start(app->search_box, frame, FALSE, FALSE, 0);
    gtk_container_set_border_width(GTK_CONTAINER(box), 10);

    box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(box));
    gtk_container_set_border_width(GTK_CONTAINER(box), 10);

    app->artist_entry = GTK_ENTRY(gtk_entry_new());
    gtk_box_pack_start(box, GTK_WIDGET(app->artist_entry), TRUE, FALSE, 0);


    /* Album entry */
    frame = gtk_frame_new("Album");
    gtk_box_pack_start(app->search_box, frame, FALSE, FALSE, 0);

    box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(box));
    gtk_container_set_border_width(GTK_CONTAINER(box), 10);

    app->album_entry = GTK_ENTRY(gtk_entry_new());
    gtk_box_pack_start(box, GTK_WIDGET(app->album_entry), TRUE, FALSE, 0);


    /* Instrument class buttons */
    frame = gtk_frame_new("Instrument Classes");
    gtk_box_pack_start(app->search_box, frame, FALSE, FALSE, 0);

    app->instr_grid = GTK_GRID(gtk_grid_new());

#if GTK_MINOR_VERSION >= 12
    gtk_widget_set_margin_start(GTK_WIDGET(app->instr_grid), 10);
    gtk_widget_set_margin_end(GTK_WIDGET(app->instr_grid), 10);
#else
    gtk_widget_set_margin_left(GTK_WIDGET(app->instr_grid), 10);
    gtk_widget_set_margin_right(GTK_WIDGET(app->instr_grid), 10);
#endif
    gtk_widget_set_margin_bottom(GTK_WIDGET(app->instr_grid), 10);
    gtk_widget_set_margin_top(GTK_WIDGET(app->instr_grid), 10);
    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(app->instr_grid));


    for (i = 0; i < INSTR_CLASSES; i++) {

        label = gtk_label_new(instrument_classes[i]);
        gtk_widget_set_halign(GTK_WIDGET(label), GTK_ALIGN_START);
        gtk_grid_attach(app->instr_grid, label, 1, i + 1, 1, 1);

        app->instr_buttons[i] = GTK_CHECK_BUTTON(gtk_check_button_new());
        gtk_widget_set_halign(GTK_WIDGET(app->instr_buttons[i]), GTK_ALIGN_END);
        gtk_grid_attach(app->instr_grid, GTK_WIDGET(app->instr_buttons[i]), 2, i + 1, 1, 1);
    }


    /* Result spinbutton */
    frame = gtk_frame_new("Max result");
    gtk_box_pack_start(app->search_box, frame, FALSE, FALSE, 0);

    box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(box));
    gtk_container_set_border_width(GTK_CONTAINER(box), 10);

    app->result_spinbutton = GTK_SPIN_BUTTON(gtk_spin_button_new_with_range(1, 100, 1));
    gtk_spin_button_set_value(app->result_spinbutton, 25);

    gtk_box_pack_start(box, GTK_WIDGET(app->result_spinbutton), TRUE, TRUE, 0);

    /* Search button */
    app->search_button = GTK_BUTTON(gtk_button_new_with_label("Search"));
    gtk_box_pack_start(app->search_box, GTK_WIDGET(app->search_button), FALSE, FALSE, 0);
    g_signal_connect_swapped(app->search_button, "clicked", G_CALLBACK(search_event), app);


    /* Songboxes notebook (Tabsview) */
    app->song_notebook = GTK_NOTEBOOK(gtk_notebook_new());
    gtk_widget_set_hexpand(GTK_WIDGET(app->song_notebook), TRUE);
    gtk_box_pack_start(app->win_box, GTK_WIDGET(app->song_notebook), TRUE, TRUE, 0);


    /* Add song boxes */
    app->songboxes[SONGBOX_ALPHA] = songbox_new(app->song_notebook, "Alphabetical");
    app->songboxes[SONGBOX_FPRNT] = songbox_new(app->song_notebook, "Fingerprint");
    app->songboxes[SONGBOX_BEST]  = songbox_new(app->song_notebook, "Best Match");
    app->songboxes[SONGBOX_POP]   = songbox_new(app->song_notebook, "Popularity");
    app->songboxes[SONGBOX_NEW]   = songbox_new(app->song_notebook, "Newest");


    /* Show all widgets */
    gtk_widget_show_all(GTK_WIDGET(app->window));


    /* Allocate song queue */
    app->songs[SONGBOX_ALPHA]   = g_queue_new();
    app->songs[SONGBOX_FPRNT]   = g_queue_new();
    app->songs[SONGBOX_BEST]    = g_queue_new();
    app->songs[SONGBOX_POP]     = g_queue_new();
    app->songs[SONGBOX_NEW]     = g_queue_new();


    return app;
}
/*********************************************************************** 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);
}