Esempio n. 1
0
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;
}
Esempio n. 2
0
static void
glade_gtk_header_bar_set_size (GObject * object,
                               const GValue * value)
{
  GList *l, *next, *children;
  GtkWidget *child;
  guint new_size, old_size, i;

  g_return_if_fail (GTK_IS_HEADER_BAR (object));

  d(g_message ("Setting size to %d", g_value_get_int (value)));

  if (glade_util_object_is_loading (object))
    return;

  children = gtk_container_get_children (GTK_CONTAINER (object));
  l = children;
  while (l)
    {
      next = l->next;
      if (l->data == gtk_header_bar_get_custom_title (GTK_HEADER_BAR (object)) ||
          (!glade_widget_get_from_gobject (l->data) && !GLADE_IS_PLACEHOLDER (l->data)))
        children = g_list_delete_link (children, l);
      l = next;
    }
 
  old_size = g_list_length (children);
  new_size = g_value_get_int (value);

  if (old_size == new_size)
    {
      g_list_free (children);
      return;
    }

  for (i = old_size; i < new_size; i++)
    {
      GtkWidget *placeholder = glade_placeholder_new ();
      gtk_header_bar_pack_start (GTK_HEADER_BAR (object), placeholder);
    }
  for (l = g_list_last (children); l && old_size > new_size; l = l->prev)
    {
      child = l->data;
      if (glade_widget_get_from_gobject (child) || !GLADE_IS_PLACEHOLDER (child))
        continue;

      gtk_container_remove (GTK_CONTAINER (object), child);
      old_size--;
    }

  g_list_free (children);
}
Esempio n. 3
0
static void
setup_header_bar (GtkWidget   *window,
                  VteTerminal *vtterm,
                  gboolean     show_maximized_title)
{
    /*
     * Using the default GtkHeaderBar title/subtitle widget makes the bar
     * too thick to look nice for a terminal, so set a custom widget.
     */
    GtkWidget *hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
    const gchar *title = gtk_window_get_title (GTK_WINDOW (window));
    GtkWidget *label = gtk_label_new (title ? title : "dwt");
    g_object_bind_property (G_OBJECT (vtterm), "window-title",
                            G_OBJECT (label), "label",
                            G_BINDING_DEFAULT);

    GtkWidget *header = gtk_header_bar_new ();
    gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (header), TRUE);
    gtk_header_bar_set_has_subtitle (GTK_HEADER_BAR (header), FALSE);
    gtk_header_bar_set_custom_title (GTK_HEADER_BAR (header), label);

    GtkWidget *button = gtk_button_new_from_icon_name ("tab-new-symbolic",
                                                       GTK_ICON_SIZE_BUTTON);
    gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
    gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "app.new-terminal");
    gtk_header_bar_pack_start (GTK_HEADER_BAR (header), button);

    GtkWidget *revealer = gtk_revealer_new ();
    gtk_container_add (GTK_CONTAINER (revealer),
                       gtk_image_new_from_icon_name ("software-update-urgent-symbolic",
                                                     GTK_ICON_SIZE_BUTTON));
    gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), 500);
    gtk_revealer_set_transition_type (GTK_REVEALER (revealer),
                                      GTK_REVEALER_TRANSITION_TYPE_CROSSFADE);
    gtk_header_bar_pack_end (GTK_HEADER_BAR (header), revealer);

    g_signal_connect (G_OBJECT (vtterm), "bell",
                      G_CALLBACK (header_bar_term_beeped), revealer);
    g_object_bind_property (G_OBJECT (window), "urgency-hint",
                            G_OBJECT (revealer), "reveal-child",
                            G_BINDING_DEFAULT);

    gtk_window_set_titlebar (GTK_WINDOW (window), header);

    /* Hide the header bar when the window is maximized. */
    if (!show_maximized_title) {
        g_object_bind_property (G_OBJECT (window), "is-maximized",
                                G_OBJECT (header), "visible",
                                G_BINDING_INVERT_BOOLEAN);
    }
}
Esempio n. 4
0
static void
gs_editor_refresh_file (GsEditor *self, GFile *file)
{
	GtkWidget *widget;

	/* set subtitle */
	widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "headerbar_main"));
	if (file != NULL) {
		g_autofree gchar *basename = g_file_get_basename (file);
		gtk_header_bar_set_subtitle (GTK_HEADER_BAR (widget), basename);
	} else {
		gtk_header_bar_set_subtitle (GTK_HEADER_BAR (widget), NULL);
	}
}
Esempio n. 5
0
static void
change_subtitle (GtkButton *button, gpointer data)
{
  GtkWidget *headerbar = GTK_WIDGET (data);

  if (gtk_header_bar_get_subtitle (GTK_HEADER_BAR (headerbar)) == NULL)
    {
      gtk_header_bar_set_subtitle (GTK_HEADER_BAR (headerbar), "(subtle subtitle)");
    }
  else
    {
      gtk_header_bar_set_subtitle (GTK_HEADER_BAR (headerbar), NULL);
    }
}
Esempio n. 6
0
static void
change_subtitle (GtkButton *button, gpointer data)
{
  if (!GTK_IS_HEADER_BAR (header))
    return;

  if (gtk_header_bar_get_subtitle (GTK_HEADER_BAR (header)) == NULL)
    {
      gtk_header_bar_set_subtitle (GTK_HEADER_BAR (header), "(subtle subtitle)");
    }
  else
    {
      gtk_header_bar_set_subtitle (GTK_HEADER_BAR (header), NULL);
    }
}
Esempio n. 7
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");
    }
}
Esempio n. 8
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);
}
static void
garu_headerbar_init (GaruHeaderbar *self)
{
  GaruApplication *app;
  GSettings       *settings;
  GaruPlayer      *player;

  self->timeout_id = 0;

  garu_headerbar_init_playback_buttons (self);
  garu_headerbar_init_song_box (self);
  garu_headerbar_init_control_buttons (self);

  gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (self), TRUE);

  app = GARU_APPLICATION (g_application_get_default ());
  settings = garu_application_get_settings (app);
  player = garu_application_get_player (app);


  /* signals */
  g_settings_bind (settings, "show-settings-button",
                   self, "show-settings-button", G_SETTINGS_BIND_GET);
  g_signal_connect (player, "playing",
                    G_CALLBACK (garu_headerbar_new_playing), self);
}
Esempio n. 10
0
static void fake_gtk_header_bar_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
    /* We haven't determined the property yet... */
    if (G_UNLIKELY(PROP_SHOW_CLOSE_BUTTON == -1)) {
        GParamSpec *spec = g_object_class_find_property(G_OBJECT_GET_CLASS(object), "show-close-button");
        if (spec)
            /* Technically, this is marked as internal in GParamSpec,
             * but it's the only way to access that trivially. It's
             * been stable in gobject for over a decade now. */
            PROP_SHOW_CLOSE_BUTTON = spec->param_id;
        else
            /* We couldn't find out, for some reason. The value -2
             * will never match a valid property id, so should be safe. */
            PROP_SHOW_CLOSE_BUTTON = -2;
    }

    /* In theory, we shouldn't need to override this, since
     * set_property in the gtk3 source code just calls that function,
     * but with active compiler optimization, an inline version of it
     * may be copied into set_propery, so we also need to override
     * this here. */
    if(G_UNLIKELY((int)prop_id == PROP_SHOW_CLOSE_BUTTON))
        gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (object), FALSE);
    else
        orig_gtk_header_bar_set_property (object, prop_id, value, pspec);
}
static void
setup_search (GtkAppChooserDialog *self)
{
  gboolean use_header;

  g_object_get (self, "use-header-bar", &use_header, NULL);
  if (use_header)
    {
      GtkWidget *button;
      GtkWidget *image;
      GtkWidget *header;

      button = gtk_toggle_button_new ();
      gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
      image = gtk_image_new_from_icon_name ("edit-find-symbolic", GTK_ICON_SIZE_MENU);
      gtk_widget_show (image);
      gtk_container_add (GTK_CONTAINER (button), image);
      gtk_style_context_add_class (gtk_widget_get_style_context (button), "image-button");
      gtk_style_context_remove_class (gtk_widget_get_style_context (button), "text-button");
      gtk_widget_show (button);

      header = gtk_dialog_get_header_bar (GTK_DIALOG (self));
      gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);

      g_object_bind_property (button, "active",
                              self->priv->search_bar, "search-mode-enabled",
                              G_BINDING_BIDIRECTIONAL);
      g_object_bind_property (self->priv->search_entry, "sensitive",
                              button, "sensitive",
                              G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
    }
}
Esempio n. 12
0
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;
}
Esempio n. 13
0
/*
 * create_page:
 * @child: the #CheeseWidget to pack into the container
 * @button: the #GtkButton for taking a photo
 *
 * Create the widgets for the #CheeseAvatarWidget and pack them into a
 * container.
 *
 * Returns: a #GtkBox containing the individual #CheeseAvatarWidget widgets
 */
