Esempio n. 1
0
/**
 * gtk_radio_tool_button_get_group:
 * @button: a #GtkRadioToolButton
 *
 * Returns the radio button group @button belongs to.
 *
 * Returns: (transfer none) (element-type GtkRadioButton): The group @button belongs to.
 *
 * Since: 2.4
 */
GSList *
gtk_radio_tool_button_get_group (GtkRadioToolButton *button)
{
  g_return_val_if_fail (GTK_IS_RADIO_TOOL_BUTTON (button), NULL);

  return gtk_radio_button_get_group (get_radio_button (button));
}
Esempio n. 2
0
/**
 * gtk_radio_tool_button_set_group:
 * @button: a #GtkRadioToolButton
 * @group: (element-type GtkRadioButton) (allow-none): an existing radio button group, or %NULL
 * 
 * Adds @button to @group, removing it from the group it belonged to before.
 * 
 * Since: 2.4
 **/
void
gtk_radio_tool_button_set_group (GtkRadioToolButton *button,
				 GSList             *group)
{
  g_return_if_fail (GTK_IS_RADIO_TOOL_BUTTON (button));

  gtk_radio_button_set_group (get_radio_button (button), group);
}
Esempio n. 3
0
static void
find_parents_group (GtkWidget * widget, GSList ** group)
{
  /* If a group has already been found, return. */
  if (*group)
    return;

  if (GTK_IS_RADIO_TOOL_BUTTON (widget))
    *group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (widget));
}
Esempio n. 4
0
GSList* wxToolBar::GetRadioGroup(size_t pos)
{
    GSList* radioGroup = NULL;
    GtkToolItem* item = NULL;
    if (pos > 0)
    {
        item = gtk_toolbar_get_nth_item(m_toolbar, int(pos) - 1);
        if (!GTK_IS_RADIO_TOOL_BUTTON(item))
            item = NULL;
    }
    if (item == NULL && pos < m_tools.size())
    {
        item = gtk_toolbar_get_nth_item(m_toolbar, int(pos));
        if (!GTK_IS_RADIO_TOOL_BUTTON(item))
            item = NULL;
    }
    if (item)
        radioGroup = gtk_radio_tool_button_get_group((GtkRadioToolButton*)item);
    return radioGroup;
}
Esempio n. 5
0
/**
 * gtk_radio_tool_button_new_from_widget: (constructor)
 * @group: (allow-none): An existing #GtkRadioToolButton, or %NULL
 *
 * Creates a new #GtkRadioToolButton adding it to the same group as @gruup
 *
 * Returns: (transfer none): The new #GtkRadioToolButton
 *
 * Since: 2.4
 **/
GtkToolItem *
gtk_radio_tool_button_new_from_widget (GtkRadioToolButton *group)
{
  GSList *list = NULL;
  
  g_return_val_if_fail (group == NULL || GTK_IS_RADIO_TOOL_BUTTON (group), NULL);

  if (group != NULL)
    list = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (group));
  
  return gtk_radio_tool_button_new (list);
}
Esempio n. 6
0
/**
 * gtk_radio_tool_button_new_with_stock_from_widget: (constructor)
 * @group: (allow-none): An existing #GtkRadioToolButton.
 * @stock_id: the name of a stock item
 *
 * Creates a new #GtkRadioToolButton adding it to the same group as @group.
 * The new #GtkRadioToolButton will contain an icon and label from the
 * stock item indicated by @stock_id.
 *
 * Return value: (transfer none): A new #GtkRadioToolButton
 *
 * Since: 2.4
 **/
GtkToolItem *
gtk_radio_tool_button_new_with_stock_from_widget (GtkRadioToolButton *group,
						  const gchar        *stock_id)
{
  GSList *list = NULL;
  
  g_return_val_if_fail (group == NULL || GTK_IS_RADIO_TOOL_BUTTON (group), NULL);

  if (group != NULL)
    list = gtk_radio_tool_button_get_group (group);
  
  return gtk_radio_tool_button_new_from_stock (list, stock_id);
}
Esempio n. 7
0
static void
find_radio_group (GtkWidget *widget, GladeFindGroupData *find_data)
{
  if (find_data->found_widget)
    return;

  if (GTK_IS_RADIO_TOOL_BUTTON (widget) && GB_IS_GB_WIDGET (widget))
    {
      if (gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (widget)) == find_data->group)
	{
	  find_data->found_widget = widget;
	}
    }
}
Esempio n. 8
0
static void
find_group_widget (GtkWidget *widget, GladeFindGroupWidgetData *find_data)
{
  if (find_data->found_widget)
    return;

  if (GTK_IS_RADIO_TOOL_BUTTON (widget) && GB_IS_GB_WIDGET (widget))
    {
      if (!strcmp (gtk_widget_get_name (widget), find_data->name))
	{
#if 0
	  g_print ("Found widget: %s\n", find_data->name);
#endif
	  find_data->found_widget = widget;
	}
    }
}
Esempio n. 9
0
/**
 * gtk_radio_tool_button_new_with_stock_from_widget: (constructor)
 * @group: (allow-none): An existing #GtkRadioToolButton.
 * @stock_id: the name of a stock item
 *
 * Creates a new #GtkRadioToolButton adding it to the same group as @group.
 * The new #GtkRadioToolButton will contain an icon and label from the
 * stock item indicated by @stock_id.
 *
 * Returns: (transfer none): A new #GtkRadioToolButton
 *
 * Since: 2.4
 *
 * Deprecated: 3.10: gtk_radio_tool_button_new_from_widget
 **/
