Exemplo n.º 1
0
/**
 * gtk_radio_menu_item_new_from_widget:
 * @group: An existing #GtkRadioMenuItem
 * 
 * Creates a new #GtkRadioMenuItem adding it to the same group as @group.
 * 
 * Return value: The new #GtkRadioMenuItem
 * 
 * Since: 2.4
 **/
GtkWidget *
gtk_radio_menu_item_new_from_widget (GtkRadioMenuItem *group)
{
  GSList *list = NULL;
  
  g_return_val_if_fail (GTK_IS_RADIO_MENU_ITEM (group), NULL);

  if (group)
    list = gtk_radio_menu_item_get_group (group);
  
  return gtk_radio_menu_item_new (list);
}
Exemplo n.º 2
0
/* {EV_RADIO_MENU_ITEM_IMP}.initialize_menu_item */
void F1173_16490 (EIF_REFERENCE Current)
{
	GTCX
	EIF_POINTER tp1;
	RTLD;
	
	RTLI(1);
	RTLR(0,Current);
	
	RTGC;
	tp1 = (EIF_POINTER) NULL;
	tp1 = (EIF_POINTER) gtk_radio_menu_item_new((GSList*) tp1);
	F1079_14134(Current, tp1);
	RTLE;
}
Exemplo n.º 3
0
GtkWidget*
gtk_radio_menu_item_new_with_label (GSList *group,
				    const gchar *label)
{
  GtkWidget *radio_menu_item;
  GtkWidget *accel_label;

  radio_menu_item = gtk_radio_menu_item_new (group);
  accel_label = gtk_accel_label_new (label);
  gtk_misc_set_alignment (GTK_MISC (accel_label), 0.0, 0.5);
  gtk_container_add (GTK_CONTAINER (radio_menu_item), accel_label);
  gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (accel_label), radio_menu_item);
  gtk_widget_show (accel_label);

  return radio_menu_item;
}
Exemplo n.º 4
0
static VALUE
rmitem_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE arg1, arg2, arg3;
    GtkWidget *widget;
    GSList *list = NULL;
    const gchar *label = NULL;
    const gchar *mnemonic = NULL;
    
    if (rb_scan_args(argc, argv, "03", &arg1, &arg2, &arg3) > 0 &&
        TYPE(arg1) == T_STRING) {
        if (NIL_P(arg2) || RVAL2CBOOL(arg2))
            mnemonic = RVAL2CSTR(arg1);
        else
            label = RVAL2CSTR(arg1);
    } else {
        if (!NIL_P(arg2)) {
            if (NIL_P(arg3) || RVAL2CBOOL(arg3))
                mnemonic = RVAL2CSTR(arg2);
            else
                label = RVAL2CSTR(arg2);
        }

        if (rb_obj_is_kind_of(arg1, GTYPE2CLASS(GTK_TYPE_RADIO_MENU_ITEM)))
            list = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(RVAL2GOBJ(arg1)));
        else if (TYPE(arg1) == T_ARRAY)
            /* TODO: This might leak. */
            list = RVAL2GTKRADIOMENUITEMGSLIST(arg1);
        else if (!NIL_P(arg1))
            rb_raise(rb_eArgError, "invalid argument %s (expect Array or Gtk::RadioMenuItem)", 
                     rb_class2name(CLASS_OF(arg1)));
    }

    if (label != NULL)
        widget = gtk_radio_menu_item_new_with_label(list, label);
    else if (mnemonic != NULL)
        widget = gtk_radio_menu_item_new_with_mnemonic(list, mnemonic);
    else
        widget = gtk_radio_menu_item_new(list);

    RBGTK_INITIALIZE(self, widget);

    return Qnil;
}
Exemplo n.º 5
0
static void pama_source_output_widget_source_button_clicked(GtkButton *button, PamaSourceOutputWidget *widget)
{
	PamaSourceOutputWidgetPrivate *priv = PAMA_SOURCE_OUTPUT_WIDGET_GET_PRIVATE(widget);
	GtkWidget *item, *last = NULL;
	GtkWidget *label;
	GSList *sources, *iter;
	PamaPulseSource *source, *current_source;
	PamaPulseSink *monitored_sink;
	gchar *source_name, *hostname;
	gboolean network;
	gchar *text;

	if (!priv->source_menu)
	{
		priv->source_menu = gtk_menu_new();
		g_object_ref_sink(priv->source_menu);
		g_signal_connect(gtk_widget_get_toplevel(priv->source_menu), "hide", G_CALLBACK(pama_source_output_widget_source_menu_hidden), widget);

		sources = g_slist_copy(pama_pulse_context_get_sources(priv->context));
		sources = g_slist_sort(sources, _source_menu_sort_function);

		g_object_get(priv->source_output, "source", &current_source, NULL);

		for (iter = sources; iter; iter = iter->next)
		{
			source = PAMA_PULSE_SOURCE(iter->data);
			g_object_get(source, 
			             "description", &source_name, 
			             "hostname",    &hostname,
			             "network",     &network,
			             NULL);
			monitored_sink = pama_pulse_source_get_monitored_sink(source);
			if (monitored_sink)
			{
				g_free(source_name);
				g_free(hostname);

				g_object_get(monitored_sink, 
		 		            "description", &text,
		 		            "hostname",    &hostname,
		  		            "network",     &network,
				             NULL);

				source_name = g_markup_printf_escaped(_("Monitor of %s"), text);
				g_free(text);
			}

			if (network)
				text = g_markup_printf_escaped("<b>%s</b> (on %s)", source_name, hostname);
			else
				text = g_markup_printf_escaped("<b>%s</b>", source_name);

			label = g_object_new(GTK_TYPE_LABEL,
			                     "label", text,
			                     "use-markup", TRUE,
			                     "xalign", 0.0,
			                     NULL);

			if (last)
				item = gtk_radio_menu_item_new_from_widget(GTK_RADIO_MENU_ITEM(last));
			else
				item = gtk_radio_menu_item_new(NULL);

			gtk_container_add(GTK_CONTAINER(item), label);

			g_object_set(item,
			             "active", (current_source == source),
			             "user-data", source,
			             NULL);
			last = item;
			g_free(source_name);
			g_free(hostname);
			g_free(text);

			g_signal_connect(item, "toggled", G_CALLBACK(pama_source_output_widget_source_menu_item_toggled), widget);
			gtk_menu_shell_append(GTK_MENU_SHELL(priv->source_menu), item);
			gtk_widget_show_all(item);
		}

		g_slist_free(sources);
		g_object_unref(current_source);

		gtk_menu_popup(GTK_MENU(priv->source_menu), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time());
	}
}