Beispiel #1
0
static gint
sort_box_children (GtkWidget * widget_a, GtkWidget * widget_b, GtkWidget *box)
{
  GladeWidget *gwidget_a, *gwidget_b;
  gint position_a, position_b;

  gwidget_a = glade_widget_get_from_gobject (widget_a);
  gwidget_b = glade_widget_get_from_gobject (widget_b);

  /* Indirect children might be internal children, sort internal children before any other children */
  if (box != gtk_widget_get_parent (widget_a))
    return -1;
  if (box != gtk_widget_get_parent (widget_b))
    return 1;

  if (gtk_box_get_center_widget (GTK_BOX (box)) == widget_a)
    return -1;
  if (gtk_box_get_center_widget (GTK_BOX (box)) == widget_b)
    return -1;

  /* XXX Sometimes the packing "position" property doesnt exist here, why ?
   */
  if (gwidget_a)
    glade_widget_pack_property_get (gwidget_a, "position", &position_a);
  else
    gtk_container_child_get (GTK_CONTAINER (box),
                             widget_a, "position", &position_a, NULL);

  if (gwidget_b)
    glade_widget_pack_property_get (gwidget_b, "position", &position_b);
  else
    gtk_container_child_get (GTK_CONTAINER (box),
                             widget_b, "position", &position_b, NULL);
  return position_a - position_b;
}
static void
bond_private_init (CEPageBond *self)
{
	CEPageBondPrivate *priv = CE_PAGE_BOND_GET_PRIVATE (self);
	GtkBuilder *builder;

	builder = CE_PAGE (self)->builder;

	priv->mode = GTK_COMBO_BOX (gtk_builder_get_object (builder, "bond_mode"));
	priv->monitoring = GTK_COMBO_BOX (gtk_builder_get_object (builder, "bond_monitoring"));
	priv->frequency = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, "bond_frequency"));
	priv->updelay = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, "bond_updelay"));
	priv->updelay_label = GTK_WIDGET (gtk_builder_get_object (builder, "bond_updelay_label"));
	priv->updelay_box = GTK_WIDGET (gtk_builder_get_object (builder, "bond_updelay_box"));
	priv->downdelay = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, "bond_downdelay"));
	priv->downdelay_label = GTK_WIDGET (gtk_builder_get_object (builder, "bond_downdelay_label"));
	priv->downdelay_box = GTK_WIDGET (gtk_builder_get_object (builder, "bond_downdelay_box"));
	priv->arp_targets = GTK_ENTRY (gtk_builder_get_object (builder, "bond_arp_targets"));
	priv->arp_targets_label = GTK_WIDGET (gtk_builder_get_object (builder, "bond_arp_targets_label"));

	priv->toplevel = GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (priv->mode),
	                                                      GTK_TYPE_WINDOW));

	priv->table = GTK_TABLE (gtk_builder_get_object (builder, "BondPage"));
	priv->table_row_spacing = gtk_table_get_default_row_spacing (priv->table);
	gtk_container_child_get (GTK_CONTAINER (priv->table), priv->updelay_label,
	                         "top-attach", &priv->updelay_row,
	                         NULL);
	gtk_container_child_get (GTK_CONTAINER (priv->table), priv->downdelay_label,
	                         "top-attach", &priv->downdelay_row,
	                         NULL);
	gtk_container_child_get (GTK_CONTAINER (priv->table), priv->arp_targets_label,
	                         "top-attach", &priv->arp_targets_row,
	                         NULL);
}
static gint
sort_children (GtkWidget * widget_a, GtkWidget * widget_b, GtkWidget *box)
{
  GladeWidget *gwidget_a, *gwidget_b;
  gint position_a, position_b;

  gwidget_a = glade_widget_get_from_gobject (widget_a);
  gwidget_b = glade_widget_get_from_gobject (widget_b);

  /* Sort internal children before any other children */
  if (box != gtk_widget_get_parent (widget_a))
    return -1;
  if (box != gtk_widget_get_parent (widget_b))
    return 1;

  if (gtk_action_bar_get_center_widget (GTK_ACTION_BAR (box)) == widget_a)
    return -1;
  if (gtk_action_bar_get_center_widget (GTK_ACTION_BAR (box)) == widget_b)
    return -1;

  if (gwidget_a)
    glade_widget_pack_property_get (gwidget_a, "position", &position_a);
  else
    gtk_container_child_get (GTK_CONTAINER (box),
                             widget_a, "position", &position_a, NULL);

  if (gwidget_b)
    glade_widget_pack_property_get (gwidget_b, "position", &position_b);
  else
    gtk_container_child_get (GTK_CONTAINER (box),
                             widget_b, "position", &position_b, NULL);

  return position_a - position_b;
}
Beispiel #4
0
void
contacts_remove_field_cb (GtkWidget *button, gpointer data)
{
	GtkWidget *window = gtk_widget_get_toplevel (button);
	GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window));
	GtkWidget *ancestor = gtk_widget_get_ancestor (
		widget, GTK_TYPE_EXPANDER);
	
	gtk_window_set_focus (GTK_WINDOW (window), NULL);

	if (ancestor) {
		contacts_remove_entries (ancestor);
		return;
	}

	ancestor = gtk_widget_get_ancestor (widget, GTK_TYPE_COMBO_BOX_ENTRY);
	if (ancestor) {
		const gchar *name;
		guint top, left;
		GtkWidget *table;
		GList *c, *children;
		
		ancestor = gtk_widget_get_ancestor (
			ancestor, GTK_TYPE_EVENT_BOX);
		name = gtk_widget_get_name (ancestor);
		table = gtk_widget_get_ancestor (ancestor, GTK_TYPE_TABLE);
		gtk_container_child_get (GTK_CONTAINER (table),
			ancestor, "left-attach", &left,
			"top-attach", &top, NULL);
			
		children = gtk_container_get_children (GTK_CONTAINER (table));
		for (c = children; c; c = c->next) {
			guint ctop, cleft;
			gtk_container_child_get (GTK_CONTAINER (table),
				GTK_WIDGET (c->data),
				"left-attach", &cleft,
				"top-attach", &ctop, NULL);
			if ((cleft == left+1) && (ctop == top)) {
				contacts_remove_entries (GTK_WIDGET (c->data));
				break;
			}
		}
		g_list_free (c);
		return;
	}
	
	contacts_remove_entries (widget);
}
Beispiel #5
0
static void
update_button (GtkStackSwitcher *self,
               GtkWidget        *widget,
               GtkWidget        *button)
{
  gchar *title;
  gchar *icon_name;

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

  rebuild_child (button, icon_name, title);

  gtk_widget_set_visible (button, title != NULL || icon_name != NULL);

  if (icon_name != NULL)
    gtk_widget_set_size_request (button, -1, -1);
  else
    gtk_widget_set_size_request (button, 100, -1);

  g_free (title);
  g_free (icon_name);
}
Beispiel #6
0
static void
create_widgets (GtkActionBar  *bar,
                GtkPackType    pack_type,
                gint           n)
{
  GList *children, *l;
  GtkWidget *child;
  gint i;
  gchar *label;

  children = gtk_container_get_children (GTK_CONTAINER (bar));
  for (l = children; l; l = l->next)
    {
      GtkPackType type;

      child = l->data;
      gtk_container_child_get (GTK_CONTAINER (bar), child, "pack-type", &type, NULL);
      if (type == pack_type)
        gtk_container_remove (GTK_CONTAINER (bar), child);
    }
  g_list_free (children);

  for (i = 0; i < n; i++)
    {
      label = g_strdup_printf ("%d", i);
      child = gtk_button_new_with_label (label);
      g_free (label);

      gtk_widget_show (child);
      if (pack_type == GTK_PACK_START)
        gtk_action_bar_pack_start (bar, child);
      else
        gtk_action_bar_pack_end (bar, child);
    }
}
static void
_rows_reordered_cb (GtkTreeModel *tree_model,
                    GtkTreePath  *path,
                    GtkTreeIter  *iter,
                    gpointer      user_data)
{
  CarrickList        *list = user_data;
  CarrickListPrivate *priv = list->priv;
  GtkWidget          *item = NULL;
  DBusGProxy         *proxy = NULL;
  guint               order, index;

  if (!iter)
    return;

  gtk_tree_model_get (tree_model, iter,
                      CARRICK_COLUMN_PROXY, &proxy,
                      CARRICK_COLUMN_INDEX, &index,
                      -1);

  /* Find widget for changed row, tell it to refresh
   * variables and update */
  item = carrick_list_find_service_item (list,
                                         proxy);

  /* Check the order and, where neccesarry, reorder */
  gtk_container_child_get (GTK_CONTAINER (priv->box),
                           item,
                           "position", &order,
                           NULL);
  if (order != index)
    gtk_box_reorder_child (GTK_BOX (priv->box),
                           item,
                           index);
}
static gint
grid_get_height (GtkWidget *grid)
{
  GList *children;
  GList *child;
  gint   height = 0;
  gint   top_attach = 0;
  gint   max = 0;

  children = gtk_container_get_children (GTK_CONTAINER (grid));
  for (child = children; child; child = g_list_next (child))
    {
      gtk_container_child_get (GTK_CONTAINER (grid), child->data,
                               "top-attach", &top_attach,
                               "height", &height,
                               NULL);

      if (height + top_attach > max)
        max = height + top_attach;
    }

  g_list_free (children);

  return max;
}
Beispiel #9
0
void
toggle_shrink (GtkWidget *widget,
               GtkWidget *child)
{
  GtkWidget *parent;
  GtkPaned *paned;
  gboolean is_child1;
  gboolean resize, shrink;

  parent = gtk_widget_get_parent (child);
  paned = GTK_PANED (parent);

  is_child1 = (child == gtk_paned_get_child1 (paned));

  gtk_container_child_get (GTK_CONTAINER (paned), child,
                           "resize", &resize,
                           "shrink", &shrink,
                           NULL);

  g_object_ref (child);
  gtk_container_remove (GTK_CONTAINER (parent), child);
  if (is_child1)
    gtk_paned_pack1 (paned, child, resize, !shrink);
  else
    gtk_paned_pack2 (paned, child, resize, !shrink);
  g_object_unref (child);
}
Beispiel #10
0
static void
ide_frame_change_current_page (IdeFrame *self,
                               gint      direction)
{
  IdeFramePrivate *priv = ide_frame_get_instance_private (self);
  g_autoptr(GPtrArray) ar = NULL;
  GtkWidget *visible_child;
  gint position = 0;

  g_assert (IDE_IS_FRAME (self));

  visible_child = gtk_stack_get_visible_child (priv->stack);

  if (visible_child == NULL)
    return;

  gtk_container_child_get (GTK_CONTAINER (priv->stack), visible_child,
                           "position", &position,
                           NULL);

  ar = g_ptr_array_new ();
  gtk_container_foreach (GTK_CONTAINER (priv->stack), collect_widgets, ar);
  if (ar->len == 0)
    g_return_if_reached ();

  visible_child = g_ptr_array_index (ar, (position + direction) % ar->len);
  gtk_stack_set_visible_child (priv->stack, visible_child);
}
static void
gb_shortcuts_dialog__stack__notify_visible_child (GbShortcutsDialog *self,
                                                  GParamSpec        *pspec,
                                                  GtkStack          *stack)
{
  GbShortcutsDialogPrivate *priv = gb_shortcuts_dialog_get_instance_private (self);
  GtkWidget *visible_child;

  visible_child = gtk_stack_get_visible_child (stack);

  if (GB_IS_SHORTCUTS_VIEW (visible_child))
    {
      const gchar *title;

      title = gb_shortcuts_view_get_title (GB_SHORTCUTS_VIEW (visible_child));
      gtk_label_set_label (priv->menu_label, title);
    }
  else if (visible_child != NULL)
    {
      g_autofree gchar *title = NULL;

      gtk_container_child_get (GTK_CONTAINER (stack), visible_child,
                               "title", &title,
                               NULL);
      gtk_label_set_label (priv->menu_label, title);
    }
}
static void
carrick_list_drag_begin (GtkWidget      *widget,
                         GdkDragContext *context,
                         CarrickList    *list)
{
  CarrickListPrivate *priv = list->priv;
  gint                x, y;

  carrick_service_item_set_active (CARRICK_SERVICE_ITEM (widget), FALSE);

  /* save old place in list for drag-failures */
  gtk_container_child_get (GTK_CONTAINER (priv->box),
                           widget,
                           "position", &priv->drag_position,
                           NULL);
  priv->drop_position = priv->drag_position;

  /* remove widget from list and setup dnd popup window */
  priv->drag_window = gtk_window_new (GTK_WINDOW_POPUP);
  gtk_widget_set_size_request (priv->drag_window,
                               widget->allocation.width,
                               widget->allocation.height);
  gtk_widget_get_pointer (widget, &x, &y);
  gtk_widget_reparent (widget, priv->drag_window);
  gtk_drag_set_icon_widget (context,
                            priv->drag_window,
                            x, y);
}
Beispiel #13
0
static void
pnl_tab_strip_child_title_changed (PnlTabStrip *self,
                                   GParamSpec  *pspec,
                                   GtkWidget   *child)
{
  g_autofree gchar *title = NULL;
  GtkWidget *parent;
  PnlTab *tab;

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

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

  if (!PNL_IS_TAB (tab))
    return;

  parent = gtk_widget_get_parent (child);

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

  pnl_tab_set_title (tab, title);
}
Beispiel #14
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);
}
static void
gb_shortcuts_dialog_get_property (GObject    *object,
                                  guint       prop_id,
                                  GValue     *value,
                                  GParamSpec *pspec)
{
  GbShortcutsDialog *self = (GbShortcutsDialog *)object;
  GbShortcutsDialogPrivate *priv = gb_shortcuts_dialog_get_instance_private (self);

  switch (prop_id)
    {
    case PROP_VIEW_NAME:
      {
        GtkWidget *child = gtk_stack_get_visible_child (priv->stack);

        if (child != NULL)
          {
            gchar *name = NULL;

            gtk_container_child_get (GTK_CONTAINER (priv->stack), child,
                                     "name", &name,
                                     NULL);
            g_value_take_string (value, name);
          }
      }
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
    }
}
Beispiel #16
0
/** This function moves a GtkWidget from one GtkTable to another,
 *  preserving its attachment data, etc.  It is called when adding one
 *  partial preference page to another.
 *
 *  @internal
 *
 *  @param widget A pointer to the widget to move.
 *
 *  @param data A pointer to a data structure passed in by the caller.
 *  This data structure contains pointers to the old and new tables,
 *  plus the row offset into the new table.
 */
