Ejemplo n.º 1
0
static GtkWidget * create_pixmap_toggle_button(visualizer_t * w,
                                               const char * filename,
                                               const char * tooltip,
                                               guint * id)
  {
  GtkWidget * button;
  GtkWidget * image;
  char * path;
  path = bg_search_file_read("icons", filename);
  if(path)
    {
    image = gtk_image_new_from_file(path);
    free(path);
    }
  else
    image = gtk_image_new();

  gtk_widget_show(image);
  button = gtk_toggle_button_new();
  gtk_container_add(GTK_CONTAINER(button), image);

  *id = g_signal_connect(G_OBJECT(button), "toggled",
                         G_CALLBACK(button_callback), w);
  
  gtk_widget_show(button);
  
  bg_gtk_tooltips_set_tip(button, tooltip, PACKAGE);
  
  return button;
  }
Ejemplo n.º 2
0
GtkWidget* new_button_with_icon(GtkIconTheme *theme,
                                const gchar *icon_name,
                                gboolean toolbar,
                                gboolean toggle,
                                const gchar *description)
{
        GtkWidget *button;
        GtkWidget *image;
        gint size;

        size = toolbar ? GTK_ICON_SIZE_SMALL_TOOLBAR : GTK_ICON_SIZE_DIALOG;
        image = gtk_image_new_from_icon_name(icon_name, size);
        /* Create the button */
        if (toggle)
                button = gtk_toggle_button_new();
        else
                button = gtk_button_new();
        gtk_widget_set_can_focus(button, FALSE);
        if (!toolbar)
                gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
        gtk_container_add(GTK_CONTAINER(button), image);

        /* Set a helpful tooltip for toolbar buttons */
        if (toolbar)
                gtk_widget_set_tooltip_text(button, description);
        return button;
}
Ejemplo n.º 3
0
// helper to create a dropdown menu item
void wxToolBarTool::CreateDropDown()
{
    gtk_tool_item_set_homogeneous(m_item, false);
    GtkWidget* box;
    GtkWidget* arrow;
    if (GetToolBar()->HasFlag(wxTB_LEFT | wxTB_RIGHT))
    {
        box = gtk_vbox_new(false, 0);
        arrow = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
    }
    else
    {
        box = gtk_hbox_new(false, 0);
        arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE);
    }
    GtkWidget* tool_button = GTK_BIN(m_item)->child;
    gtk_widget_reparent(tool_button, box);
    GtkWidget* arrow_button = gtk_toggle_button_new();
    gtk_button_set_relief(GTK_BUTTON(arrow_button),
        gtk_tool_item_get_relief_style(GTK_TOOL_ITEM(m_item)));
    gtk_container_add(GTK_CONTAINER(arrow_button), arrow);
    gtk_container_add(GTK_CONTAINER(box), arrow_button);
    gtk_widget_show_all(box);
    gtk_container_add(GTK_CONTAINER(m_item), box);

    g_signal_connect(arrow_button, "toggled", G_CALLBACK(arrow_toggled), this);
    g_signal_connect(arrow_button, "button_press_event",
        G_CALLBACK(arrow_button_press_event), this);
}
Ejemplo n.º 4
0
static GtkToggleButton* gw_popupbutton_new (int font_size, GwResultPopupData *rpdata)
{
    //Sanity check
    g_assert (rpdata != NULL);

    //Declarations
    GtkToggleButton *button;
    gchar *markup;
    GtkLabel *label;

    //Initializations
    button = GTK_TOGGLE_BUTTON (gtk_toggle_button_new ());
    g_signal_connect (G_OBJECT (button), "toggled", G_CALLBACK (_resultpopup_show_cb), rpdata);
    g_signal_connect_swapped (G_OBJECT (button), "destroy", G_CALLBACK (gw_resultpopupdata_free), rpdata);
    label = GTK_LABEL (gtk_label_new (NULL));
    markup = g_markup_printf_escaped ("<span size=\"%d\">▼</span>", font_size * PANGO_SCALE * 3 / 4);
    if (markup != NULL)
    {
      gtk_label_set_markup (label, markup);
      g_free (markup);
    }

    gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
    gtk_container_add (GTK_CONTAINER (button), GTK_WIDGET (label));
    gtk_widget_show (GTK_WIDGET (label));

    return button;
}
static void launcher_navigator_applet_init(LauncherNavigatorApplet *applet)
{
    LauncherNavigatorAppletPrivate *info = LAUNCHER_NAVIGATOR_APPLET_GET_PRIVATE(applet);

    ULOG_OPEN("launcher-statusbar-applet");

    g_return_if_fail(info);

    info->icon = gtk_image_new_from_pixbuf(NULL);
    info->button = gtk_toggle_button_new();

    set_applet_icon("qgn_grid_tasknavigator_others", info);
    
    gtk_widget_set_name (info->button, "hildon-navigator-button-one");

    gtk_container_add(GTK_CONTAINER(info->button),
                      GTK_WIDGET(info->icon));

    gtk_container_add(GTK_CONTAINER(applet), info->button);

    /* Signal for icon (button) */
    g_signal_connect(G_OBJECT(info->button), "button-press-event",
                     G_CALLBACK(applet_icon_pressed), info);

    /* Initialize osso */
    info->osso = osso_initialize("org.telescope.LauncherApplet", "0.1", TRUE, NULL);
    if (!info->osso)
        ULOG_WARN("%s: error while initializing osso\n", __FUNCTION__);

    gtk_widget_show_all(GTK_WIDGET(applet));
}
Ejemplo n.º 6
0
GtkWidget*sc_image_toggle_button_new_by_size(const guint8* data,int siz)
{


    GtkWidget*image;
    GtkWidget*button=gtk_toggle_button_new();

    GdkPixbuf*pxf=gdk_pixbuf_new_from_inline(-1,data,FALSE,NULL);
    GdkPixbuf*real_pxf;


    if(!pxf) {
        image=gtk_image_new_from_icon_name("image-x-generic",GTK_ICON_SIZE_BUTTON);

    } else {
        real_pxf=gdk_pixbuf_scale_simple(pxf,siz,siz,GDK_INTERP_HYPER);
        g_object_unref(pxf);
        image=gtk_image_new_from_pixbuf(real_pxf);
        g_object_set(image,"pixel-size",GTK_IMAGE_PIXBUF,NULL);
    }
    g_object_unref(real_pxf);

    gtk_button_set_image(GTK_BUTTON(button),image);
    gtk_button_set_always_show_image(GTK_BUTTON(button),TRUE);

    sc_button_set_style(GTK_BUTTON(button));


    return button;


}
Ejemplo n.º 7
0
static void
thunar_location_entry_init (ThunarLocationEntry *location_entry)
{
  GtkSizeGroup *size_group;
  GtkWidget    *button;
  GtkWidget    *arrow;

  gtk_box_set_spacing (GTK_BOX (location_entry), 0);
  gtk_container_set_border_width (GTK_CONTAINER (location_entry), 4);

  location_entry->path_entry = thunar_path_entry_new ();
  exo_binding_new (G_OBJECT (location_entry), "current-directory", G_OBJECT (location_entry->path_entry), "current-file");
  g_signal_connect_after (G_OBJECT (location_entry->path_entry), "activate", G_CALLBACK (thunar_location_entry_activate), location_entry);
  gtk_box_pack_start (GTK_BOX (location_entry), location_entry->path_entry, TRUE, TRUE, 0);
  gtk_widget_show (location_entry->path_entry);

  button = gtk_toggle_button_new ();
  g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (thunar_location_entry_button_clicked), location_entry);
  g_signal_connect (G_OBJECT (button), "pressed", G_CALLBACK (thunar_location_entry_button_clicked), location_entry);
  gtk_box_pack_start (GTK_BOX (location_entry), button, FALSE, FALSE, 0);
  gtk_widget_show (button);

  arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
  gtk_container_add (GTK_CONTAINER (button), arrow);
  gtk_widget_show (arrow);

  /* make sure the entry and the button request the same height */
  size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
  gtk_size_group_add_widget (size_group, location_entry->path_entry);
  gtk_size_group_add_widget (size_group, button);
  g_object_unref (G_OBJECT (size_group));
}
Ejemplo n.º 8
0
static GtkWidget *
toolbar_create_toolbutton (NemoToolbar *self,
                gboolean create_toggle,
                const gchar *name)
{
    GtkWidget *button;
    GtkWidget *image;
    GtkAction *action;

    if (create_toggle)
    {
        button = gtk_toggle_button_new ();
    } else {
        button = gtk_button_new ();
    }

    image = gtk_image_new ();

    gtk_button_set_image (GTK_BUTTON (button), image);
    action = gtk_action_group_get_action (self->priv->action_group, name);
    gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), action);
    gtk_button_set_label (GTK_BUTTON (button), NULL);
    gtk_widget_set_tooltip_text (button, gtk_action_get_tooltip (action));

    return button;
}
Ejemplo n.º 9
0
bool wxBitmapToggleButton::Create(wxWindow *parent, wxWindowID id,
                            const wxBitmap &label, const wxPoint &pos,
                            const wxSize &size, long style,
                            const wxValidator& validator,
                            const wxString &name)
{
    if (!PreCreation(parent, pos, size) ||
       !CreateBase(parent, id, pos, size, style, validator, name ))
    {
        wxFAIL_MSG(wxT("wxBitmapToggleButton creation failed"));
        return false;
    }

    // Create the gtk widget.
    m_widget = gtk_toggle_button_new();
    g_object_ref(m_widget);

    if (style & wxNO_BORDER)
        gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE );

    m_bitmap = label;
    OnSetBitmap();

    g_signal_connect (m_widget, "clicked",
                      G_CALLBACK (gtk_togglebutton_clicked_callback),
                      this);

    m_parent->DoAddChild(this);

    PostCreation(size);

    return true;
}
Ejemplo n.º 10
0
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);
    }
}
Ejemplo n.º 11
0
static void add_button (MMConversation *mmconv)
{
	PurpleConversation *conv = mmconv->conv;
	
	GtkWidget *button, *image, *sep;
	gchar *file_path;

	button = gtk_toggle_button_new();
	gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);

	g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(music_button_toggled), mmconv);

	file_path = g_build_filename(DATADIR, "pixmaps", "purple", "buttons",
										"music.png", NULL);
	image = gtk_image_new_from_file(file_path);
	g_free(file_path);

	gtk_container_add((GtkContainer *)button, image);
	
	sep = gtk_vseparator_new();
	
	mmconv->seperator = sep;
	mmconv->button = button;
	
	gtk_widget_show(sep);
	gtk_widget_show(image);
	gtk_widget_show(button);
	
	gtk_box_pack_start(GTK_BOX(PIDGIN_CONVERSATION(conv)->toolbar), sep, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(PIDGIN_CONVERSATION(conv)->toolbar), button, FALSE, FALSE, 0);
}
Ejemplo n.º 12
0
static GtkWidget *
togglebutton_new(GladeXML *xml, GladeWidgetInfo *info)
{
	GtkWidget *button;
	GList *tmp;
	char *string = NULL;
	gboolean active = FALSE;

	for (tmp = info->attributes; tmp; tmp = tmp->next) {
		GladeAttribute *attr = tmp->data;

		if (!strcmp(attr->name, "label"))
			string = attr->value;
		else if (!strcmp(attr->name, "active"))
			active = attr->value[0] == 'T';
	}
	if (string != NULL) {
		guint key;
		
		button = gtk_toggle_button_new_with_label("");
		key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(button)->child),
					    string[0] ? _(string) : "");
		if (key)
			gtk_widget_add_accelerator(button, "clicked",
						   glade_xml_ensure_accel(xml),
						   key, GDK_MOD1_MASK, 0);
	} else
		button = gtk_toggle_button_new();
	gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), active);
	return button;
}
Ejemplo n.º 13
0
static VALUE
tbtn_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE label, use_underline;
    GtkWidget *widget;

    if (rb_scan_args(argc, argv, "02", &label, &use_underline) > 0) {
        if (TYPE(label) == T_STRING){
            if (NIL_P(use_underline) || RVAL2CBOOL(use_underline)){
                widget = gtk_toggle_button_new_with_mnemonic(RVAL2CSTR(label));
            } else {
                widget = gtk_toggle_button_new_with_label(RVAL2CSTR(label));
            }
        } else if (TYPE(label) == T_SYMBOL){
            widget = gtk_toggle_button_new_with_label(rb_id2name(SYM2ID(label)));
            gtk_button_set_use_stock(GTK_BUTTON(widget), TRUE);
        } else {
            rb_raise(rb_eArgError, "invalid argument %s (expect Symbol(Gtk::Stock constants) or String)", 
                     rb_class2name(CLASS_OF(label)));
        }
    } else {
	widget = gtk_toggle_button_new();
    }

    RBGTK_INITIALIZE(self, widget);
    return Qnil;
}
Ejemplo n.º 14
0
static void
gb_folder_tb_widget_rebuild_impl (GbTbWidget *w)
{
	GbFolderTbWidgetPrivate *p = GB_FOLDER_TB_WIDGET (w)->priv;
	GbFolder *folder = GB_FOLDER (gb_tb_widget_get_bookmark (w));

	g_return_if_fail (GB_IS_FOLDER (folder));

	if (!p->mainwid)
	{
		p->mainwid = gtk_toggle_button_new ();
		gtk_widget_show (p->mainwid);
		gtk_box_pack_start (GTK_BOX (w), p->mainwid, FALSE, FALSE, 0);

		g_signal_connect (p->mainwid, "button-press-event", 
				  G_CALLBACK (gb_folder_tb_widget_button_press_event_cb), w);
		g_signal_connect (p->mainwid, "toggled", 
				  G_CALLBACK (gb_folder_tb_widget_toggled_cb), w);
	}

	if (gtk_bin_get_child (GTK_BIN (p->mainwid)))
	{
		gtk_container_remove (GTK_CONTAINER (p->mainwid),
				      gtk_bin_get_child (GTK_BIN (p->mainwid)));
	}
	
	gb_widgets_fill_tb_item (GTK_CONTAINER (p->mainwid), GB_BOOKMARK (folder), NULL);

	gtk_button_set_relief (GTK_BUTTON (p->mainwid), GTK_RELIEF_NONE);
	GTK_WIDGET_SET_FLAGS (GTK_BUTTON (p->mainwid), GTK_CAN_FOCUS);

	gb_tb_widget_setup_context_menu (w, p->mainwid);
	gb_bookmark_dnd_drag_dest_set (GTK_BIN (p->mainwid)->child, GB_BOOKMARK (folder));
}
Ejemplo n.º 15
0
// helper to create a dropdown menu item
void wxToolBarTool::CreateDropDown()
{
    gtk_tool_item_set_homogeneous(m_item, false);
    GtkOrientation orient = GTK_ORIENTATION_HORIZONTAL;
    GtkArrowType arrowType = GTK_ARROW_DOWN;
    if (GetToolBar()->HasFlag(wxTB_LEFT | wxTB_RIGHT))
    {
        orient = GTK_ORIENTATION_VERTICAL;
        arrowType = GTK_ARROW_RIGHT;
    }
    GtkWidget* box = gtk_box_new(orient, 0);
    GtkWidget* arrow = gtk_arrow_new(arrowType, GTK_SHADOW_NONE);
    GtkWidget* tool_button = gtk_bin_get_child(GTK_BIN(m_item));
    g_object_ref(tool_button);
    gtk_container_remove(GTK_CONTAINER(m_item), tool_button);
    gtk_container_add(GTK_CONTAINER(box), tool_button);
    g_object_unref(tool_button);
    GtkWidget* arrow_button = gtk_toggle_button_new();
    gtk_button_set_relief(GTK_BUTTON(arrow_button),
        gtk_tool_item_get_relief_style(GTK_TOOL_ITEM(m_item)));
    gtk_container_add(GTK_CONTAINER(arrow_button), arrow);
    gtk_container_add(GTK_CONTAINER(box), arrow_button);
    gtk_widget_show_all(box);
    gtk_container_add(GTK_CONTAINER(m_item), box);

    g_signal_connect(arrow_button, "toggled", G_CALLBACK(arrow_toggled), this);
    g_signal_connect(arrow_button, "button_press_event",
        G_CALLBACK(arrow_button_press_event), this);
}
Ejemplo n.º 16
0
void sux_init(SuxModule *sm, gchar *args)
{
        GtkWidget *button, *image;
        WnckScreen *screen;
        ShowDesktop *sd;

        sd = g_new0(ShowDesktop, 1);
        
        button = gtk_toggle_button_new();
        gtk_widget_show(button);
        
        image = gtk_image_new_from_file_scaled(IMG_PREFIX "showdesktop.png", 24, 24);
        gtk_widget_show(image);
        gtk_container_add(GTK_CONTAINER(button), image);

        screen = wnck_screen_get_default();
        g_object_set_data(G_OBJECT(screen), "sd", sd);

	sd->tips = gtk_tooltips_new();
        sd->screen = screen;
        sd->is_showing_desktop = wnck_screen_get_showing_desktop(sd->screen);
        sd->button = button;

        update_tooltip(sd);
        
        g_signal_connect(G_OBJECT(button), "toggled",
                         G_CALLBACK(toggle_show_desktop), sd);
        g_signal_connect(G_OBJECT(screen), "showing_desktop_changed",
                         G_CALLBACK(show_desktop_changed), sd);
	
	sm->widget = sd->button;
}
Ejemplo n.º 17
0
Archivo: utils.cpp Proyecto: dyne/MuSE
GtkWidget *createpixmap(GtkWidget *w, GtkWidget *but, 
		const gchar **pippo, const gchar *tip, bool istoggled)
{
	/* create and return button with pixmap */

	GtkWidget *image;
	GtkTooltips *tooltip;
	GdkPixmap *pixmap;
	GdkBitmap *mask;
	GtkStyle *style;

	style=gtk_widget_get_style(w);
	gtk_widget_realize(w);
	pixmap=gdk_pixmap_create_from_xpm_d(w->window, &mask, 
			&style->bg[GTK_STATE_NORMAL], (gchar **)pippo);
	image = gtk_image_new_from_pixmap(pixmap, mask);
	
	if(!istoggled)
		but=gtk_button_new();
	else
		but=gtk_toggle_button_new();

	gtk_container_add(GTK_CONTAINER(but), image);
	tooltip = gtk_tooltips_new();
	gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltip), but, tip, NULL);
	return but;
	
}
Ejemplo n.º 18
0
static GtkWidget *
gimp_text_style_editor_create_toggle (GimpTextStyleEditor *editor,
                                      GtkTextTag          *tag,
                                      const gchar         *stock_id,
                                      const gchar         *tooltip)
{
  GtkWidget *toggle;
  GtkWidget *image;

  toggle = gtk_toggle_button_new ();
  gtk_widget_set_can_focus (toggle, FALSE);
  gtk_box_pack_start (GTK_BOX (editor->lower_hbox), toggle, FALSE, FALSE, 0);
  gtk_widget_show (toggle);

  gimp_help_set_help_data (toggle, tooltip, NULL);

  editor->toggles = g_list_append (editor->toggles, toggle);
  g_object_set_data (G_OBJECT (toggle), "tag", tag);

  g_signal_connect (toggle, "toggled",
                    G_CALLBACK (gimp_text_style_editor_tag_toggled),
                    editor);

  image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
  gtk_container_add (GTK_CONTAINER (toggle), image);
  gtk_widget_show (image);

  return toggle;
}
Ejemplo n.º 19
0
GtkWidget* button_with_stock_image(gchar* mnemonic, gchar* stock, gboolean toggle)
{
	GtkWidget *button, *alignment, *hbox, *label, *image;

	if(toggle)
		button = gtk_toggle_button_new();
	else
		button = gtk_button_new();
	
	alignment = gtk_alignment_new(0.5, 0.5, 0, 0);
	gtk_container_add(GTK_CONTAINER(button), alignment);

	hbox = gtk_hbox_new(FALSE, 2);
	gtk_container_add(GTK_CONTAINER(alignment), hbox);

	image = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_SMALL_TOOLBAR);
	gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);

	label = gtk_label_new_with_mnemonic(mnemonic);
	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);

	gtk_widget_show_all(alignment);

	return button;
}
Ejemplo n.º 20
0
/***************************************************************
* ToggleRadioButtonNew関数                                     *
* ラジオアクションを設定したトグルボタンウィジェットを作成     *
* 引数                                                         *
* list			: ボタンリストの入ったGList                    *
*				  先頭のボタンはNULLの入ったlistを渡す         *
*				  g_list_freeしないこと                        *
* callback_func	: ボタンが有効状態になった時のコールバック関数 *
* callback_data	: コールバック関数に渡すデータ                 *
* 返り値                                                       *
*	ボタンウィジェット                                         *
***************************************************************/
GtkWidget* ToggleRadioButtonNew(
	GList** list,
	void (*callback_func)(GtkWidget* button, void* data),
	void* callback_data
)
{
	TOGGLE_RADIO_BUTTON_DATA *data;
	GtkWidget *button;
	GList *button_list;

	if(list == NULL)
	{
		return NULL;
	}
	else if(*list == NULL)
	{
		data = (TOGGLE_RADIO_BUTTON_DATA*)MEM_ALLOC_FUNC(sizeof(*data));
		(void)memset(data, 0, sizeof(*data));
		*list = data->button_list = g_list_alloc();
		(*list)->data = (gpointer)(button = gtk_toggle_button_new());
		g_object_set_data(G_OBJECT(button), "widget_data", data);
		(void)g_signal_connect_swapped(G_OBJECT(button), "destroy",
			G_CALLBACK(OnDestroyToggleRadioButton), data);
		data->callback_func = callback_func;
		data->callback_data = callback_data;
		(void)g_signal_connect(G_OBJECT(button), "toggled",
			G_CALLBACK(OnToggledToggleRadioButton), data);

		return button;
	}

	data = (TOGGLE_RADIO_BUTTON_DATA*)g_object_get_data(G_OBJECT((*list)->data), "widget_data");
	button_list = *list;
	while(button_list->next != NULL)
	{
		button_list = button_list->next;
	}
	(void)g_list_append(button_list, (gpointer)(button = gtk_toggle_button_new()));
	(void)g_signal_connect(G_OBJECT(button), "toggled",
		G_CALLBACK(OnToggledToggleRadioButton), data);

	return button;
}
Ejemplo n.º 21
0
//
// Create a toggle button with stock
//
static GtkWidget* qq_toggle_button_new_with_stock(const gchar *stock_id)
{
    GtkWidget *btn = gtk_toggle_button_new();
    if(stock_id != NULL){
        GtkWidget *img = gtk_image_new_from_stock(stock_id
                                    , GTK_ICON_SIZE_LARGE_TOOLBAR);
        gtk_button_set_image(GTK_BUTTON(btn), img);
    }
    return btn;
}
Ejemplo n.º 22
0
static gint
ensure_toggle_button_widget()
{
    if (!gParts->toggleButtonWidget) {
        gParts->toggleButtonWidget = gtk_toggle_button_new();
        setup_widget_prototype(gParts->toggleButtonWidget);
        /* toggle button must be set active to get the right style on hover. */
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gParts->toggleButtonWidget), TRUE);
  }
  return MOZ_GTK_SUCCESS;
}
Ejemplo n.º 23
0
static void
go_combo_box_init (GOComboBox *combo_box)
{
	GtkWidget *arrow;

	combo_box->priv = g_new0 (GOComboBoxPrivate, 1);
	combo_box->priv->updating_buttons = FALSE;

	combo_box->priv->arrow_button = gtk_toggle_button_new ();
	gtk_button_set_relief (GTK_BUTTON (combo_box->priv->arrow_button), GTK_RELIEF_NONE);
	gtk_widget_set_can_focus (combo_box->priv->arrow_button, FALSE);

	arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_IN);
	gtk_container_add (GTK_CONTAINER (combo_box->priv->arrow_button), arrow);
	gtk_box_pack_end (GTK_BOX (combo_box), combo_box->priv->arrow_button, FALSE, FALSE, 0);
	g_signal_connect_swapped (combo_box->priv->arrow_button,
		"button-press-event",
		G_CALLBACK (cb_arrow_pressed), combo_box);
	gtk_widget_show_all (combo_box->priv->arrow_button);

	/*
	 * prelight the display widget when mousing over the arrow.
	 */
	g_signal_connect (combo_box->priv->arrow_button, "state-changed",
			  G_CALLBACK (cb_state_change), combo_box);

	/*
	 * The pop-down container
	 */

	combo_box->priv->toplevel = gtk_window_new (GTK_WINDOW_POPUP);
	g_object_ref (combo_box->priv->toplevel);
	g_object_set (G_OBJECT (combo_box->priv->toplevel),
		      "type-hint", GDK_WINDOW_TYPE_HINT_COMBO,
		      NULL);

	combo_box->priv->popup = gtk_event_box_new ();
	gtk_container_add (GTK_CONTAINER (combo_box->priv->toplevel),
			   combo_box->priv->popup);
	gtk_widget_show (combo_box->priv->popup);

	combo_box->priv->torn_off = FALSE;
	combo_box->priv->tearoff_window = NULL;

	combo_box->priv->frame = gtk_frame_new (NULL);
	gtk_container_add (GTK_CONTAINER (combo_box->priv->popup),
			   combo_box->priv->frame);
	gtk_frame_set_shadow_type (GTK_FRAME (combo_box->priv->frame), GTK_SHADOW_OUT);

	g_signal_connect (combo_box->priv->toplevel, "button_press_event",
			  G_CALLBACK (go_combo_box_button_press), combo_box);
	g_signal_connect (combo_box->priv->toplevel, "key_press_event",
			  G_CALLBACK (cb_combo_keypress), combo_box);
}
Ejemplo n.º 24
0
static void
_adg_method_toggle_button_sensitivize(void)
{
    GtkToggleButton *button = (GtkToggleButton *) gtk_toggle_button_new();
    GtkWidget *widget = gtk_toggle_button_new();

    gtk_toggle_button_set_active(button, FALSE);
    adg_gtk_toggle_button_sensitivize(button, widget);
    g_assert_false(gtk_widget_get_sensitive(widget));

    gtk_toggle_button_set_active(button, TRUE);
    adg_gtk_toggle_button_sensitivize(button, widget);
    g_assert_true(gtk_widget_get_sensitive(widget));

    g_object_ref_sink(button);
    g_object_unref(button);

    g_object_ref_sink(widget);
    g_object_unref(widget);
}
Ejemplo n.º 25
0
GtkWidget *make_pixmap_toggle_button(struct mapwin *mw,char **xpmdata)
{
  GdkBitmap *mask=NULL;
  GdkPixmap *gpm = gdk_pixmap_create_from_xpm_d(mw->map->window,
						&mask,NULL,xpmdata);
  GtkWidget *gtpm = gtk_pixmap_new(gpm,mask);
  GtkWidget *but=gtk_toggle_button_new();
  gtk_container_add(GTK_CONTAINER(but),gtpm);
  gtk_widget_show(gtpm);
  return but;
}
Ejemplo n.º 26
0
static void
gtk_combo_button_init (GtkComboButton * combo_button)
{
  GtkWidget *event_box;
  GdkCursor *cursor;
  GtkWidget *widget;
  GtkWidget *arrow;

  widget=GTK_WIDGET(combo_button);

  GTK_BOX(widget)->homogeneous = FALSE;

  combo_button->button = gtk_button_new ();
  combo_button->arrow = gtk_toggle_button_new ();

  arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_IN);
  gtk_widget_show (arrow);
  gtk_container_add (GTK_CONTAINER (combo_button->arrow), arrow);

  gtk_box_pack_start (GTK_BOX (combo_button), combo_button->button, TRUE, TRUE, 0);
  gtk_box_pack_end (GTK_BOX (combo_button), combo_button->arrow, FALSE, FALSE, 0);

  gtk_widget_show (combo_button->button);
  gtk_widget_show (combo_button->arrow);

  gtk_signal_connect (GTK_OBJECT (combo_button->arrow), "toggled",
		      (GtkSignalFunc) gtk_combo_button_arrow_press, combo_button);

                       
  combo_button->popwin = gtk_window_new (GTK_WINDOW_POPUP);
  gtk_widget_ref (combo_button->popwin);
  gtk_window_set_resizable (GTK_WINDOW (combo_button->popwin), FALSE);
  gtk_window_set_policy (GTK_WINDOW (combo_button->popwin), 1, 1, 0);
  gtk_widget_set_events (combo_button->popwin, GDK_KEY_PRESS_MASK);
 
  event_box = gtk_event_box_new ();
  gtk_container_add (GTK_CONTAINER (combo_button->popwin), event_box);
  gtk_widget_show (event_box);

  gtk_widget_realize (event_box);
  cursor = gdk_cursor_new (GDK_TOP_LEFT_ARROW);
  gdk_window_set_cursor (event_box->window, cursor);
  gdk_cursor_destroy (cursor);

  combo_button->frame = gtk_frame_new (NULL);
  gtk_container_add (GTK_CONTAINER (event_box), combo_button->frame);
  gtk_frame_set_shadow_type (GTK_FRAME (combo_button->frame), GTK_SHADOW_OUT);
  gtk_widget_show (combo_button->frame);

  gtk_signal_connect (GTK_OBJECT (combo_button->popwin), "button_press_event",
		      GTK_SIGNAL_FUNC (gtk_combo_button_button_press), combo_button);
  

}
/**
 * xfce_panel_create_toggle_button:
 *
 * Create regular #GtkToggleButton with a few properties set to be useful in
 * Xfce panel: Flat (%GTK_RELIEF_NONE), no focus on click and minimal padding.
 *
 * Returns: newly created #GtkToggleButton.
 **/