static GtkWidget *
create_page (GtkWidget *child,
             GtkWidget *button)
{
    GtkWidget *vgrid, *bar;
    GtkStyleContext *context;

    vgrid = gtk_grid_new ();
    gtk_grid_attach (GTK_GRID (vgrid),
                     child, 0, 0, 1, 1);
    gtk_widget_set_hexpand (child, TRUE);
    gtk_widget_set_vexpand (child, TRUE);

    bar = gtk_header_bar_new ();
    context = gtk_widget_get_style_context (GTK_WIDGET (bar));
    gtk_style_context_remove_class (context, "header-bar");
    gtk_style_context_add_class (context, "inline-toolbar");
    gtk_style_context_add_class (context, "toolbar");
    gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);

    g_object_set (G_OBJECT (button), "margin-top", 6, "margin-bottom", 6, NULL);
    gtk_header_bar_set_custom_title (GTK_HEADER_BAR (bar), button);
    gtk_grid_attach (GTK_GRID (vgrid),
                     bar, 0, 1, 1, 1);

    return vgrid;
}
Esempio n. 14
0
static void
gs_shell_set_header_end_widget (GsShell *shell, GtkWidget *widget)
{
	GsShellPrivate *priv = gs_shell_get_instance_private (shell);
	GtkWidget *old_widget;
	GtkWidget *header;

	old_widget = priv->header_end_widget;
	header = GTK_WIDGET (gtk_builder_get_object (priv->builder, "header"));

	if (priv->header_end_widget == widget)
		return;

	if (widget != NULL) {
		g_object_ref (widget);
		gtk_header_bar_pack_end (GTK_HEADER_BAR (header), widget);
	}

	priv->header_end_widget = widget;

	if (old_widget != NULL) {
		gtk_container_remove (GTK_CONTAINER (header), old_widget);
		g_object_unref (old_widget);
	}
}
Esempio n. 15
0
void
glade_gtk_header_bar_add_child (GladeWidgetAdaptor *adaptor,
                                GObject *parent,
                                GObject *child)
{
  GladeWidget *gbox, *gchild;
  gint size;
  gchar *special_child_type;

  gchild = glade_widget_get_from_gobject (child);
  if (gchild)
    glade_widget_set_pack_action_visible (gchild, "remove_slot", FALSE);

  special_child_type = g_object_get_data (child, "special-child-type");

  d(g_message ("Add %s %p (special: %s)",
	       GLADE_IS_PLACEHOLDER (child) ? "placeholder" : "child",
	       child, special_child_type));

  if (special_child_type && !strcmp (special_child_type, "title"))
    {
      gtk_header_bar_set_custom_title (GTK_HEADER_BAR (parent), GTK_WIDGET (child));
      return;
    }

  GWA_GET_CLASS (GTK_TYPE_CONTAINER)->add (adaptor, parent, child);
  
  gbox = glade_widget_get_from_gobject (parent);
  if (!glade_widget_superuser ())
    {
      glade_widget_property_get (gbox, "size", &size);
      glade_widget_property_set (gbox, "size", size);
    }
}
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
}
Esempio n. 17
0
static void
garu_headerbar_init_playback_buttons (GaruHeaderbar *self)
{
  GSettings       *settings;
  GaruApplication *app;
  GtkWidget       *box, *button, *image;

  app = GARU_APPLICATION (g_application_get_default ());
  settings = garu_application_get_settings (app);

  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);

  /* shuffle */
  button = garu_utils_new_icon_button ("media-playlist-shuffle-symbolic",
				       TRUE, FALSE);
  gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
  gtk_widget_show (button);
  /* repeat */
  button = garu_utils_new_icon_button ("media-playlist-repeat-symbolic",
				       TRUE, FALSE);
  
  gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
  gtk_widget_show (button);
  /* volume */
  button = gtk_volume_button_new ();
  gtk_scale_button_set_value (GTK_SCALE_BUTTON (button), 1);
  g_settings_bind (settings, "volume", button, "value",
                   G_SETTINGS_BIND_DEFAULT);
  gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
  gtk_widget_show (button);

  gtk_header_bar_pack_end (GTK_HEADER_BAR (self), box);
  gtk_widget_show (box);
}
Esempio n. 18
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);
}
void WebInspectorProxy::createInspectorWindow()
{
    if (m_client.openWindow(this))
        return;

    ASSERT(!m_inspectorWindow);
    m_inspectorWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    GtkWidget* inspectedViewParent = gtk_widget_get_toplevel(m_page->viewWidget());
    if (WebCore::widgetIsOnscreenToplevelWindow(inspectedViewParent))
        gtk_window_set_transient_for(GTK_WINDOW(m_inspectorWindow), GTK_WINDOW(inspectedViewParent));

#if GTK_CHECK_VERSION(3, 10, 0)
    m_headerBar = gtk_header_bar_new();
    gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(m_headerBar), TRUE);

    m_dockBottomButton = gtk_button_new();
    g_object_add_weak_pointer(G_OBJECT(m_dockBottomButton), reinterpret_cast<void**>(&m_dockBottomButton));
    g_signal_connect(m_dockBottomButton, "clicked", G_CALLBACK(dockButtonClicked), this);
    gtk_widget_set_sensitive(m_dockBottomButton, canAttach());
    gtk_button_set_relief(GTK_BUTTON(m_dockBottomButton), GTK_RELIEF_NONE);
    gtk_button_set_image(GTK_BUTTON(m_dockBottomButton), gtk_image_new_from_resource("/org/webkitgtk/inspector/UserInterface/Images/DockBottom.svg"));
    gtk_header_bar_pack_start(GTK_HEADER_BAR(m_headerBar), m_dockBottomButton);
    gtk_widget_show(m_dockBottomButton);

    m_dockRightButton = gtk_button_new();
    g_object_add_weak_pointer(G_OBJECT(m_dockRightButton), reinterpret_cast<void**>(&m_dockRightButton));
    g_signal_connect(m_dockRightButton, "clicked", G_CALLBACK(dockButtonClicked), this);
    gtk_widget_set_sensitive(m_dockRightButton, canAttach());
    gtk_button_set_relief(GTK_BUTTON(m_dockRightButton), GTK_RELIEF_NONE);
    gtk_button_set_image(GTK_BUTTON(m_dockRightButton), gtk_image_new_from_resource("/org/webkitgtk/inspector/UserInterface/Images/DockRight.svg"));
    gtk_header_bar_pack_start(GTK_HEADER_BAR(m_headerBar), m_dockRightButton);
    gtk_widget_show(m_dockRightButton);

    gtk_window_set_titlebar(GTK_WINDOW(m_inspectorWindow), m_headerBar);
    gtk_widget_show(m_headerBar);
