Пример #1
0
static void
ev_sidebar_document_changed_cb (EvDocumentModel *model,
				GParamSpec      *pspec,
				EvSidebar       *ev_sidebar)
{
	EvSidebarPrivate *priv = GET_PRIVATE (ev_sidebar);
	EvDocument *document = ev_document_model_get_document (model);
	GtkTreeIter iter;
	gboolean valid;
	GtkWidget *first_supported_page = NULL;

	for (valid = gtk_tree_model_get_iter_first (priv->page_model, &iter);
	     valid;
	     valid = gtk_tree_model_iter_next (priv->page_model, &iter)) {
		GtkWidget *widget;
		gchar *title;
		gchar *icon_name;

		gtk_tree_model_get (priv->page_model, &iter,
				    PAGE_COLUMN_MAIN_WIDGET, &widget,
				    PAGE_COLUMN_TITLE, &title,
				    PAGE_COLUMN_ICON_NAME, &icon_name,
				    -1);

		if (ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (widget),	document)) {
			gtk_container_child_set (GTK_CONTAINER (priv->stack),
				 widget,
				 "icon-name", icon_name,
				 "title", title,
				 NULL);
			if (!first_supported_page)
                                first_supported_page = widget;
		} else {
			/* Without icon and title, the page is not shown in
			 * the GtkStackSwitchter */
			gtk_container_child_set (GTK_CONTAINER (priv->stack),
				 widget,
				 "icon-name", NULL,
				 "title", NULL,
				 NULL);
		}
		g_object_unref (widget);
		g_free (title);
		g_free (icon_name);
	}

	if (first_supported_page != NULL) {
		if (!ev_sidebar_current_page_support_document (ev_sidebar, document)) {
			ev_sidebar_set_page (ev_sidebar, first_supported_page);
		}
	} else {
		gtk_widget_hide (GTK_WIDGET (ev_sidebar));
	}
}
Пример #2
0
static void
gtk_scale_button_set_orientation_private (GtkScaleButton *button,
                                          GtkOrientation  orientation)
{
  GtkScaleButtonPrivate *priv = button->priv;

  if (orientation != priv->orientation)
    {
      priv->orientation = orientation;

      gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box),
                                      orientation);
      gtk_container_child_set (GTK_CONTAINER (priv->box),
                               button->plus_button,
                               "pack-type",
                               orientation == GTK_ORIENTATION_VERTICAL ?
                               GTK_PACK_START : GTK_PACK_END,
                               NULL);
      gtk_container_child_set (GTK_CONTAINER (priv->box),
                               button->minus_button,
                               "pack-type",
                               orientation == GTK_ORIENTATION_VERTICAL ?
                               GTK_PACK_END : GTK_PACK_START,
                               NULL);

      gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->scale),
                                      orientation);

      if (orientation == GTK_ORIENTATION_VERTICAL)
        {
          gtk_widget_set_size_request (GTK_WIDGET (priv->scale),
                                       -1, SCALE_SIZE);
          gtk_range_set_inverted (GTK_RANGE (priv->scale), TRUE);
        }
      else
        {
          gtk_widget_set_size_request (GTK_WIDGET (priv->scale),
                                       SCALE_SIZE, -1);
          gtk_range_set_inverted (GTK_RANGE (priv->scale), FALSE);
        }

      /* FIXME: without this, the popup window appears as a square
       * after changing the orientation
       */
      gtk_window_resize (GTK_WINDOW (priv->dock), 1, 1);

      g_object_notify (G_OBJECT (button), "orientation");
    }
}
Пример #3
0
int
nautilus_notebook_add_tab (NautilusNotebook *notebook,
			   NautilusWindowSlot *slot,
			   int position,
			   gboolean jump_to)
{
	GtkNotebook *gnotebook = GTK_NOTEBOOK (notebook);
	GtkWidget *tab_label;

	g_return_val_if_fail (NAUTILUS_IS_NOTEBOOK (notebook), -1);
	g_return_val_if_fail (NAUTILUS_IS_WINDOW_SLOT (slot), -1);

	tab_label = build_tab_label (notebook, slot);

	position = gtk_notebook_insert_page (GTK_NOTEBOOK (notebook),
					     GTK_WIDGET (slot),
					     tab_label,
					     position);

	gtk_container_child_set (GTK_CONTAINER (notebook),
				 GTK_WIDGET (slot),
				 "tab-expand", TRUE,
				 NULL);

	nautilus_notebook_sync_tab_label (notebook, slot);
	nautilus_notebook_sync_loading (notebook, slot);

	if (jump_to) {
		gtk_notebook_set_current_page (gnotebook, position);
	}

	return position;
}
Пример #4
0
static void
pnl_tab_strip_child_position_changed (PnlTabStrip *self,
                                      GParamSpec  *pspec,
                                      GtkWidget   *child)
{
  GVariant *state;
  GtkWidget *parent;
  PnlTab *tab;
  guint position;

  g_assert (PNL_IS_TAB_STRIP (self));
  g_assert (GTK_IS_WIDGET (child));

  tab = g_object_get_data (G_OBJECT (child), "PNL_TAB");

  if (!tab || !PNL_IS_TAB (tab))
    return;

  parent = gtk_widget_get_parent (child);

  gtk_container_child_get (GTK_CONTAINER (parent), child,
                           "position", &position,
                           NULL);

  gtk_container_child_set (GTK_CONTAINER (self), GTK_WIDGET (tab),
                           "position", position,
                           NULL);

  state = g_variant_new_int32 (position);
  gtk_actionable_set_action_target_value (GTK_ACTIONABLE (tab), state);
}
Пример #5
0
static void
section_notify_cb (GObject    *section,
                   GParamSpec *pspec,
                   gpointer    data)
{
  GtkShortcutsWindow *self = data;
  GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self);

  if (strcmp (pspec->name, "section-name") == 0)
    {
      gchar *name;

      g_object_get (section, "section-name", &name, NULL);
      gtk_container_child_set (GTK_CONTAINER (priv->stack), GTK_WIDGET (section), "name", name, NULL);
      g_free (name);
    }
  else if (strcmp (pspec->name, "title") == 0)
    {
      gchar *title;
      GtkWidget *label;

      label = g_object_get_data (section, "gtk-shortcuts-title");
      g_object_get (section, "title", &title, NULL);
      gtk_label_set_label (GTK_LABEL (label), title);
      g_free (title);
    }
}
Пример #6
0
static void
ide_editor_utilities_add (GtkContainer *container,
                          GtkWidget    *widget)
{
  IdeEditorUtilities *self = (IdeEditorUtilities *)container;

  if (self->loading)
    GTK_CONTAINER_CLASS (ide_editor_utilities_parent_class)->add (container, widget);
  else
    gtk_container_add (GTK_CONTAINER (self->stack), widget);

  if (DZL_IS_DOCK_WIDGET (widget))
    {
      g_autofree gchar *icon_name = NULL;
      g_autofree gchar *title = NULL;

      g_object_get (widget,
                    "icon-name", &icon_name,
                    "title", &title,
                    NULL);

      gtk_container_child_set (GTK_CONTAINER (self->stack), widget,
                               "title", title,
                               "icon-name", icon_name,
                               NULL);

      gtk_container_foreach (GTK_CONTAINER (self->stack_switcher),
                             tweak_radio_button,
                             NULL);
    }
}
Пример #7
0
static void
gb_terminal_set_needs_attention (GbTerminalView  *self,
                                 gboolean         needs_attention,
                                 GtkPositionType  position)
{
  GtkWidget *parent;

  g_assert (GB_IS_TERMINAL_VIEW (self));

  parent = gtk_widget_get_parent (GTK_WIDGET (self));

  if (GTK_IS_STACK (parent) &&
      !gtk_widget_in_destruction (GTK_WIDGET (self)) &&
      !gtk_widget_in_destruction (parent))
    {
      if (position == GTK_POS_TOP &&
          !gtk_widget_in_destruction (GTK_WIDGET (self->terminal_top)))
        {
          self->top_has_needs_attention = TRUE;
        }
      else if (position == GTK_POS_BOTTOM &&
               self->terminal_bottom != NULL &&
               !gtk_widget_in_destruction (GTK_WIDGET (self->terminal_bottom)))
        {
          self->bottom_has_needs_attention = TRUE;
        }

      gtk_container_child_set (GTK_CONTAINER (parent), GTK_WIDGET (self),
                               "needs-attention",
                               !!(self->top_has_needs_attention || self->bottom_has_needs_attention) &&
                               needs_attention,
                               NULL);
    }
}
Пример #8
0
void
ev_sidebar_add_page (EvSidebar   *ev_sidebar,
                     GtkWidget   *widget,
                     const gchar *name,
		     const gchar *title,
		     const gchar *icon_name)
{
	EvSidebarPrivate *priv;
	GtkTreeIter iter;

	g_return_if_fail (EV_IS_SIDEBAR (ev_sidebar));
	g_return_if_fail (GTK_IS_WIDGET (widget));

	priv = GET_PRIVATE (ev_sidebar);

	ev_sidebar_page_set_model (EV_SIDEBAR_PAGE (widget), priv->model);

	gtk_stack_add_named (GTK_STACK (priv->stack), widget, name);
	gtk_container_child_set (GTK_CONTAINER (priv->stack), widget,
				 "icon-name", icon_name,
				 "title", title,
				 NULL);

	/* Insert and move to end */
	gtk_list_store_insert_with_values (GTK_LIST_STORE (priv->page_model),
					   &iter, 0,
					   PAGE_COLUMN_NAME, name,
					   PAGE_COLUMN_MAIN_WIDGET, widget,
					   PAGE_COLUMN_TITLE, title,
					   PAGE_COLUMN_ICON_NAME, icon_name,
					   -1);
	gtk_list_store_move_before (GTK_LIST_STORE (priv->page_model),
				    &iter, NULL);
}
Пример #9
0
static void
ekiga_window_init_dialpad (EkigaWindow *mw)
{
  GtkWidget *dialpad = NULL;
  GtkWidget *grid = NULL;

  grid = gtk_grid_new ();
  gtk_grid_set_row_spacing (GTK_GRID (grid), 18);
  gtk_container_set_border_width (GTK_CONTAINER (grid), 18);

  dialpad = ekiga_dialpad_new (mw->priv->accel);
  gtk_widget_set_hexpand (dialpad, FALSE);
  gtk_widget_set_vexpand (dialpad, FALSE);
  gtk_widget_set_halign (dialpad, GTK_ALIGN_CENTER);
  gtk_widget_set_valign (dialpad, GTK_ALIGN_CENTER);
  gtk_grid_attach (GTK_GRID (grid), dialpad, 0, 0, 1, 1);
  g_signal_connect (dialpad, "button-clicked",
                    G_CALLBACK (dialpad_button_clicked_cb), mw);

  mw->priv->entry = ekiga_window_uri_entry_new (mw);
  gtk_widget_set_hexpand (dialpad, TRUE);
  gtk_widget_set_vexpand (dialpad, TRUE);
  gtk_widget_set_halign (mw->priv->entry, GTK_ALIGN_FILL);
  gtk_widget_set_valign (mw->priv->entry, GTK_ALIGN_END);
  gtk_grid_attach_next_to (GTK_GRID (grid), mw->priv->entry, dialpad,
                           GTK_POS_BOTTOM, 1, 1);

  gtk_stack_add_named (GTK_STACK (mw->priv->main_stack), grid, "dialpad");
  gtk_container_child_set (GTK_CONTAINER (mw->priv->main_stack),
                           grid,
                           "icon-name", "input-dialpad-symbolic", NULL);

  g_signal_connect (mw, "key-press-event",
                    G_CALLBACK (key_press_event_cb), mw);
}
Пример #10
0
int
ephy_notebook_add_tab (EphyNotebook *notebook,
                       EphyEmbed    *embed,
                       int           position,
                       gboolean      jump_to)
{
  GtkNotebook *gnotebook = GTK_NOTEBOOK (notebook);

  g_assert (EPHY_IS_NOTEBOOK (notebook));

  position = gtk_notebook_insert_page (GTK_NOTEBOOK (notebook),
                                       GTK_WIDGET (embed),
                                       NULL,
                                       position);

  gtk_container_child_set (GTK_CONTAINER (notebook),
                           GTK_WIDGET (embed),
                           "tab-expand", g_settings_get_boolean (EPHY_SETTINGS_UI,
                                                                 EPHY_PREFS_UI_EXPAND_TABS_BAR),
                           NULL);

  if (jump_to) {
    gtk_notebook_set_current_page (gnotebook, position);
    g_object_set_data (G_OBJECT (embed), "jump_to",
                       GINT_TO_POINTER (jump_to));
  }

  return position;
}
Пример #11
0
static void
toggle_icon_name (GtkWidget *button, gpointer data)
{
  gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
  gtk_container_child_set (GTK_CONTAINER (stack), w1,
			   "icon-name", active ? "edit-find-symbolic" : NULL,
			   NULL);
}
static void
remove_display_link (CcWacomPagePrivate *priv)
{
	gtk_widget_destroy (WID ("display-link"));

        gtk_container_child_set (CWID ("main-grid"),
                                 WID ("tablet-buttons-box"),
                                 "top_attach", 2, NULL);
}
Пример #13
0
static void
glade_gtk_action_bar_set_size (GObject * object, const GValue * value)
{
  GtkActionBar *box;
  GList *child, *children;
  guint new_size, old_size, i;

  box = GTK_ACTION_BAR (object);

  if (glade_util_object_is_loading (object))
    return;

  children = gtk_container_get_children (GTK_CONTAINER (box));
  children = g_list_remove (children, gtk_action_bar_get_center_widget (box));

  old_size = g_list_length (children);
  new_size = g_value_get_int (value);

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

  /* Ensure placeholders first...
   */
  for (i = 0; i < new_size; i++)
    {
      if (g_list_length (children) < (i + 1))
        {
          GtkWidget *placeholder = glade_placeholder_new ();
          gint blank = glade_gtk_action_bar_get_first_blank (box);

          gtk_container_add (GTK_CONTAINER (box), placeholder);
          gtk_container_child_set (GTK_CONTAINER (box), placeholder, "position", blank, NULL);
        }
    }

  /* The box has shrunk. Remove the widgets that are on those slots */
  for (child = g_list_last (children);
       child && old_size > new_size; child = g_list_previous (child))
    {
      GtkWidget *child_widget = child->data;

      /* Refuse to remove any widgets that are either GladeWidget objects
       * or internal to the hierarchic entity (may be a composite widget,
       * not all internal widgets have GladeWidgets).
       */
      if (glade_widget_get_from_gobject (child_widget) ||
          GLADE_IS_PLACEHOLDER (child_widget) == FALSE)
        continue;

      gtk_container_remove (GTK_CONTAINER (box), child_widget);
      old_size--;
    }
  g_list_free (children);
}
Пример #14
0
/* Applies or loads the child properties of a child of a GtkFixed. */
void
gb_fixed_set_child_properties (GtkWidget *widget, GtkWidget *child,
			       GbWidgetSetArgData *data)
{
  gint x, y;

  x = gb_widget_input_int (data, GladeFixedChildX);
  if (data->apply)
    gtk_container_child_set (GTK_CONTAINER (widget), child,
			     "x", x,
			     NULL);

  y = gb_widget_input_int (data, GladeFixedChildY);
  if (data->apply)
    gtk_container_child_set (GTK_CONTAINER (widget), child,
			     "y", y,
			     NULL);
}
static void
update_tablet_ui (CcWacomPage *page,
		  int          layout)
{
	CcWacomPagePrivate *priv;
	gboolean has_monitor = FALSE;

	priv = page->priv;

	/* Hide the pad buttons if no pad is present */
	gtk_widget_set_visible (WID ("map-buttons-button"), priv->pad != NULL);

	switch (layout) {
	case LAYOUT_NORMAL:
		remove_left_handed (priv);
		remove_display_link (priv);
		break;
	case LAYOUT_REVERSIBLE:
		remove_display_link (priv);
		break;
	case LAYOUT_SCREEN:
		remove_left_handed (priv);

		gtk_widget_destroy (WID ("combo-tabletmode"));
		gtk_widget_destroy (WID ("label-trackingmode"));
		gtk_widget_destroy (WID ("display-mapping-button"));

		gtk_widget_show (WID ("button-calibrate"));
		if (csd_wacom_device_get_display_monitor (priv->stylus) >= 0)
			has_monitor = TRUE;
		gtk_widget_set_sensitive (WID ("button-calibrate"), has_monitor);
		gtk_widget_show (WID ("display-link"));

		gtk_container_child_set (CWID ("main-grid"),
					 WID ("tablet-buttons-box"),
					 "top_attach", 1, NULL);
		gtk_container_child_set (CWID ("main-grid"),
					 WID ("display-link"),
					 "top_attach", 2, NULL);
		break;
	default:
		g_assert_not_reached ();
	}
}
Пример #16
0
static void
set_needs_attention (GtkWidget *page, gboolean needs_attention)
{
  GtkWidget *stack;

  stack = gtk_widget_get_parent (page);
  gtk_container_child_set (GTK_CONTAINER (stack), page,
                           "needs-attention", needs_attention,
                           NULL);
}
Пример #17
0
static void
glade_gtk_action_bar_set_child_pack_type (GObject * container,
                                          GObject * child,
                                          GValue * value)
{
  GtkPackType pack_type;

  pack_type = g_value_get_enum (value);

  gtk_container_child_set (GTK_CONTAINER (container), GTK_WIDGET (child), "pack-type", pack_type, NULL);
}
Пример #18
0
static void
gs_page_needs_user_action (GsPageHelper *helper, AsScreenshot *ss)
{
	GtkWidget *content_area;
	GtkWidget *dialog;
	GtkWidget *ssimg;
	g_autofree gchar *escaped = NULL;
	GsPagePrivate *priv = gs_page_get_instance_private (helper->page);

	dialog = gtk_message_dialog_new (gs_shell_get_window (priv->shell),
					 GTK_DIALOG_MODAL |
					 GTK_DIALOG_USE_HEADER_BAR,
					 GTK_MESSAGE_INFO,
					 GTK_BUTTONS_CANCEL,
					 /* TRANSLATORS: this is a prompt message, and
					  * '%s' is an application summary, e.g. 'GNOME Clocks' */
					 _("Prepare %s"),
					 gs_app_get_name (helper->app));
	escaped = g_markup_escape_text (as_screenshot_get_caption (ss, NULL), -1);
	gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog),
						    "%s", escaped);

	/* this will be enabled when the device is in the right mode */
	helper->button_install = gtk_dialog_add_button (GTK_DIALOG (dialog),
							/* TRANSLATORS: update the fw */
							_("Install"),
							GTK_RESPONSE_OK);
	helper->notify_quirk_id =
		g_signal_connect (helper->app, "notify::quirk",
				  G_CALLBACK (gs_page_notify_quirk_cb),
				  helper);
	gtk_widget_set_sensitive (helper->button_install, FALSE);

	/* load screenshot */
	helper->soup_session = soup_session_new_with_options (SOUP_SESSION_USER_AGENT,
							      gs_user_agent (), NULL);
	ssimg = gs_screenshot_image_new (helper->soup_session);
	gs_screenshot_image_set_screenshot (GS_SCREENSHOT_IMAGE (ssimg), ss);
	gs_screenshot_image_set_size (GS_SCREENSHOT_IMAGE (ssimg), 400, 225);
	gs_screenshot_image_load_async (GS_SCREENSHOT_IMAGE (ssimg),
					helper->cancellable);
	gtk_widget_set_margin_start (ssimg, 24);
	gtk_widget_set_margin_end (ssimg, 24);
	content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
	gtk_container_add (GTK_CONTAINER (content_area), ssimg);
	gtk_container_child_set (GTK_CONTAINER (content_area), ssimg, "pack-type", GTK_PACK_END, NULL);

	/* handle this async */
	g_signal_connect (dialog, "response",
			  G_CALLBACK (gs_page_update_app_response_cb), helper);
	gs_shell_modal_dialog_present (priv->shell, GTK_DIALOG (dialog));
}
Пример #19
0
static gint
luaH_notebook_set_title(lua_State *L)
{
    size_t len;
    widget_t *w = luaH_checkwidget(L, 1);
    widget_t *child = luaH_checkwidget(L, 2);
    const gchar *title = luaL_checklstring(L, 3, &len);
    GtkWidget *label = gtk_label_new(title);
    gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_MIDDLE);
    gtk_notebook_set_tab_label(GTK_NOTEBOOK(w->widget),
        child->widget, label);
    gtk_container_child_set(GTK_CONTAINER(w->widget), label, "tab-expand", TRUE, "tab-fill", TRUE, NULL);
    return 0;
}
Пример #20
0
static void
ekiga_window_init_contact_list (EkigaWindow *mw)
{
  mw->priv->roster_view = roster_view_gtk_new (mw->priv->presence_core,
                                               mw->priv->account_core);
  gtk_stack_add_named (GTK_STACK (mw->priv->main_stack), mw->priv->roster_view, "contacts");
  gtk_container_child_set (GTK_CONTAINER (mw->priv->main_stack),
                           mw->priv->roster_view,
                           "icon-name", "avatar-default-symbolic", NULL);

  g_object_ref (mw->priv->roster_view);

  g_signal_connect (mw->priv->roster_view, "actions-changed",
                    G_CALLBACK (actions_changed_cb), mw);
}
Пример #21
0
static void
ekiga_window_init_history (EkigaWindow *mw)
{
  boost::shared_ptr<History::Source> history_source = mw->priv->history_source.lock ();
  if (history_source) {
    boost::shared_ptr<History::Book> history_book = history_source->get_book ();

    mw->priv->call_history_view = call_history_view_gtk_new (history_book,
                                                             mw->priv->call_core,
                                                             mw->priv->contact_core);
    gtk_stack_add_named (GTK_STACK (mw->priv->main_stack), mw->priv->call_history_view, "call-history");
    gtk_container_child_set (GTK_CONTAINER (mw->priv->main_stack),
                             mw->priv->call_history_view,
                             "icon-name", "document-open-recent-symbolic", NULL);

    g_signal_connect (mw->priv->call_history_view, "actions-changed",
                      G_CALLBACK (actions_changed_cb), mw);
  }
}
Пример #22
0
int
nemo_notebook_add_tab (NemoNotebook *notebook,
			   NemoWindowSlot *slot,
			   int position,
			   gboolean jump_to)
{
	GtkNotebook *gnotebook = GTK_NOTEBOOK (notebook);
	GtkWidget *tab_label;

	g_return_val_if_fail (NEMO_IS_NOTEBOOK (notebook), -1);
	g_return_val_if_fail (NEMO_IS_WINDOW_SLOT (slot), -1);

	tab_label = build_tab_label (notebook, slot);

	position = gtk_notebook_insert_page (GTK_NOTEBOOK (notebook),
					     GTK_WIDGET (slot),
					     tab_label,
					     position);

	gtk_container_child_set (GTK_CONTAINER (notebook),
				 GTK_WIDGET (slot),
				 "tab-expand", TRUE,
				 NULL);

	nemo_notebook_sync_tab_label (notebook, slot);
	nemo_notebook_sync_loading (notebook, slot);


	/* FIXME gtk bug! */
	/* FIXME: this should be fixed in gtk 2.12; check & remove this! */
	/* The signal handler may have reordered the tabs */
	position = gtk_notebook_page_num (gnotebook, GTK_WIDGET (slot));

	if (jump_to)
	{
		gtk_notebook_set_current_page (gnotebook, position);

	}

	return position;
}
Пример #23
0
static void
gbp_terminal_page_set_needs_attention (IdeTerminalPage *self,
                                       gboolean         needs_attention)
{
  GtkWidget *parent;

  g_assert (IDE_IS_TERMINAL_PAGE (self));

  parent = gtk_widget_get_parent (GTK_WIDGET (self));

  if (GTK_IS_STACK (parent) &&
      !gtk_widget_in_destruction (GTK_WIDGET (self)) &&
      !gtk_widget_in_destruction (parent))
    {
      if (!gtk_widget_in_destruction (GTK_WIDGET (self->terminal_top)))
        self->needs_attention = !!needs_attention;

      gtk_container_child_set (GTK_CONTAINER (parent), GTK_WIDGET (self),
                               "needs-attention", needs_attention,
                               NULL);
    }
}
Пример #24
0
void
ephy_notebook_tab_set_pinned (EphyNotebook *notebook,
                              GtkWidget    *embed,
                              gboolean      is_pinned)
{
  GtkWidget *tab_label;
  gboolean expanded;

  if (is_pinned) {
    gtk_notebook_reorder_child (GTK_NOTEBOOK (notebook), embed, 0);
    expanded = FALSE;
  } else {
    expanded = g_settings_get_boolean (EPHY_SETTINGS_UI, EPHY_PREFS_UI_EXPAND_TABS_BAR);
  }

  gtk_container_child_set (GTK_CONTAINER (notebook), embed, "tab-expand", expanded, NULL);

  gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (notebook), embed, !is_pinned);

  tab_label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (notebook), embed);
  ephy_tab_label_set_pinned (tab_label, is_pinned);
}
Пример #25
0
static void
palette_drop_item (GtkToolItem      *drag_item,
                   GtkToolItemGroup *drop_group,
                   gint              x,
                   gint              y)
{
  GtkWidget *drag_group = gtk_widget_get_parent (GTK_WIDGET (drag_item));
  GtkToolItem *drop_item = gtk_tool_item_group_get_drop_item (drop_group, x, y);
  gint drop_position = -1;

  if (drop_item)
    drop_position = gtk_tool_item_group_get_item_position (GTK_TOOL_ITEM_GROUP (drop_group), drop_item);

  if (GTK_TOOL_ITEM_GROUP (drag_group) != drop_group)
    {
      gboolean homogeneous, expand, fill, new_row;

      g_object_ref (drag_item);
      gtk_container_child_get (GTK_CONTAINER (drag_group), GTK_WIDGET (drag_item),
                               "homogeneous", &homogeneous,
                               "expand", &expand,
                               "fill", &fill,
                               "new-row", &new_row,
                               NULL);
      gtk_container_remove (GTK_CONTAINER (drag_group), GTK_WIDGET (drag_item));
      gtk_tool_item_group_insert (GTK_TOOL_ITEM_GROUP (drop_group),
                                  drag_item, drop_position);
      gtk_container_child_set (GTK_CONTAINER (drop_group), GTK_WIDGET (drag_item),
                               "homogeneous", homogeneous,
                               "expand", expand,
                               "fill", fill,
                               "new-row", new_row,
                               NULL);
      g_object_unref (drag_item);
    }
  else
    gtk_tool_item_group_set_item_position (GTK_TOOL_ITEM_GROUP (drop_group),
                                           drag_item, drop_position);
}
Пример #26
0
/**
 * gedit_notebook_add_tab:
 * @nb: a #GeditNotebook
 * @tab: a #GeditTab
 * @position: the position where the @tab should be added
 * @jump_to: %TRUE to set the @tab as active
 *
 * Adds the specified @tab to the @nb.
 */