GtkWidget *
xfce_panel_create_toggle_button (void)
{
  GtkWidget *button = gtk_toggle_button_new ();

  GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_DEFAULT | GTK_CAN_FOCUS);
  gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
  gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
  gtk_widget_set_name (button, "xfce-panel-toggle-button");

  return button;
}
Ejemplo n.º 28
0
GtkWidget* button_with_pixmap_image(gchar* mnemonic, gint image_number, gboolean toggle)
{
	GtkWidget *button, *alignment, *hbox, *label, *image;
	GdkPixbuf *pixbuf;

	if(toggle)
		button = gtk_toggle_button_new();
	else
		button = gtk_button_new();
	
	alignment = gtk_alignment_new(0.5, 0.5, 0, 0);
	gtk_container_add(GTK_CONTAINER(button), alignment);

	hbox = gtk_hbox_new(FALSE, 4);
	gtk_container_add(GTK_CONTAINER(alignment), hbox);

	// image = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_SMALL_TOOLBAR);
	switch(image_number)
	{
		case P_CPU:
			pixbuf = gdk_pixbuf_new_from_inline(-1, cpu_pixmap, FALSE, NULL);
			break;
		case P_VIDEO:
			pixbuf = gdk_pixbuf_new_from_inline(-1, video_pixmap, FALSE, NULL);
			break;
		case P_DEVICE:
			pixbuf = gdk_pixbuf_new_from_inline(-1, device_pixmap, FALSE, NULL);
			break;
		case P_MEMORY:
			pixbuf = gdk_pixbuf_new_from_inline(-1, memory_pixmap, FALSE, NULL);
			break;
		case P_MONITOR:
			pixbuf = gdk_pixbuf_new_from_inline(-1, monitor_pixmap, FALSE, NULL);
			break;
		case P_JOYSTICK:
			pixbuf = gdk_pixbuf_new_from_inline(-1, joystick_pixmap, FALSE, NULL);
			break;
		default:
			g_error("Invalid pixmap");
	}
	image = gtk_image_new_from_pixbuf(pixbuf);

	gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);

	label = gtk_label_new_with_mnemonic(mnemonic);
	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);

	gtk_widget_show_all(alignment);

	return button;
}
Ejemplo n.º 29
0
/*
 * Creates a new GtkWidget of class GtkToggleButton, performing any specialized
 * initialization needed for the widget to work correctly in this environment.
 * If a dialog box is used to initialize the widget, return NULL from this
 * function, and call data->callback with your new widget when it is done.
 * If the widget needs a special destroy handler, add a signal here.
 */
GtkWidget *
gb_toggle_button_new (GbWidgetNewData * data)
{
  GtkWidget *new_widget;

  if (data->action == GB_CREATING)
    new_widget = gtk_toggle_button_new_with_label (data->name);
  else
    {
      new_widget = gtk_toggle_button_new ();
      gtk_container_add (GTK_CONTAINER (new_widget), editor_new_placeholder());
    }
  return new_widget;
}
Ejemplo n.º 30
0
/*
 * 	creates a toggle button with an icon from file and a tooltip 
 */
GtkWidget* create_toggle_button(const gchar *icon, const gchar *tooltip)
{
	GtkWidget *btn = gtk_toggle_button_new();

	gchar *path = g_build_path(G_DIR_SEPARATOR_S, DBGPLUG_DATA_DIR, icon, NULL);
	GtkWidget *image =  gtk_image_new_from_file(path);
	g_free(path);

	gtk_widget_show(image);
	gtk_button_set_image(GTK_BUTTON(btn), image);

	gtk_widget_set_tooltip_text(btn, tooltip);
	
	return btn;
}