#endif

    updateInspectorWindowTitle();
    gtk_window_set_default_size(GTK_WINDOW(m_inspectorWindow), initialWindowWidth, initialWindowHeight);

    gtk_container_add(GTK_CONTAINER(m_inspectorWindow), m_inspectorView);
    gtk_widget_show(m_inspectorView);

    g_object_add_weak_pointer(G_OBJECT(m_inspectorWindow), reinterpret_cast<void**>(&m_inspectorWindow));
    gtk_window_present(GTK_WINDOW(m_inspectorWindow));
}
Esempio n. 20
0
void
glade_gtk_header_bar_set_use_custom_title (GObject *object,
					   gboolean use_custom_title)
{
  GladeWidget *gwidget = glade_widget_get_from_gobject (object);
  GtkWidget *child;

  if (use_custom_title)
    {
      child = gtk_header_bar_get_custom_title (GTK_HEADER_BAR (object));
      if (!child)
	{
	  child = glade_placeholder_new ();
	  g_object_set_data (G_OBJECT (child), "special-child-type", "title");
	}
    }
  else
    child = NULL;

  gtk_header_bar_set_custom_title (GTK_HEADER_BAR (object), child);

  if (GLADE_IS_PLACEHOLDER (child))
    {
      GList *list, *l;

      list = glade_placeholder_packing_actions (GLADE_PLACEHOLDER (child));
      for (l = list; l; l = l->next)
	{
	  GladeWidgetAction *gwa = l->data;
	  if (!strcmp (glade_widget_action_get_class (gwa)->id, "remove_slot"))
	    glade_widget_action_set_visible (gwa, FALSE);
	}
    }

  if (use_custom_title)
    {
      glade_widget_property_set_sensitive (gwidget, "title", FALSE, TITLE_DISABLED_MESSAGE);
      glade_widget_property_set_sensitive (gwidget, "subtitle", FALSE, TITLE_DISABLED_MESSAGE);
      glade_widget_property_set_sensitive (gwidget, "has-subtitle", FALSE, TITLE_DISABLED_MESSAGE);
    }
  else
    {
      glade_widget_property_set_sensitive (gwidget, "title", TRUE, NULL);
      glade_widget_property_set_sensitive (gwidget, "subtitle", TRUE, NULL);
      glade_widget_property_set_sensitive (gwidget, "has-subtitle", TRUE, NULL);
    }
}
Esempio n. 21
0
static void
_gth_window_add_header_bar (GthWindow *self)
{
	self->priv->headerbar = gtk_header_bar_new ();
	gtk_widget_show (self->priv->headerbar);
	gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (self->priv->headerbar), TRUE);

	g_object_add_weak_pointer (G_OBJECT (self->priv->headerbar), &self->priv->headerbar);