GtkToolItem *
gtk_radio_tool_button_new_with_stock_from_widget (GtkRadioToolButton *group,
						  const gchar        *stock_id)
{
  GSList *list = NULL;
  GtkToolItem *item;

  g_return_val_if_fail (group == NULL || GTK_IS_RADIO_TOOL_BUTTON (group), NULL);

  if (group != NULL)
    list = gtk_radio_tool_button_get_group (group);

  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
  item = gtk_radio_tool_button_new_from_stock (list, stock_id);
  G_GNUC_END_IGNORE_DEPRECATIONS;

  return item;
}
Esempio n. 10
0
/* Note that this must walk the widget tree in exactly the same way that we
   save the widgets, so we know which widget in the group will be the first
   output. */
static void
get_radio_button_groups (GtkWidget * widget, GladeFindGroupsData *find_data)
{
  if (GTK_IS_RADIO_TOOL_BUTTON (widget) && GB_IS_GB_WIDGET (widget))
    {
      GSList *group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (widget));

      /* See if we've already found a widget in this group. */
      if (!g_list_find (find_data->groups_found, group))
	{
	  const char *name = gtk_widget_get_name (GTK_WIDGET (widget));

	  /* Remember that we've already seen this group. */
	  find_data->groups_found = g_list_prepend (find_data->groups_found,
						    group);

	  /* Add the widget's name to the list. */
	  find_data->group_names = g_list_insert_sorted (find_data->group_names, (char*)name, (GCompareFunc) g_utf8_collate);
	}
    }
}
Esempio n. 11
0
static gboolean
gtk_toggle_tool_button_create_menu_proxy (GtkToolItem *item)
{
  GtkToolButton *tool_button = GTK_TOOL_BUTTON (item);
  GtkToggleToolButton *toggle_tool_button = GTK_TOGGLE_TOOL_BUTTON (item);
  GtkWidget *menu_item = NULL;
  GtkStockItem stock_item;
  gboolean use_mnemonic = TRUE;
  const char *label;
  GtkWidget *label_widget;
  const gchar *label_text;
  const gchar *stock_id;

  if (_gtk_tool_item_create_menu_proxy (item))
    return TRUE;

  label_widget = gtk_tool_button_get_label_widget (tool_button);
  label_text = gtk_tool_button_get_label (tool_button);
  stock_id = gtk_tool_button_get_stock_id (tool_button);

  if (GTK_IS_LABEL (label_widget))
    {
      label = gtk_label_get_label (GTK_LABEL (label_widget));
      use_mnemonic = gtk_label_get_use_underline (GTK_LABEL (label_widget));
    }
  else if (label_text)
    {
      label = label_text;
      use_mnemonic = gtk_tool_button_get_use_underline (tool_button);
    }
  else if (stock_id && gtk_stock_lookup (stock_id, &stock_item))
    {
      label = stock_item.label;
    }
  else
    {
      label = "";
    }
  
  if (use_mnemonic)
    menu_item = gtk_check_menu_item_new_with_mnemonic (label);
  else
    menu_item = gtk_check_menu_item_new_with_label (label);

  gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
				  toggle_tool_button->priv->active);

  if (GTK_IS_RADIO_TOOL_BUTTON (toggle_tool_button))
    {
      gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (menu_item),
					     TRUE);
    }

  g_signal_connect_closure_by_id (menu_item,
				  g_signal_lookup ("activate", G_OBJECT_TYPE (menu_item)), 0,
				  g_cclosure_new_object (G_CALLBACK (menu_item_activated),
							 G_OBJECT (toggle_tool_button)),
				  FALSE);

  gtk_tool_item_set_proxy_menu_item (item, MENU_ID, menu_item);
  
  return TRUE;
}