static void
gnc_prefs_move_table_entry (GtkWidget *child,
                            gpointer data)
{
    struct copy_data *copydata = data;
    GtkAttachOptions x_opts, y_opts;
    gint bottom, top, left, right, x_pad, y_pad;

    ENTER("child %p, copy data %p", child, data);
    gtk_container_child_get(GTK_CONTAINER(copydata->table_from), child,
                            "bottom-attach", &bottom,
                            "left-attach", &left,
                            "right-attach", &right,
                            "top-attach", &top,
                            "x-options", &x_opts,
                            "x-padding", &x_pad,
                            "y-options", &y_opts,
                            "y-padding", &y_pad,
                            NULL);

    g_object_ref(child);
    gtk_container_remove(GTK_CONTAINER(copydata->table_from), child);
    gtk_table_attach(copydata->table_to, child, left, right,
                     top + copydata->row_offset, bottom + copydata->row_offset,
                     x_opts, y_opts, x_pad, y_pad);
    g_object_unref(child);
    LEAVE(" ");
}
Beispiel #17
0
void
ide_workbench_add_perspective (IdeWorkbench   *self,
                               IdePerspective *perspective)
{
  g_autofree gchar *accel= NULL;
  g_autofree gchar *icon_name = NULL;
  g_autofree gchar *id = NULL;
  g_autofree gchar *title = NULL;
  GtkWidget *titlebar;

  g_assert (IDE_IS_WORKBENCH (self));
  g_assert (IDE_IS_PERSPECTIVE (perspective));

  id = ide_perspective_get_id (perspective);
  title = ide_perspective_get_title (perspective);
  icon_name = ide_perspective_get_icon_name (perspective);
  titlebar = ide_perspective_get_titlebar (perspective);

  gtk_container_add_with_properties (GTK_CONTAINER (self->perspectives_stack),
                                     GTK_WIDGET (perspective),
                                     "icon-name", icon_name,
                                     "name", id,
                                     "needs-attention", FALSE,
                                     "title", title,
                                     NULL);

  if (titlebar != NULL)
    gtk_container_add_with_properties (GTK_CONTAINER (self->header_stack), titlebar,
                                       "name", id,
                                       NULL);

  if (!IDE_IS_GREETER_PERSPECTIVE (perspective))
    {
      guint position = 0;

      gtk_container_child_get (GTK_CONTAINER (self->perspectives_stack),
                               GTK_WIDGET (perspective),
                               "position", &position,
                               NULL);

      g_list_store_append (self->perspectives, perspective);
      g_list_store_sort (self->perspectives,
                         ide_workbench_compare_perspective,
                         NULL);
    }

  accel = ide_perspective_get_accelerator (perspective);

  if (accel != NULL)
    {
      const gchar *accel_map[] = { accel, NULL };
      g_autofree gchar *action_name = NULL;

      action_name = g_strdup_printf ("win.perspective('%s')", id);
      gtk_application_set_accels_for_action (GTK_APPLICATION (IDE_APPLICATION_DEFAULT),
                                             action_name, accel_map);

    }
}
Beispiel #18
0
void
go_gtk_widget_replace (GtkWidget *victim, GtkWidget *replacement)
{
	GtkContainer *parent = GTK_CONTAINER (gtk_widget_get_parent (victim));

	if (GTK_IS_GRID (parent)) {
		int col, row, width, height;
		gtk_container_child_get (parent,
					 victim,
					 "left-attach", &col,
					 "top-attach", &row,
					 "width", &width,
					 "height", &height,
					 NULL);
		gtk_container_remove (parent, victim);
		gtk_grid_attach (GTK_GRID (parent), replacement,
				 col, row, width, height);
	} else if (GTK_IS_BOX (parent)) {
		GtkBox *box = GTK_BOX (parent);
		gboolean expand, fill;
		guint padding;
		GtkPackType pack_type;
		int pos;

		gtk_box_query_child_packing (box, victim,
					     &expand, &fill,
					     &padding, &pack_type);
		gtk_container_child_get (parent, victim,
					 "position", &pos,
					 NULL);
		gtk_container_remove (parent, victim);
		gtk_container_add (parent, replacement);
		gtk_box_set_child_packing (box, replacement,
					   expand, fill,
					   padding, pack_type);
		gtk_box_reorder_child (box, replacement, pos);
	} else {
		g_error ("Unsupported container: %s",
			 g_type_name_from_instance ((gpointer)parent));
	}
}
Beispiel #19
0
static void
glade_gtk_grid_get_child_attachments (GtkWidget            *grid,
                                      GtkWidget            *child,
                                      GladeGridAttachments *grid_child)
{
  gtk_container_child_get (GTK_CONTAINER (grid), child,
                           "left-attach", &grid_child->left_attach,
                           "width",       &grid_child->width,
                           "top-attach",  &grid_child->top_attach,
                           "height",      &grid_child->height,
                           NULL);
}
Beispiel #20
0
static void
ViewOvBoxGetOverGeometry(ViewOvBox *that, // IN
                         int *x,          // OUT
                         int *y,          // OUT
                         int *width,      // OUT
                         int *height)     // OUT
{
   ViewOvBoxPrivate *priv;
   gboolean expand;
   gboolean fill;
   guint padding;
   unsigned int boxWidth;
   GtkAllocation allocation;

   priv = that->priv;

   if (priv->over) {
      /*
       * When a child's expand or fill property changes, GtkBox queues
       * a resize for the child.
       */
      gtk_container_child_get(GTK_CONTAINER(that), priv->over,
                              "expand", &expand,
                              "fill", &fill,
                              "padding", &padding,
                              NULL);
   } else {
      /* Default values used by GtkBox. */
      expand = TRUE;
      fill = TRUE;
      padding = 0;
   }

   gtk_widget_get_allocation(GTK_WIDGET(that), &allocation);
   boxWidth = allocation.width;
   if (!expand) {
      *width = MIN(priv->overR.width, boxWidth - padding);
      *x = padding;
   } else if (!fill) {
      *width = MIN(priv->overR.width, boxWidth);
      *x = (boxWidth - *width) / 2;
   } else {
      *width = boxWidth;
      *x = 0;
   }

   *y =   (priv->overR.height - ViewOvBoxGetActualMin(that))
        * (priv->fraction - 1) + priv->verticalOffset;
   *height = priv->overR.height;
}
Beispiel #21
0
static void
set_tab_state (GSimpleAction *action,
               GVariant      *state,
               gpointer       user_data)
{
  PnlTabStrip *self = user_data;
  PnlTabStripPrivate *priv = pnl_tab_strip_get_instance_private (self);
  PnlTab *tab = NULL;
  const GList *iter;
  GList *list;
  gint stateval;

  g_assert (G_IS_SIMPLE_ACTION (action));
  g_assert (PNL_IS_TAB_STRIP (self));
  g_assert (state != NULL);
  g_assert (g_variant_is_of_type (state, G_VARIANT_TYPE_INT32));

  g_simple_action_set_state (action, state);

  stateval = g_variant_get_int32 (state);

  list = gtk_container_get_children (GTK_CONTAINER (priv->stack));

  for (iter = list; iter != NULL; iter = iter->next)
    {
      GtkWidget *child = iter->data;
      gint position = 0;

      gtk_container_child_get (GTK_CONTAINER (priv->stack), GTK_WIDGET (child),
                               "position", &position,
                               NULL);

      if (position == stateval)
        {
          tab = g_object_get_data (G_OBJECT (child), "PNL_TAB");
          gtk_stack_set_visible_child (priv->stack, child);
          break;
        }
    }

  /*
   * When clicking an active toggle button, we get the state callback but then
   * the toggle button disables the checked state. So ensure it stays on by
   * manually setting the state.
   */
  if (PNL_IS_TAB (tab))
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tab), TRUE);

  g_list_free (list);
}
/**
 * gimp_resolution_entry_attach_label:
 * @gre:       The #GimpResolutionEntry you want to add a label to.
 * @text:      The text of the label.
 * @row:       The row where the label will be attached.
 * @column:    The column where the label will be attached.
 * @alignment: The horizontal alignment of the label.
 *
 * Attaches a #GtkLabel to the #GimpResolutionEntry (which is a #GtkTable).
 *
 * Returns: A pointer to the new #GtkLabel widget.
 **/