#if GTK_CHECK_VERSION(3,12,0)
	{
		gboolean  shell_shows_app_menu;
		char     *decoration_layout;

		g_object_get (gtk_settings_get_default (),
			      "gtk-shell-shows-app-menu", &shell_shows_app_menu,
			      "gtk-decoration-layout", &decoration_layout,
			      NULL);
		if (! shell_shows_app_menu && ((decoration_layout == NULL) || (strstr (decoration_layout, "menu") == NULL))) {
			gboolean  left_part_is_empty;
			char     *new_layout;

			/* add 'menu' to the left */

			left_part_is_empty = (decoration_layout == NULL) || (decoration_layout[0] == '\0') || (decoration_layout[0] == ':');
			new_layout = g_strconcat ("menu", (left_part_is_empty ? "" : ","), decoration_layout, NULL);
			gtk_header_bar_set_decoration_layout (GTK_HEADER_BAR (self->priv->headerbar), new_layout);

			g_free (new_layout);
		}

		g_free (decoration_layout);
	}
#endif

	self->priv->title = gth_window_title_new ();
	gtk_widget_show (self->priv->title);
	gtk_header_bar_set_custom_title (GTK_HEADER_BAR (self->priv->headerbar), self->priv->title);

	self->priv->headerbar_container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_widget_show (self->priv->headerbar_container);
	gtk_box_pack_start (GTK_BOX (self->priv->headerbar_container), self->priv->headerbar, TRUE, TRUE, 0);

	gtk_window_set_titlebar (GTK_WINDOW (self), self->priv->headerbar_container);
}
Esempio n. 22
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);
}
Esempio n. 23
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));
}
Esempio n. 24
0
static void
garu_headerbar_init_song_box (GaruHeaderbar *self)
{
  GtkWidget *song_box;
  song_box = garu_song_box_new ();
  gtk_header_bar_set_custom_title(GTK_HEADER_BAR(self), song_box);
  gtk_widget_show (song_box);
  self->song_box = GARU_SONG_BOX (song_box);
}
Esempio n. 25
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 ());
}
void
ide_workbench_header_bar_focus_search (IdeWorkbenchHeaderBar *self)
{
  GtkWidget *entry;

  g_return_if_fail (IDE_IS_WORKBENCH_HEADER_BAR (self));

  entry = gtk_header_bar_get_custom_title (GTK_HEADER_BAR (self));
  if (GTK_IS_ENTRY (entry))
    gtk_widget_grab_focus (GTK_WIDGET (entry));
}
Esempio n. 27
0
File: paint.c Progetto: sam-m888/gtk
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;
}
Esempio n. 28
0
static void
example_app_window_init (ExampleAppWindow *win)
{
        gtk_widget_init_template (GTK_WIDGET (win));

        ExampleAppWindowPrivate *priv = example_app_window_get_instance_private (win);
        gtk_header_bar_set_decoration_layout (GTK_HEADER_BAR (priv->header), ":");


        priv->open_button = gtk_button_new_from_icon_name ("document-open-symbolic", GTK_ICON_SIZE_BUTTON);
        gtk_widget_set_valign (priv->open_button, GTK_ALIGN_CENTER);

        gtk_header_bar_pack_start (GTK_HEADER_BAR (priv->header), priv->open_button);
        gtk_widget_show (priv->open_button);
        g_signal_connect (priv->open_button, "clicked", (GCallback) on_open_clicked, win);


        priv->save_button = gtk_button_new_from_icon_name ("document-save-symbolic", GTK_ICON_SIZE_BUTTON);
        gtk_widget_set_valign (priv->save_button, GTK_ALIGN_CENTER);

        gtk_header_bar_pack_start (GTK_HEADER_BAR (priv->header), priv->save_button);
        gtk_widget_show (priv->save_button);
        g_signal_connect (priv->save_button, "clicked", (GCallback) on_save_clicked, win);


        priv->cancel_button = gtk_button_new_from_icon_name ("process-error-symbolic", GTK_ICON_SIZE_BUTTON);
        gtk_widget_set_valign (priv->cancel_button, GTK_ALIGN_CENTER);

        gtk_header_bar_pack_end (GTK_HEADER_BAR (priv->header), priv->cancel_button);
        gtk_widget_show (priv->cancel_button);
        g_signal_connect (priv->cancel_button, "clicked", (GCallback) on_cancel_clicked, win);


        priv->destroy_button = gtk_button_new_from_icon_name ("edit-delete-symbolic", GTK_ICON_SIZE_BUTTON);
        gtk_widget_set_valign (priv->destroy_button, GTK_ALIGN_CENTER);

        gtk_header_bar_pack_end (GTK_HEADER_BAR (priv->header), priv->destroy_button);
        gtk_widget_show (priv->destroy_button);
        g_signal_connect (priv->destroy_button, "clicked", (GCallback) on_destroy_clicked, win);
}
Esempio n. 29
0
static void
selection_changed_cb (GtkButton * button, gpointer vdata)
{
  int i;
  struct filter_data * data = vdata;

  // If the button isn't active, we are not interested in it.
  if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) return;

  for (i = 0; i < MAX_FILTERS_ON_TOOLBAR; i++) {
    if (GTK_WIDGET (button) == data->filters[i].widget) {
      data->active_activity_type = data->filters[i].type;

      switch (data->active_activity_type) {
        case ACTIVITY_FILTER_ALL:
        gtk_header_bar_set_subtitle(GTK_HEADER_BAR (data->header_bar), _("All"));
        break;

        case ACTIVITY_FILTER_DOWNLOADING:
        gtk_header_bar_set_subtitle(GTK_HEADER_BAR (data->header_bar), _("Downloading"));
        break;

        case ACTIVITY_FILTER_SEEDING:
        gtk_header_bar_set_subtitle(GTK_HEADER_BAR (data->header_bar), _("Seeding"));
        break;

        case ACTIVITY_FILTER_ACTIVE:
        gtk_header_bar_set_subtitle(GTK_HEADER_BAR (data->header_bar), _("Active"));
        break;

        default:
        break;
      }
    }
  }

  /* refilter */
  gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (data->filter_model));
}
Esempio n. 30
-1
void WebInspectorProxy::createInspectorWindow()
{
    if (m_client.openWindow(this))
        return;

    ASSERT(!m_inspectorWindow);
    m_inspectorWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    GtkWidget* inspectedViewParent = gtk_widget_get_toplevel(inspectedPage()->viewWidget());
    if (WebCore::widgetIsOnscreenToplevelWindow(inspectedViewParent))
        gtk_window_set_transient_for(GTK_WINDOW(m_inspectorWindow), GTK_WINDOW(inspectedViewParent));

#if GTK_CHECK_VERSION(3, 10, 0)
    m_headerBar = gtk_header_bar_new();
    gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(m_headerBar), TRUE);
    gtk_window_set_titlebar(GTK_WINDOW(m_inspectorWindow), m_headerBar);
    gtk_widget_show(m_headerBar);
#endif

    updateInspectorWindowTitle();
    gtk_window_set_default_size(GTK_WINDOW(m_inspectorWindow), initialWindowWidth, initialWindowHeight);

    gtk_container_add(GTK_CONTAINER(m_inspectorWindow), m_inspectorView);
    gtk_widget_show(m_inspectorView);

    g_object_add_weak_pointer(G_OBJECT(m_inspectorWindow), reinterpret_cast<void**>(&m_inspectorWindow));
    gtk_window_present(GTK_WINDOW(m_inspectorWindow));
}