void
gedit_notebook_add_tab (GeditNotebook *nb,
		        GeditTab      *tab,
		        gint           position,
		        gboolean       jump_to)
{
	GtkWidget *tab_label;

	g_return_if_fail (GEDIT_IS_NOTEBOOK (nb));
	g_return_if_fail (GEDIT_IS_TAB (tab));

	tab_label = create_tab_label (nb, tab);

	gtk_notebook_insert_page (GTK_NOTEBOOK (nb),
				  GTK_WIDGET (tab),
				  tab_label,
				  position);
	gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (nb),
	                                  GTK_WIDGET (tab),
	                                  TRUE);
	gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (nb),
	                                 GTK_WIDGET (tab),
	                                 TRUE);
	gtk_container_child_set (GTK_CONTAINER (nb),
				 GTK_WIDGET (tab),
				 "tab-expand", TRUE,
				 NULL);

	/* The signal handler may have reordered the tabs */
	position = gtk_notebook_page_num (GTK_NOTEBOOK (nb),
					  GTK_WIDGET (tab));

	if (jump_to)
	{
		gtk_notebook_set_current_page (GTK_NOTEBOOK (nb), position);
		gtk_widget_grab_focus (GTK_WIDGET (tab));
	}
}
Пример #27
0
static void
ide_workbench_resort_perspectives (IdeWorkbench *self)
{
  GList *children;
  const GList *iter;
  gint i = 0;

  g_assert (IDE_IS_WORKBENCH (self));

  children = gtk_container_get_children (GTK_CONTAINER (self->perspectives_stack));
  children = g_list_sort (children, ide_workbench_compare_perspective);

  for (iter = children; iter; iter = iter->next, i++)
    {
      GtkWidget *child = iter->data;

      gtk_container_child_set (GTK_CONTAINER (self->perspectives_stack), child,
                               "position", i,
                               NULL);
    }

  g_list_free (children);
}
Пример #28
0
static int
ephy_notebook_insert_page (GtkNotebook *gnotebook,
                           GtkWidget   *tab_widget,
                           GtkWidget   *tab_label,
                           GtkWidget   *menu_label,
                           int          position)
{
  EphyNotebook *notebook = EPHY_NOTEBOOK (gnotebook);

  /* Destroy passed-in tab label */
  if (tab_label != NULL) {
    g_object_ref_sink (tab_label);
    g_object_unref (tab_label);
  }

  g_assert (EPHY_IS_EMBED (tab_widget));

  tab_label = build_tab_label (notebook, EPHY_EMBED (tab_widget));

  update_tabs_visibility (notebook, TRUE);

  position = GTK_NOTEBOOK_CLASS (ephy_notebook_parent_class)->insert_page (gnotebook,
                                                                           tab_widget,
                                                                           tab_label,
                                                                           menu_label,
                                                                           position);

  gtk_notebook_set_tab_reorderable (gnotebook, tab_widget, TRUE);
  gtk_notebook_set_tab_detachable (gnotebook, tab_widget, TRUE);
  gtk_container_child_set (GTK_CONTAINER (gnotebook),
                           GTK_WIDGET (tab_widget),
                           "tab-expand", g_settings_get_boolean (EPHY_SETTINGS_UI,
                                                                 EPHY_PREFS_UI_EXPAND_TABS_BAR),
                           NULL);

  return position;
}
Пример #29
0
void
glade_gtk_action_bar_replace_child (GladeWidgetAdaptor * adaptor,
                                    GObject * container,
                                    GObject * current,
                                    GObject * new_widget)
{
  gint position;
  GtkPackType pack_type;

  gchar *special_child_type;

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

  if (special_child_type && !strcmp (special_child_type, "center"))
    {
      g_object_set_data (G_OBJECT (new_widget), "special-child-type", "center");
      gtk_action_bar_set_center_widget (GTK_ACTION_BAR (container), GTK_WIDGET (new_widget));
      return;
    }

  gtk_container_child_get (GTK_CONTAINER (container),
                           GTK_WIDGET (current),
                           "position", &position,
                           "pack-type", &pack_type,
                           NULL); 

  gtk_container_remove (GTK_CONTAINER (container), GTK_WIDGET (current));
  gtk_container_add (GTK_CONTAINER (container), GTK_WIDGET (new_widget));

  gtk_container_child_set (GTK_CONTAINER (container),
                           GTK_WIDGET (new_widget),
                           "position", position,
                           "pack-type", pack_type,
                           NULL);
}
Пример #30
0
static void
glade_gtk_action_bar_set_child_position (GObject * container,
                                         GObject * child,
                                         GValue * value)
{
  static gboolean recursion = FALSE;
  gint new_position, old_position;

  if (recursion)
    return;

  gtk_container_child_get (GTK_CONTAINER (container), GTK_WIDGET (child), "position", &old_position, NULL);
  new_position = g_value_get_int (value);

  if (old_position == new_position)
    return;

  recursion = TRUE;
  gtk_container_child_set (GTK_CONTAINER (container), GTK_WIDGET (child),
                           "position", new_position,
                           NULL);
  gtk_container_forall (GTK_CONTAINER (container), update_position, container);
  recursion = FALSE;
}