GtkWidget *
gimp_resolution_entry_attach_label (GimpResolutionEntry *gre,
                                    const gchar         *text,
                                    gint                 row,
                                    gint                 column,
                                    gfloat               alignment)
{
    GtkWidget *label;

    g_return_val_if_fail (GIMP_IS_RESOLUTION_ENTRY (gre), NULL);
    g_return_val_if_fail (text != NULL, NULL);

    label = gtk_label_new_with_mnemonic (text);

    if (column == 0)
    {
        GList *children;
        GList *list;

        children = gtk_container_get_children (GTK_CONTAINER (gre));

        for (list = children; list; list = g_list_next (list))
        {
            GtkWidget *child = list->data;
            gint       left_attach;
            gint       top_attach;

            gtk_container_child_get (GTK_CONTAINER (gre), child,
                                     "left-attach", &left_attach,
                                     "top-attach",  &top_attach,
                                     NULL);

            if (left_attach == 1 && top_attach == row)
            {
                gtk_label_set_mnemonic_widget (GTK_LABEL (label), child);
                break;
            }
        }

        g_list_free (children);
    }

    gtk_misc_set_alignment (GTK_MISC (label), alignment, 0.5);

    gtk_table_attach (GTK_TABLE (gre), label, column, column+1, row, row+1,
                      GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
    gtk_widget_show (label);

    return label;
}
static void
update_position (GtkWidget *widget, gpointer data)
{
  GtkContainer *parent = data;
  GladeWidget *gwidget;
  gint position;

  gwidget = glade_widget_get_from_gobject (widget);
  if (gwidget)
    {
      gtk_container_child_get (parent, widget, "position", &position, NULL);
      glade_widget_pack_property_set (gwidget, "position", position);
    }
}
Beispiel #24
0
static void
pnl_tab_strip_stack_add (PnlTabStrip *self,
                         GtkWidget   *widget,
                         GtkStack    *stack)
{
  PnlTabStripPrivate *priv = pnl_tab_strip_get_instance_private (self);
  GVariant *target;
  PnlTab *tab;
  gint position = 0;

  g_assert (PNL_IS_TAB_STRIP (self));
  g_assert (GTK_IS_WIDGET (widget));
  g_assert (GTK_IS_STACK (stack));

  gtk_container_child_get (GTK_CONTAINER (stack), widget,
                           "position", &position,
                           NULL);

  target = g_variant_new_int32 (position);

  tab = g_object_new (PNL_TYPE_TAB,
                      "action-name", "tab-strip.tab",
                      "action-target", target,
                      "edge", priv->edge,
                      "widget", widget,
                      NULL);

  g_object_set_data (G_OBJECT (widget), "PNL_TAB", tab);

  g_signal_connect_object (widget,
                           "child-notify::position",
                           G_CALLBACK (pnl_tab_strip_child_position_changed),
                           self,
                           G_CONNECT_SWAPPED);

  g_signal_connect_object (widget,
                           "child-notify::title",
                           G_CALLBACK (pnl_tab_strip_child_title_changed),
                           self,
                           G_CONNECT_SWAPPED);

  gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (tab));

  g_object_bind_property (widget, "visible", tab, "visible", G_BINDING_SYNC_CREATE);

  pnl_tab_strip_child_title_changed (self, NULL, widget);
  pnl_tab_strip_stack_notify_visible_child (self, NULL, stack);
}
Beispiel #25
0
static void
on_position_updated (GtkWidget        *widget,
                     GParamSpec       *pspec,
                     GtkStackSwitcher *self)
{
  GtkWidget *button;
  gint position;

  button = g_hash_table_lookup (self->priv->buttons, widget);

  gtk_container_child_get (GTK_CONTAINER (self->priv->stack), widget,
                           "position", &position,
                           NULL);

  gtk_box_reorder_child (GTK_BOX (self), button, position);
}
Beispiel #26
0
static gchar *
ev_sidebar_get_visible_icon_name (EvSidebar *ev_sidebar)
{
	GtkStack *stack;
	GtkWidget *widget;
	gchar *icon_name;
	EvSidebarPrivate *priv = GET_PRIVATE (ev_sidebar);

	stack = GTK_STACK (priv->stack);
	widget = gtk_stack_get_visible_child (stack);
	gtk_container_child_get (GTK_CONTAINER (stack), widget,
				 "icon-name", &icon_name,
				 NULL);

	return icon_name;
}
Beispiel #27
0
/* Outputs source to add a child widget to a GtkFixed. */
static void
gb_fixed_write_add_child_source (GtkWidget * parent,
				  const gchar *parent_name,
				  GtkWidget *child,
				  GbWidgetWriteSourceData * data)
{
  gint x, y;

  gtk_container_child_get (GTK_CONTAINER (parent), child,
			   "x", &x,
			   "y", &y,
			   NULL);
  source_add (data,
	      "  gtk_fixed_put (GTK_FIXED (%s), %s, %i, %i);\n",
	      parent_name, data->wname, x, y);
}
static gboolean
carrick_list_drag_drop (GtkWidget      *widget,
                        GdkDragContext *context,
                        gint            x,
                        gint            y,
                        guint           time,
                        CarrickList    *list)
{
  CarrickListPrivate *priv = list->priv;

  gtk_container_child_get (GTK_CONTAINER (priv->box),
                           widget,
                           "position", &priv->drop_position,
                           NULL);

  gtk_drag_finish (context, TRUE, TRUE, time);
  return TRUE;
}
static void _move_close_button_for(DeepinWorkspaceOverview* self,
        MetaDeepinClonedWidget* cloned)
{
    GtkAllocation alloc;
    gtk_widget_get_allocation(GTK_WIDGET(cloned), &alloc);

    gint x = 0, y = 0;
    gtk_container_child_get(GTK_CONTAINER(self), GTK_WIDGET(cloned),
            "x", &x, "y", &y, NULL);

    gdouble sx = 1.0;
    meta_deepin_cloned_widget_get_scale(cloned, &sx, NULL);

    deepin_fixed_move(DEEPIN_FIXED(self), self->priv->close_button,
            x + alloc.width * sx /2,
            y - alloc.height * sx /2,
            FALSE);
}
Beispiel #30
0
/** This function finds the size of a GtkGrid and saves it to
 *  the data structure.
 *
 *  @internal
 *
 *  @param widget A pointer to the widget to move.
 *
 *  @param data A pointer to a data structure passed in by the caller.
 *  This data structure contains pointers to the old and new grids
 *  plus the row offset into the new grid.
 */
static void
gnc_prefs_get_grid_size (GtkWidget *child, gpointer data)
{
    struct copy_data *copydata = data;
    gint top, left, height, width;

    gtk_container_child_get(GTK_CONTAINER(copydata->grid_to), child,
                            "left-attach", &left,
                            "top-attach", &top,
                            "height", &height,
                            "width", &width,
                            NULL);

    if (left + width >= copydata->cols)
        copydata->cols = left + width;

    if (top + height >= copydata->rows)
        copydata->rows = top + height;
}