コード例 #1
0
ファイル: gtktoolbutton.c プロジェクト: raja651/gtk
static void
gtk_tool_button_sync_action_properties (GtkActivatable *activatable,
				        GtkAction      *action)
{
  GtkToolButton *button;
  GIcon         *icon;
  const gchar   *stock_id;
  GtkIconSet    *icon_set = NULL;

  parent_activatable_iface->sync_action_properties (activatable, action);

  if (!action)
    return;

  if (!gtk_activatable_get_use_action_appearance (activatable))
    return;

  button = GTK_TOOL_BUTTON (activatable);
  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
  stock_id = gtk_action_get_stock_id (action);
  G_GNUC_END_IGNORE_DEPRECATIONS;

  gtk_tool_button_set_label (button, gtk_action_get_short_label (action));
  gtk_tool_button_set_use_underline (button, TRUE);
  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
  gtk_tool_button_set_stock_id (button, stock_id);
  G_GNUC_END_IGNORE_DEPRECATIONS;
  gtk_tool_button_set_icon_name (button, gtk_action_get_icon_name (action));

  if (stock_id)
    {
      G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
      icon_set = gtk_icon_factory_lookup_default (stock_id);
      G_GNUC_END_IGNORE_DEPRECATIONS;
    }

  if (icon_set != NULL)
      gtk_tool_button_set_icon_widget (button, NULL);
  else if ((icon = gtk_action_get_gicon (action)) != NULL)
    {
      GtkIconSize icon_size = gtk_tool_item_get_icon_size (GTK_TOOL_ITEM (button));
      GtkWidget  *image = gtk_tool_button_get_icon_widget (button);
      
      if (!image)
	{
	  image = gtk_image_new ();
	  gtk_widget_show (image);
	  gtk_tool_button_set_icon_widget (button, image);
	}

      gtk_image_set_from_gicon (GTK_IMAGE (image), icon, icon_size);
    }
  else if (gtk_action_get_icon_name (action))
    gtk_tool_button_set_icon_name (button, gtk_action_get_icon_name (action));
  else
    gtk_tool_button_set_label (button, gtk_action_get_short_label (action));
}
コード例 #2
0
void Sidebar::initPages(GtkWidget* sidebar, GladeGui* gui)
{
	XOJ_CHECK_TYPE(Sidebar);

	addPage(new SidebarIndexPage(this->control));
	addPage(new SidebarPreviewPages(this->control));
#ifdef UNSTABLE_LAYERS_SIDEBAR
	addPage(new SidebarPreviewLayers(this->control));
#endif //UNSTABLE_LAYERS_SIDEBAR

	// Init toolbar with icons

	int i = 0;
	for (AbstractSidebarPage* p : this->pages)
	{
		GtkToolItem* it = gtk_toggle_tool_button_new();
		p->tabButton = it;

		gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(it), gui->loadIcon(p->getIconName().c_str()));
		g_signal_connect(it, "clicked", G_CALLBACK(&buttonClicked), new SidebarPageButton(this, i, p));
		gtk_tool_item_set_tooltip_text(it, p->getName().c_str());
		gtk_tool_button_set_label(GTK_TOOL_BUTTON(it), p->getName().c_str());

		gtk_toolbar_insert(tbSelectPage, it, -1);

		// Add widget to sidebar
		gtk_box_pack_start(GTK_BOX(sidebar), p->getWidget(), TRUE, TRUE, 0);

		i++;
	}

	gtk_widget_show_all(GTK_WIDGET(this->tbSelectPage));

	updateEnableDisableButtons();
}
コード例 #3
0
static GtkWidget* ink_toggle_action_create_tool_item( GtkAction* action )
{
    InkToggleAction* act = INK_TOGGLE_ACTION( action );

    GtkWidget* item = GTK_TOGGLE_ACTION_CLASS(ink_toggle_action_parent_class)->parent_class.create_tool_item(action);
    if ( GTK_IS_TOOL_BUTTON(item) ) {
        GtkToolButton* button = GTK_TOOL_BUTTON(item);
        if ( act->private_data->iconId ) {
            GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId );
            GtkWidget* align = gtk_alignment_new( 0.5, 0.5, 0.0, 0.0 );
            gtk_container_add( GTK_CONTAINER(align), child );
            gtk_tool_button_set_icon_widget( button, align );
        } else {
            gchar *label = 0;
            g_object_get( G_OBJECT(action), "short_label", &label, NULL );
            gtk_tool_button_set_label( button, label );
            g_free( label );
            label = 0;
        }
    } else {
        // For now trigger a warning but don't do anything else
        GtkToolButton* button = GTK_TOOL_BUTTON(item);
        (void)button;
    }
    gtk_widget_show_all( item );

    return item;
}
コード例 #4
0
/*
 * Creates a new GtkWidget of class GtkToggleToolButton, 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.
 */
static GtkWidget*
gb_toggle_tool_button_new (GbWidgetNewData *data)
{
  GtkWidget *new_widget, *image;
  GbWidget *pixmap_gbwidget;

  /* Place the pixmap icon in the button initially (even when loading). */
  pixmap_gbwidget = gb_widget_lookup_class ("GtkImage");
  if (pixmap_gbwidget)
    {
      image = gtk_image_new_from_pixmap (pixmap_gbwidget->gdkpixmap,
					 pixmap_gbwidget->mask);
    }
  else
    {
      image = gtk_image_new ();
      g_warning ("Couldn't find GtkPixmap data");
    }
  gtk_widget_show (image);

  new_widget = (GtkWidget*) gtk_toggle_tool_button_new ();

  gtk_tool_button_set_label (GTK_TOOL_BUTTON (new_widget), "");
  gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (new_widget), image);

  return new_widget;
}
コード例 #5
0
ファイル: ToolButton.cpp プロジェクト: wbrenna/xournalpp
GtkToolItem * ToolButton::newItem() {
	XOJ_CHECK_TYPE(ToolButton);

	GtkToolItem * it;

	if (!stock.isEmpty()) {
		if (popupMenu) {
			it = gtk_menu_tool_button_new_from_stock(stock.c_str());
			gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(it), popupMenu);
		} else {
			it = gtk_tool_button_new_from_stock(stock.c_str());
		}
	} else if (group != GROUP_NOGROUP) {
		if (popupMenu) {
			it = gtk_menu_tool_toggle_button_new(this->gui->loadIcon(iconName.c_str()), description.c_str());
			gtk_menu_tool_toggle_button_set_menu(GTK_MENU_TOOL_TOGGLE_BUTTON(it), popupMenu);
		} else {
			it = gtk_toggle_tool_button_new();
			gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(it), this->gui->loadIcon(iconName.c_str()));
		}
	} else {
		if (popupMenu) {
			it = gtk_menu_tool_button_new(this->gui->loadIcon(iconName.c_str()), description.c_str());
			gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(it), popupMenu);
		} else {
			it = gtk_tool_button_new(this->gui->loadIcon(iconName.c_str()), description.c_str());
		}
	}
	gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(it), description.c_str());
	gtk_tool_button_set_label(GTK_TOOL_BUTTON(it), description.c_str());

	return it;
}
コード例 #6
0
ファイル: browser.c プロジェクト: kublaj/lariza
void
changed_download_progress(GObject *obj, GParamSpec *pspec, gpointer data)
{
    WebKitDownload *download = WEBKIT_DOWNLOAD(obj);
    WebKitURIResponse *resp;
    GtkToolItem *tb = GTK_TOOL_ITEM(data);
    gdouble p, size_mb;
    const gchar *uri;
    gchar *t, *filename, *base;

    p = webkit_download_get_estimated_progress(download) * 100;
    resp = webkit_download_get_response(download);
    size_mb = webkit_uri_response_get_content_length(resp) / 1e6;

    uri = webkit_download_get_destination(download);
    filename = g_filename_from_uri(uri, NULL, NULL);
    if (filename == NULL)
    {
        /* This really should not happen because WebKit uses that URI to
         * write to a file... */
        fprintf(stderr, __NAME__": Could not construct file name from URI!\n");
        t = g_strdup_printf("%s (%.0f%% of %.1f MB)",
                            webkit_uri_response_get_uri(resp), p, size_mb);
    }
    else
    {
        base = g_path_get_basename(filename);
        t = g_strdup_printf("%s (%.0f%% of %.1f MB)", base, p, size_mb);
        g_free(filename);
        g_free(base);
    }
    gtk_tool_button_set_label(GTK_TOOL_BUTTON(tb), t);
    g_free(t);
}
コード例 #7
0
ファイル: preview.c プロジェクト: LiminWang/HandBrake
static void
update_preview_labels(signal_user_data_t *ud, gboolean active)
{
    GtkToolButton *button;

    button   = GTK_TOOL_BUTTON(GHB_WIDGET(ud->builder, "show_preview"));

    if (!active)
    {
        gtk_tool_button_set_label(button, "Preview");
    }
    else
    {
        gtk_tool_button_set_label(button, "Preview");
    }
}
コード例 #8
0
ファイル: gtktoolbutton.c プロジェクト: ystk/debian-gtk-2.0
static void
gtk_tool_button_set_property (GObject         *object,
			      guint            prop_id,
			      const GValue    *value,
			      GParamSpec      *pspec)
{
  GtkToolButton *button = GTK_TOOL_BUTTON (object);
  
  switch (prop_id)
    {
    case PROP_LABEL:
      gtk_tool_button_set_label (button, g_value_get_string (value));
      break;
    case PROP_USE_UNDERLINE:
      gtk_tool_button_set_use_underline (button, g_value_get_boolean (value));
      break;
    case PROP_LABEL_WIDGET:
      gtk_tool_button_set_label_widget (button, g_value_get_object (value));
      break;
    case PROP_STOCK_ID:
      gtk_tool_button_set_stock_id (button, g_value_get_string (value));
      break;
    case PROP_ICON_NAME:
      gtk_tool_button_set_icon_name (button, g_value_get_string (value));
      break;
    case PROP_ICON_WIDGET:
      gtk_tool_button_set_icon_widget (button, g_value_get_object (value));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
コード例 #9
0
ファイル: viewer.c プロジェクト: BIANZiyang/3PRE
void make_toolbar(Viewer *viewer, GtkWidget *parent)
{
    GtkWidget *toolbar = gtk_toolbar_new();
    gtk_box_pack_start(GTK_BOX(parent), toolbar, FALSE, FALSE, 0);

    // add a recording button to the toolbar
    viewer->record_button = GTK_WIDGET(
        gtk_toggle_tool_button_new_from_stock (GTK_STOCK_MEDIA_RECORD));
    gtk_tool_item_set_is_important (GTK_TOOL_ITEM (viewer->record_button), 
            TRUE);
    gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (viewer->record_button), 
            viewer->tips,
            "Record an AVI of the viewport, saved in the current directory",
            NULL);

    gtk_toolbar_insert (GTK_TOOLBAR (toolbar), 
            GTK_TOOL_ITEM (viewer->record_button), 0);
    gtk_widget_show (viewer->record_button);
    g_signal_connect (G_OBJECT (viewer->record_button), "toggled", 
            G_CALLBACK (on_record_toggled), viewer);

    // screenshot button
    GtkToolItem *ssbt = gtk_tool_button_new_from_stock (GTK_STOCK_FLOPPY);
    gtk_tool_button_set_label (GTK_TOOL_BUTTON (ssbt), "Screenshot");
    gtk_tool_item_set_is_important (GTK_TOOL_ITEM (ssbt), TRUE);
    gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (ssbt), viewer->tips,
            "Save a PPM screenshot of the viewport to the current directory",
            NULL);
    gtk_toolbar_insert (GTK_TOOLBAR (toolbar), ssbt, 1);
    gtk_widget_show (GTK_WIDGET (ssbt));
    g_signal_connect (G_OBJECT (ssbt), "clicked", 
            G_CALLBACK (on_screenshot_clicked), viewer);

    // quit button
    GtkToolItem *quitbt = gtk_tool_button_new_from_stock (GTK_STOCK_QUIT);
    gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (quitbt), viewer->tips,
            "Quit", NULL);
    gtk_toolbar_insert (GTK_TOOLBAR (toolbar), quitbt, 2);
    gtk_widget_show (GTK_WIDGET (quitbt));
    g_signal_connect (G_OBJECT (quitbt), "clicked", gtk_main_quit, NULL);

    GtkToolItem * sep = gtk_separator_tool_item_new ();
    gtk_widget_show (GTK_WIDGET (sep));
    gtk_toolbar_insert (GTK_TOOLBAR (toolbar), sep, 3);

    GtkWidget * hbox = gtk_hbox_new (FALSE, 5);
    GtkWidget * label = gtk_label_new ("Record FPS");
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
    viewer->fps_spin = gtk_spin_button_new_with_range (0.1, 120.0, 1.0);
    gtk_spin_button_set_digits (GTK_SPIN_BUTTON (viewer->fps_spin), 1);
    gtk_spin_button_set_value (GTK_SPIN_BUTTON (viewer->fps_spin), 30);
    gtk_box_pack_start (GTK_BOX (hbox), viewer->fps_spin, FALSE, FALSE, 0);

    GtkToolItem * toolitem = gtk_tool_item_new ();
    gtk_container_add (GTK_CONTAINER (toolitem), hbox);
    gtk_widget_show_all (GTK_WIDGET (toolitem));
    gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, 4);
    viewer->toolbar = GTK_TOOLBAR (toolbar);
}
コード例 #10
0
ファイル: gtk_ToolButton.cpp プロジェクト: Klaim/falcon
/*#
    @method set_label GtkToolButton
    @brief Sets label as the label used for the tool button.
    @param label a string that will be used as label, or NULL.

    The "label" property only has an effect if not overridden by a non-NULL
    "label_widget" property. If both the "label_widget" and "label" properties
    are NULL, the label is determined by the "stock_id" property. If the
    "stock_id" property is also NULL, button will not have a label.
 */
FALCON_FUNC ToolButton::set_label( VMARG )
{
    Gtk::ArgCheck1 args( vm, "[S]" );
    const gchar* lbl = args.getCString( 0, false );
    MYSELF;
    GET_OBJ( self );
    gtk_tool_button_set_label( (GtkToolButton*)_obj, lbl );
}
コード例 #11
0
static void
load_stock_items (GtkToolPalette *palette)
{
  GtkWidget *group_af = gtk_tool_item_group_new ("Stock Icons (A-F)");
  GtkWidget *group_gn = gtk_tool_item_group_new ("Stock Icons (G-N)");
  GtkWidget *group_or = gtk_tool_item_group_new ("Stock Icons (O-R)");
  GtkWidget *group_sz = gtk_tool_item_group_new ("Stock Icons (S-Z)");
  GtkWidget *group = NULL;

  GtkToolItem *item;
  GSList *stock_ids;
  GSList *iter;

  stock_ids = gtk_stock_list_ids ();
  stock_ids = g_slist_sort (stock_ids, (GCompareFunc) strcmp);

  gtk_container_add (GTK_CONTAINER (palette), group_af);
  gtk_container_add (GTK_CONTAINER (palette), group_gn);
  gtk_container_add (GTK_CONTAINER (palette), group_or);
  gtk_container_add (GTK_CONTAINER (palette), group_sz);

  for (iter = stock_ids; iter; iter = g_slist_next (iter))
    {
      GtkStockItem stock_item;
      gchar *id = iter->data;

      switch (id[4])
        {
          case 'a':
            group = group_af;
            break;

          case 'g':
            group = group_gn;
            break;

          case 'o':
            group = group_or;
            break;

          case 's':
            group = group_sz;
            break;
        }

      item = gtk_tool_button_new_from_stock (id);
      gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (item), id);
      gtk_tool_item_set_is_important (GTK_TOOL_ITEM (item), TRUE);
      gtk_tool_item_group_insert (GTK_TOOL_ITEM_GROUP (group), item, -1);

      if (!gtk_stock_lookup (id, &stock_item) || !stock_item.label)
        gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), id);

      g_free (id);
    }

  g_slist_free (stock_ids);
}
コード例 #12
0
ファイル: ToolButton.cpp プロジェクト: wbrenna/xournalpp
void ToolButton::updateDescription(String description) {
	XOJ_CHECK_TYPE(ToolButton);

	this->description = description;
	if (GTK_IS_TOOL_ITEM(item)) {
		gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(item), description.c_str());
		gtk_tool_button_set_label(GTK_TOOL_BUTTON(item), description.c_str());
	}
}
コード例 #13
0
ファイル: browser.c プロジェクト: kublaj/lariza
gboolean
download_handle(WebKitDownload *download, gchar *suggested_filename, gpointer data)
{
    gchar *sug_clean, *path, *path2 = NULL, *uri;
    GtkToolItem *tb;
    int suffix = 1;
    size_t i;

    sug_clean = g_strdup(suggested_filename);
    for (i = 0; i < strlen(sug_clean); i++)
        if (sug_clean[i] == G_DIR_SEPARATOR)
            sug_clean[i] = '_';

    path = g_build_filename(download_dir, sug_clean, NULL);
    path2 = g_strdup(path);
    while (g_file_test(path2, G_FILE_TEST_EXISTS) && suffix < 1000)
    {
        g_free(path2);

        path2 = g_strdup_printf("%s.%d", path, suffix);
        suffix++;
    }

    if (suffix == 1000)
    {
        fprintf(stderr, __NAME__": Suffix reached limit for download.\n");
        webkit_download_cancel(download);
    }
    else
    {
        uri = g_filename_to_uri(path2, NULL, NULL);
        webkit_download_set_destination(download, uri);
        g_free(uri);

        tb = gtk_tool_button_new(NULL, NULL);
        gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(tb), "gtk-delete");
        gtk_tool_button_set_label(GTK_TOOL_BUTTON(tb), sug_clean);
        gtk_toolbar_insert(GTK_TOOLBAR(dm.toolbar), tb, 0);
        gtk_widget_show_all(dm.win);

        g_signal_connect(G_OBJECT(download), "notify::estimated-progress",
                         G_CALLBACK(changed_download_progress), tb);

        g_object_ref(download);
        g_signal_connect(G_OBJECT(tb), "clicked",
                         G_CALLBACK(downloadmanager_cancel), download);
    }

    g_free(sug_clean);
    g_free(path);
    g_free(path2);

    /* Propagate -- to whom it may concern. */
    return FALSE;
}
コード例 #14
0
static inline GtkToolItem *_add_category_button (GtkWidget *pToolBar, const gchar *cLabel, const gchar *cIconName, int pos, GtkToolItem *group)
{
	GtkToolItem *pCategoryButton;
	if (group)
		pCategoryButton= gtk_radio_tool_button_new_from_widget (GTK_RADIO_TOOL_BUTTON (group));
	else
		pCategoryButton = gtk_radio_tool_button_new (NULL);
	gtk_tool_button_set_label (GTK_TOOL_BUTTON (pCategoryButton), cLabel);
	gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (pCategoryButton), cIconName);
	g_signal_connect (G_OBJECT (pCategoryButton), "toggled", G_CALLBACK(on_click_category_button), GINT_TO_POINTER (pos));
	gtk_toolbar_insert (GTK_TOOLBAR (pToolBar) , pCategoryButton, -1);
	return pCategoryButton;
}
コード例 #15
0
static void
glade_gtk_tool_button_set_label (GObject * object, const GValue * value)
{
  const gchar *label;

  g_return_if_fail (GTK_IS_TOOL_BUTTON (object));

  label = g_value_get_string (value);

  if (label && strlen (label) == 0)
    label = NULL;

  gtk_tool_button_set_label (GTK_TOOL_BUTTON (object), label);
}
コード例 #16
0
ファイル: ui_gtk.c プロジェクト: viking/audacious-plugins
static GtkToolItem * toggle_button_new (const gchar * icon, const gchar * alt,
 void (* toggled) (GtkToggleToolButton * button))
{
    GtkToolItem * item = gtk_toggle_tool_button_new ();

    if (! alt)
        gtk_tool_button_set_stock_id ((GtkToolButton *) item, icon);
    else if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (), icon))
        gtk_tool_button_set_icon_name ((GtkToolButton *) item, icon);
    else
        gtk_tool_button_set_label ((GtkToolButton *) item, alt);

    g_signal_connect (item, "toggled", (GCallback) toggled, NULL);
    return item;
}
コード例 #17
0
ファイル: ColorToolItem.cpp プロジェクト: wbrenna/xournalpp
GtkToolItem * ColorToolItem::newItem() {
	XOJ_CHECK_TYPE(ColorToolItem);

	this->iconWidget = selectcolor_new(this->color);

	selectcolor_set_circle(this->iconWidget, !isSelector());
	GtkToolItem * it = gtk_toggle_tool_button_new();

	gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(it), this->name.c_str());
	gtk_tool_button_set_label(GTK_TOOL_BUTTON(it), this->name.c_str());

	gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(it), this->iconWidget);

	return it;
}
コード例 #18
0
GtkToolItem *hwidget_get_tool_button(const gchar *image_file,
				     const gchar *label,
				     const gchar *tooltips_string,
				     gpointer callback,
				     gpointer data,
				     guint type)
{
	GtkToolItem	*button;
	GtkWidget	*pixmap;
	GtkTooltips	*tooltips;

	switch (type) {
		case HWIDGET_TOGGLE_TOOL_BUTTON:
			button = gtk_toggle_tool_button_new();
			if (callback) {
				g_signal_connect(G_OBJECT(button), "toggled",
						 G_CALLBACK(callback), data);
			}
			break;
		case HWIDGET_TOOL_BUTTON:
			button = gtk_tool_button_new(NULL, NULL);
			if (callback) {
				g_signal_connect(G_OBJECT(button), "clicked",
						 G_CALLBACK(callback), data);
			}
			break;
		default:
			return NULL;
	}

	if (image_file) {
		pixmap = hutil_create_pixmap(image_file);
		gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(button),
						pixmap);
	}

	if (label) {
		gtk_tool_button_set_label(GTK_TOOL_BUTTON(button), label);
	}

	if (tooltips_string) {
		tooltips = gtk_tooltips_new();
		gtk_tool_item_set_tooltip(button, tooltips, tooltips_string,
					  NULL);
	}

	return button;
}
コード例 #19
0
ファイル: cookie-manager-page.c プロジェクト: sinoory/webv8
static void cm_create_toolbar(CookieManagerPage *cmp)
{
    CookieManagerPagePrivate *priv = cmp->priv;
    GtkWidget *toolbar;
    GtkToolItem *toolitem;

    priv->toolbar = toolbar = gtk_toolbar_new();
    toolitem = gtk_tool_button_new_from_stock(GTK_STOCK_DELETE);
    gtk_tool_item_set_is_important(toolitem, TRUE);
    g_signal_connect(toolitem, "clicked", G_CALLBACK(cm_button_delete_clicked_cb), cmp);
    gtk_widget_show(GTK_WIDGET(toolitem));
    gtk_widget_set_sensitive(GTK_WIDGET(toolitem), FALSE);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
    priv->delete_button = GTK_WIDGET(toolitem);

    toolitem = gtk_tool_button_new_from_stock(GTK_STOCK_DELETE);
    gtk_tool_button_set_label(GTK_TOOL_BUTTON(toolitem), _("Delete All"));
    gtk_tool_item_set_tooltip_text(toolitem,
                                   _("Deletes all shown cookies. "
                                     "If a filter is set, only those cookies are deleted which match the filter."));
    gtk_tool_item_set_is_important(toolitem, TRUE);
    g_signal_connect(toolitem, "clicked", G_CALLBACK(cm_button_delete_all_clicked_cb), cmp);
    gtk_widget_show(GTK_WIDGET(toolitem));
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
    priv->delete_all_button = GTK_WIDGET(toolitem);

    toolitem = gtk_separator_tool_item_new();
    gtk_separator_tool_item_set_draw(GTK_SEPARATOR_TOOL_ITEM(toolitem), FALSE);
    gtk_tool_item_set_expand(toolitem, TRUE);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
    gtk_widget_show(GTK_WIDGET(toolitem));

    toolitem = gtk_tool_button_new_from_stock(GTK_STOCK_ADD);
    gtk_tool_item_set_tooltip_text(toolitem, _("Expand All"));
    g_signal_connect(toolitem, "clicked", G_CALLBACK(cm_tree_popup_expand_activate_cb), cmp);
    gtk_widget_show(GTK_WIDGET(toolitem));
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
    priv->expand_buttons[0] = GTK_WIDGET(toolitem);

    toolitem = gtk_tool_button_new_from_stock(GTK_STOCK_REMOVE);
    gtk_tool_item_set_tooltip_text(toolitem, _("Collapse All"));
    g_signal_connect(toolitem, "clicked", G_CALLBACK(cm_tree_popup_collapse_activate_cb), cmp);
    gtk_widget_show(GTK_WIDGET(toolitem));
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
    priv->expand_buttons[1] = GTK_WIDGET(toolitem);
}
コード例 #20
0
ファイル: gtktoolbutton.c プロジェクト: ystk/debian-gtk-2.0
static void
gtk_tool_button_update (GtkActivatable *activatable,
			GtkAction      *action,
			const gchar    *property_name)
{
  GtkToolButton *button;
  GtkWidget *image;

  parent_activatable_iface->update (activatable, action, property_name);

  if (!gtk_activatable_get_use_action_appearance (activatable))
    return;

  button = GTK_TOOL_BUTTON (activatable);
  
  if (strcmp (property_name, "short-label") == 0)
    gtk_tool_button_set_label (button, gtk_action_get_short_label (action));
  else if (strcmp (property_name, "stock-id") == 0)
    gtk_tool_button_set_stock_id (button, gtk_action_get_stock_id (action));
  else if (strcmp (property_name, "gicon") == 0)
    {
      const gchar *stock_id = gtk_action_get_stock_id (action);
      GIcon *icon = gtk_action_get_gicon (action);
      GtkIconSize icon_size = GTK_ICON_SIZE_BUTTON;

      if ((stock_id && gtk_icon_factory_lookup_default (stock_id)) || !icon)
	image = NULL;
      else 
	{   
	  image = gtk_tool_button_get_icon_widget (button);
	  icon_size = gtk_tool_item_get_icon_size (GTK_TOOL_ITEM (button));

	  if (!image)
	    image = gtk_image_new ();
	}

      gtk_tool_button_set_icon_widget (button, image);
      gtk_image_set_from_gicon (GTK_IMAGE (image), icon, icon_size);

    }
  else if (strcmp (property_name, "icon-name") == 0)
    gtk_tool_button_set_icon_name (button, gtk_action_get_icon_name (action));
}
コード例 #21
0
ファイル: gtktoolbutton.c プロジェクト: raja651/gtk
static void
gtk_tool_button_set_property (GObject         *object,
			      guint            prop_id,
			      const GValue    *value,
			      GParamSpec      *pspec)
{
  GtkToolButton *button = GTK_TOOL_BUTTON (object);
  
  switch (prop_id)
    {
    case PROP_LABEL:
      gtk_tool_button_set_label (button, g_value_get_string (value));
      break;
    case PROP_USE_UNDERLINE:
      gtk_tool_button_set_use_underline (button, g_value_get_boolean (value));
      break;
    case PROP_LABEL_WIDGET:
      gtk_tool_button_set_label_widget (button, g_value_get_object (value));
      break;
    case PROP_STOCK_ID:
      G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
      gtk_tool_button_set_stock_id (button, g_value_get_string (value));
      G_GNUC_END_IGNORE_DEPRECATIONS;
      break;
    case PROP_ICON_NAME:
      gtk_tool_button_set_icon_name (button, g_value_get_string (value));
      break;
    case PROP_ICON_WIDGET:
      gtk_tool_button_set_icon_widget (button, g_value_get_object (value));
      break;
    case PROP_ACTION_NAME:
      g_object_set_property (G_OBJECT (button->priv->button), "action-name", value);
      break;
    case PROP_ACTION_TARGET:
      g_object_set_property (G_OBJECT (button->priv->button), "action-target", value);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
コード例 #22
0
/*
 * Creates a new GtkWidget of class GtkRadioToolButton, 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.
 */
static GtkWidget*
gb_radio_tool_button_new (GbWidgetNewData *data)
{
  GtkWidget *new_widget, *image;
  GbWidget *pixmap_gbwidget;
  GSList *group_list = NULL;

  /* When creating a radiotoolbutton we try to place it in the same group
     as other radiotoolbuttons in the same toolbar. */
  if (data->action == GB_CREATING)
    {
      GtkWidget *parent = data->parent;
      while (parent && !GTK_IS_TOOLBAR (parent))
	parent = parent->parent;
      if (parent)
	gb_widget_children_foreach (parent,
				    (GtkCallback) find_parents_group,
				    &group_list);
    }

  /* Place the pixmap icon in the button initially (even when loading). */
  pixmap_gbwidget = gb_widget_lookup_class ("GtkImage");
  if (pixmap_gbwidget)
    {
      image = gtk_image_new_from_pixmap (pixmap_gbwidget->gdkpixmap,
					 pixmap_gbwidget->mask);
    }
  else
    {
      image = gtk_image_new ();
      g_warning ("Couldn't find GtkPixmap data");
    }
  gtk_widget_show (image);

  new_widget = (GtkWidget*) gtk_radio_tool_button_new (group_list);

  gtk_tool_button_set_label (GTK_TOOL_BUTTON (new_widget), "");
  gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (new_widget), image);

  return new_widget;
}
コード例 #23
0
GtkToolItem *ZLGtkApplicationWindow::createGtkToolButton(const ZLToolbar::AbstractButtonItem &button) {
	GtkToolItem *gtkItem = 0;
	static std::string imagePrefix =
		ZLibrary::ApplicationImageDirectory() + ZLibrary::FileNameDelimiter;
	GtkWidget *image = gtk_image_new_from_file(
		(imagePrefix + button.iconName() + ".png").c_str()
	);

	switch (button.type()) {
		case ZLToolbar::Item::PLAIN_BUTTON:
			gtkItem = gtk_tool_button_new(image, button.tooltip().c_str());
			break;
		case ZLToolbar::Item::TOGGLE_BUTTON:
			gtkItem = gtk_toggle_tool_button_new();
			gtk_tool_button_set_label(GTK_TOOL_BUTTON(gtkItem), button.tooltip().c_str());
			gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(gtkItem), image);
			break;
		case ZLToolbar::Item::MENU_BUTTON:
		{
			gtkItem = gtk_menu_tool_button_new(image, button.tooltip().c_str());
			const ZLToolbar::MenuButtonItem &menuButton =
				(const ZLToolbar::MenuButtonItem&)button;
			shared_ptr<ZLPopupData> popupData = menuButton.popupData();
			myPopupIdMap[gtkItem] =
				popupData.isNull() ? (size_t)-1 : (popupData->id() - 1);
			gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(gtkItem), gtk_menu_new());
			gtk_menu_tool_button_set_arrow_tooltip(GTK_MENU_TOOL_BUTTON(gtkItem), myToolbar->tooltips, menuButton.popupTooltip().c_str(), 0);
			break;
		}
		default:
			break;
	}

	gtk_tool_item_set_tooltip(gtkItem, myToolbar->tooltips, button.tooltip().c_str(), 0);
	ZLGtkSignalUtil::connectSignal(GTK_OBJECT(gtkItem), "clicked", GTK_SIGNAL_FUNC(onButtonClicked), this);
	//GTK_WIDGET_UNSET_FLAGS(gtkItem, GTK_CAN_FOCUS);

	return gtkItem;
}
コード例 #24
0
ファイル: gnomeapp.c プロジェクト: AriaAsuka/deadbeef
static void
gb_gnome_app_add_toolbar_button (GtkToolbar *toolbar,
				 const gchar *stock_id,
				 const gchar *tooltip)
{
  GtkWidget *button;
  GladeWidgetData *wdata;

  button = gb_widget_new ("GtkToolButton", NULL);

  gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (button), stock_id);
  gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (button), NULL);
  gtk_tool_button_set_label (GTK_TOOL_BUTTON (button), NULL);

  gtk_object_set_data_full (GTK_OBJECT (button),
			    GladeToolButtonStockIDKey,
			    g_strdup (stock_id), g_free);

  wdata = gtk_object_get_data (GTK_OBJECT (button), GB_WIDGET_DATA_KEY);
  wdata->tooltip = g_strdup (tooltip);

  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (button), -1);
}
コード例 #25
0
static void
load_toggle_items (GtkToolPalette *palette)
{
  GSList *toggle_group = NULL;
  GtkToolItem *item;
  GtkWidget *group;
  char *label;
  int i;

  group = gtk_tool_item_group_new ("Radio Item");
  gtk_container_add (GTK_CONTAINER (palette), group);

  for (i = 1; i <= 10; ++i)
    {
      label = g_strdup_printf ("#%d", i);
      item = gtk_radio_tool_button_new (toggle_group);
      gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), label);
      g_free (label);

      gtk_tool_item_group_insert (GTK_TOOL_ITEM_GROUP (group), item, -1);
      toggle_group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (item));
    }
}
コード例 #26
0
static gint
tm_set_tool_item_label(GtkToolItem * tool_item, const gchar * stock_id,
                       gboolean make_two_line)
{
    gint button = get_toolbar_button_index(stock_id);
    const gchar *text;
    gchar *label;

    if (button < 0)
        return button;

    text = balsa_toolbar_button_text(button);
    if (balsa_app.toolbar_wrap_button_text) {
        /* Make sure all buttons have the same number of lines of
         * text (1 or 2), to keep icons aligned */
        label = make_two_line && !strchr(text, '\n') ?
            g_strconcat(text, "\n", NULL) : g_strdup(text);
    } else {
        gchar *p = label = g_strdup(text);
        while ((p = strchr(p, '\n')))
            *p++ = ' ';
    }

    gtk_tool_button_set_label(GTK_TOOL_BUTTON(tool_item), label);
    g_free(label);

    gtk_tool_item_set_is_important(tool_item,
                                   toolbar_buttons[button].is_important);

    if (strcmp(toolbar_buttons[button].pixmap_id, BALSA_PIXMAP_SEND) == 0
        && balsa_app.always_queue_sent_mail)
        gtk_tool_item_set_tooltip_text(tool_item,
                                       _("Queue this message for sending"));

    return button;
}
コード例 #27
0
ファイル: tbargtk.cpp プロジェクト: czxxjtu/wxPython-1
bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
{
    wxToolBarTool* tool = static_cast<wxToolBarTool*>(toolBase);

    GSList* radioGroup;
    switch ( tool->GetStyle() )
    {
        case wxTOOL_STYLE_BUTTON:
            switch (tool->GetKind())
            {
                case wxITEM_CHECK:
                    tool->m_item = gtk_toggle_tool_button_new();
                    g_signal_connect(tool->m_item, "toggled",
                        G_CALLBACK(item_toggled), tool);
                    break;
                case wxITEM_RADIO:
                    radioGroup = GetRadioGroup(pos);
                    if (radioGroup)
                    {
                        // this is the first button in the radio button group,
                        // it will be toggled automatically by GTK so bring the
                        // internal flag in sync
                        tool->Toggle(true);
                    }
                    tool->m_item = gtk_radio_tool_button_new(radioGroup);
                    g_signal_connect(tool->m_item, "toggled",
                        G_CALLBACK(item_toggled), tool);
                    break;
                default:
                    wxFAIL_MSG("unknown toolbar child type");
                    // fall through
                case wxITEM_DROPDOWN:
                case wxITEM_NORMAL:
                    tool->m_item = gtk_tool_button_new(NULL, "");
                    g_signal_connect(tool->m_item, "clicked",
                        G_CALLBACK(item_clicked), tool);
                    break;
            }
            if (!HasFlag(wxTB_NOICONS))
            {
                GtkWidget* image = gtk_image_new();
                gtk_tool_button_set_icon_widget(
                    GTK_TOOL_BUTTON(tool->m_item), image);
                tool->SetImage();
                gtk_widget_show(image);
                g_signal_connect(image, "expose_event",
                    G_CALLBACK(image_expose_event), tool);
            }
            if (!tool->GetLabel().empty())
            {
                gtk_tool_button_set_label(
                    GTK_TOOL_BUTTON(tool->m_item), wxGTK_CONV(tool->GetLabel()));
                // needed for labels in horizontal toolbar with wxTB_HORZ_LAYOUT
                gtk_tool_item_set_is_important(tool->m_item, true);
            }
            if (!HasFlag(wxTB_NO_TOOLTIPS) && !tool->GetShortHelp().empty())
            {
                gtk_tool_item_set_tooltip(tool->m_item,
                    m_tooltips, wxGTK_CONV(tool->GetShortHelp()), "");
            }
            g_signal_connect(GTK_BIN(tool->m_item)->child, "button_press_event",
                G_CALLBACK(button_press_event), tool);
            g_signal_connect(tool->m_item, "enter_notify_event",
                G_CALLBACK(enter_notify_event), tool);
            g_signal_connect(tool->m_item, "leave_notify_event",
                G_CALLBACK(enter_notify_event), tool);

            if (tool->GetKind() == wxITEM_DROPDOWN)
                tool->CreateDropDown();
            gtk_toolbar_insert(m_toolbar, tool->m_item, int(pos));
            break;

        case wxTOOL_STYLE_SEPARATOR:
            tool->m_item = gtk_separator_tool_item_new();
            gtk_toolbar_insert(m_toolbar, tool->m_item, int(pos));
            break;

        case wxTOOL_STYLE_CONTROL:
            wxWindow* control = tool->GetControl();
            if (control->m_widget->parent == NULL)
                AddChildGTK(control);
            tool->m_item = GTK_TOOL_ITEM(control->m_widget->parent->parent);
            if (gtk_toolbar_get_item_index(m_toolbar, tool->m_item) != int(pos))
            {
                g_object_ref(tool->m_item);
                gtk_container_remove(
                    GTK_CONTAINER(m_toolbar), GTK_WIDGET(tool->m_item));
                gtk_toolbar_insert(m_toolbar, tool->m_item, int(pos));
                g_object_unref(tool->m_item);
            }
            // Inserted items "slide" into place using an animated effect that
            // causes multiple size events on the item. Must set size request
            // to keep item size from getting permanently set too small by the
            // first of these size events.
            const wxSize size = control->GetSize();
            gtk_widget_set_size_request(control->m_widget, size.x, size.y);
            break;
    }
    gtk_widget_show(GTK_WIDGET(tool->m_item));

    InvalidateBestSize();

    return true;
}
コード例 #28
0
ファイル: gtkgeomwindow.cpp プロジェクト: p1heidary/pybsimu
GTKGeomWindow::GTKGeomWindow( class GTKPlotter       &plotter, 
			      const Geometry         &geom,
			      const EpotField        *epot,
			      const EpotEfield       *efield,
			      const MeshScalarField  *scharge,
			      const MeshScalarField  *tdens,
			      const VectorField      *bfield,
			      const ParticleDataBase *pdb )
  : GTKFrameWindow(plotter), _geomplot(_frame,geom), 
    _geom(geom), _epot(epot), _efield(efield), _scharge(scharge), _tdens(tdens), 
    _bfield(bfield), _pdb(pdb), _tool(TOOL_UNKNOWN), _prefdata(NULL)
{
    //std::cout << "GTKGeomWindow constructor\n";

    // Setup GeomPlot
    _geomplot.set_epot( epot );
    _geomplot.set_scharge( scharge );
    _geomplot.set_trajdens( tdens );
    _geomplot.set_bfield( bfield );
    _geomplot.set_efield( efield );
    _geomplot.set_particle_database( pdb );

    // Set window title
    gtk_window_set_title( GTK_WINDOW(_window), "Simulation geometry" );

    // Adding geometry window specific tools to toolbar
    // Creating separator
    GtkToolItem *toolitem = gtk_separator_tool_item_new();
    gtk_toolbar_insert( GTK_TOOLBAR(_toolbar), toolitem, -1 );

    // Creating "Particle diagnostics" button
    GdkPixbuf *pixbuf = gdk_pixbuf_new_from_inline( -1, icon_particle_diag_inline, FALSE, NULL );
    GtkWidget *icon = gtk_image_new_from_pixbuf( pixbuf );
    toolitem = gtk_radio_tool_button_new_from_widget( GTK_RADIO_TOOL_BUTTON(_radioitem) );
    gtk_tool_button_set_label( GTK_TOOL_BUTTON(toolitem), "Particle diagnostics" );
#if GTK_CHECK_VERSION(2,12,0)
    gtk_widget_set_tooltip_text( GTK_WIDGET(toolitem), "Particle diagnostics" );
#endif
    gtk_tool_button_set_icon_widget( GTK_TOOL_BUTTON(toolitem), icon );
    gtk_toolbar_insert( GTK_TOOLBAR(_toolbar), toolitem, -1 );
    g_signal_connect( G_OBJECT(toolitem), "toggled",
		      G_CALLBACK(menuitem_tool_change_signal),
		      (gpointer)this );

    // Creating "Field diagnostics" button
    pixbuf = gdk_pixbuf_new_from_inline( -1, icon_field_diag_inline, FALSE, NULL );
    icon = gtk_image_new_from_pixbuf( pixbuf );
    toolitem = gtk_radio_tool_button_new_from_widget( GTK_RADIO_TOOL_BUTTON(_radioitem) );
    gtk_tool_button_set_label( GTK_TOOL_BUTTON(toolitem), "Field diagnostics" );
#if GTK_CHECK_VERSION(2,12,0)
    gtk_widget_set_tooltip_text( GTK_WIDGET(toolitem), "Field diagnostics" );
#endif
    gtk_tool_button_set_icon_widget( GTK_TOOL_BUTTON(toolitem), icon );
    gtk_toolbar_insert( GTK_TOOLBAR(_toolbar), toolitem, -1 );
    g_signal_connect( G_OBJECT(toolitem), "toggled",
		      G_CALLBACK(menuitem_tool_change_signal),
		      (gpointer)this );

    // Creating "Geom 3D" button
    pixbuf = gdk_pixbuf_new_from_inline( -1, icon_geom3d_inline, FALSE, NULL );
    icon = gtk_image_new_from_pixbuf( pixbuf );
    toolitem = gtk_tool_button_new( icon, "3D geometry view" );
#if GTK_CHECK_VERSION(2,12,0)
    gtk_widget_set_tooltip_text( GTK_WIDGET(toolitem), "3D geometry view" );
#endif
    gtk_toolbar_insert( GTK_TOOLBAR(_toolbar), toolitem, -1 );
    if( _geom.geom_mode() != MODE_3D || !_geom.surface_built() )
	gtk_widget_set_sensitive( GTK_WIDGET(toolitem), FALSE );
    g_signal_connect( G_OBJECT(toolitem), "clicked",
		      G_CALLBACK(menuitem_geom3d_signal),
		      (gpointer)this );

    // Creating separator
    toolitem = gtk_separator_tool_item_new();
    gtk_toolbar_insert( GTK_TOOLBAR(_toolbar), toolitem, -1 );

    // Creating view combobox and level spinbutton
    //_combobox = gtk_combo_box_new_text();
    _combobox = gtk_combo_box_text_new();
    if( geom.geom_mode() == MODE_3D ) {
	gtk_combo_box_text_append( GTK_COMBO_BOX_TEXT(_combobox), NULL, "XY" );
	gtk_combo_box_text_append( GTK_COMBO_BOX_TEXT(_combobox), NULL, "XZ" );
        gtk_combo_box_text_append( GTK_COMBO_BOX_TEXT(_combobox), NULL, "YX" );
        gtk_combo_box_text_append( GTK_COMBO_BOX_TEXT(_combobox), NULL, "YZ" );
        gtk_combo_box_text_append( GTK_COMBO_BOX_TEXT(_combobox), NULL, "ZX" );
        gtk_combo_box_text_append( GTK_COMBO_BOX_TEXT(_combobox), NULL, "ZY" );
	/*
	gtk_combo_box_append_text( GTK_COMBO_BOX(_combobox), "XY" );
	gtk_combo_box_append_text( GTK_COMBO_BOX(_combobox), "XZ" );
        gtk_combo_box_append_text( GTK_COMBO_BOX(_combobox), "YX" );
        gtk_combo_box_append_text( GTK_COMBO_BOX(_combobox), "YZ" );
        gtk_combo_box_append_text( GTK_COMBO_BOX(_combobox), "ZX" );
        gtk_combo_box_append_text( GTK_COMBO_BOX(_combobox), "ZY" );
	*/
	gtk_combo_box_set_active( GTK_COMBO_BOX(_combobox), 0 );
	_spinbutton = gtk_spin_button_new_with_range( 0, geom.size(2)-1, 1 );
	gtk_spin_button_set_value( GTK_SPIN_BUTTON(_spinbutton), geom.size(2)/2 );
	_geomplot.set_view( VIEW_XY, geom.size(2)/2 );
    } else {
	gtk_combo_box_text_append( GTK_COMBO_BOX_TEXT(_combobox), NULL, "XY" );
	gtk_combo_box_text_append( GTK_COMBO_BOX_TEXT(_combobox), NULL, "YX" );
        gtk_combo_box_set_active( GTK_COMBO_BOX(_combobox), 0 );
        _spinbutton = gtk_spin_button_new_with_range( 0, 0, 1 );
        gtk_spin_button_set_value( GTK_SPIN_BUTTON(_spinbutton), 0 );
    }
    toolitem = gtk_tool_item_new();
    gtk_container_add( GTK_CONTAINER(toolitem), _combobox );
    gtk_toolbar_insert( GTK_TOOLBAR(_toolbar), toolitem, -1 );
#if GTK_CHECK_VERSION(2,12,0)
    gtk_widget_set_tooltip_text( GTK_WIDGET(toolitem), "Select view direction" );
#endif

    gtk_spin_button_set_digits( GTK_SPIN_BUTTON(_spinbutton), 0 );
    toolitem = gtk_tool_item_new();
    gtk_container_add( GTK_CONTAINER(toolitem), _spinbutton );
    gtk_toolbar_insert( GTK_TOOLBAR(_toolbar), toolitem, -1 );
#if GTK_CHECK_VERSION(2,12,0)
    gtk_widget_set_tooltip_text( GTK_WIDGET(toolitem), "Select view level" );
#endif
    g_signal_connect( G_OBJECT(_combobox), "changed",
                      G_CALLBACK(combobox_signal),
                      (gpointer)this );
    g_signal_connect( G_OBJECT(_spinbutton), "value-changed",
                      G_CALLBACK(spinbutton_signal),
                      (gpointer)this );

    // Drawing area signals
    g_signal_connect( G_OBJECT(_darea), "button_press_event",
		      G_CALLBACK(darea_button_signal2),
		      (gpointer)this );
    g_signal_connect( G_OBJECT(_darea), "button_release_event",
		      G_CALLBACK(darea_button_signal2),
		      (gpointer)this );
    g_signal_connect( G_OBJECT(_darea), "motion_notify_event",
		      G_CALLBACK(darea_motion_signal2),
		      (gpointer)this );

    update_view();
    show();
}
コード例 #29
0
ファイル: toolbar.cpp プロジェクト: GuyXY/wxWidgets
bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
{
    wxToolBarTool* tool = static_cast<wxToolBarTool*>(toolBase);

    GSList* radioGroup;
    GtkWidget* bin_child;
    switch ( tool->GetStyle() )
    {
        case wxTOOL_STYLE_BUTTON:
            switch (tool->GetKind())
            {
                case wxITEM_CHECK:
                    tool->m_item = gtk_toggle_tool_button_new();
                    g_signal_connect(tool->m_item, "toggled",
                        G_CALLBACK(item_toggled), tool);
                    break;
                case wxITEM_RADIO:
                    radioGroup = GetRadioGroup(pos);
                    if (!radioGroup)
                    {
                        // this is the first button in the radio button group,
                        // it will be toggled automatically by GTK so bring the
                        // internal flag in sync
                        tool->Toggle(true);
                    }
                    tool->m_item = gtk_radio_tool_button_new(radioGroup);
                    g_signal_connect(tool->m_item, "toggled",
                        G_CALLBACK(item_toggled), tool);
                    break;
                default:
                    wxFAIL_MSG("unknown toolbar child type");
                    // fall through
                case wxITEM_DROPDOWN:
                case wxITEM_NORMAL:
                    tool->m_item = gtk_tool_button_new(NULL, "");
                    g_signal_connect(tool->m_item, "clicked",
                        G_CALLBACK(item_clicked), tool);
                    break;
            }
            if (!HasFlag(wxTB_NOICONS))
            {
                GtkWidget* image = gtk_image_new();
                gtk_tool_button_set_icon_widget(
                    GTK_TOOL_BUTTON(tool->m_item), image);
                tool->SetImage();
                gtk_widget_show(image);
#ifdef __WXGTK3__
                g_signal_connect(image, "draw",
                    G_CALLBACK(image_draw), tool);
#else
                g_signal_connect(image, "expose_event",
                    G_CALLBACK(image_expose_event), tool);
#endif
            }
            if (!tool->GetLabel().empty())
            {
                gtk_tool_button_set_label(
                    GTK_TOOL_BUTTON(tool->m_item), wxGTK_CONV(tool->GetLabel()));
                // needed for labels in horizontal toolbar with wxTB_HORZ_LAYOUT
                gtk_tool_item_set_is_important(tool->m_item, true);
            }
            if (!HasFlag(wxTB_NO_TOOLTIPS) && !tool->GetShortHelp().empty())
            {
#if GTK_CHECK_VERSION(2, 12, 0)
                if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,12,0) == NULL)
                {
                    gtk_tool_item_set_tooltip_text(tool->m_item,
                        wxGTK_CONV(tool->GetShortHelp()));
                }
                else
#endif
                {
#ifndef __WXGTK3__
                    gtk_tool_item_set_tooltip(tool->m_item,
                        m_tooltips, wxGTK_CONV(tool->GetShortHelp()), "");
#endif
                }
            }
            bin_child = gtk_bin_get_child(GTK_BIN(tool->m_item));
            g_signal_connect(bin_child, "button_press_event",
                G_CALLBACK(button_press_event), tool);
            g_signal_connect(bin_child, "enter_notify_event",
                G_CALLBACK(enter_notify_event), tool);
            g_signal_connect(bin_child, "leave_notify_event",
                G_CALLBACK(enter_notify_event), tool);

            if (tool->GetKind() == wxITEM_DROPDOWN)
                tool->CreateDropDown();
            gtk_toolbar_insert(m_toolbar, tool->m_item, int(pos));
            break;

        case wxTOOL_STYLE_SEPARATOR:
            tool->m_item = gtk_separator_tool_item_new();
            if ( tool->IsStretchable() )
            {
                gtk_separator_tool_item_set_draw
                (
                    GTK_SEPARATOR_TOOL_ITEM(tool->m_item),
                    FALSE
                );
                gtk_tool_item_set_expand(tool->m_item, TRUE);
            }
            gtk_toolbar_insert(m_toolbar, tool->m_item, int(pos));
            break;

        case wxTOOL_STYLE_CONTROL:
            wxWindow* control = tool->GetControl();
            if (gtk_widget_get_parent(control->m_widget) == NULL)
                AddChildGTK(control);
            tool->m_item = GTK_TOOL_ITEM(gtk_widget_get_parent(gtk_widget_get_parent(control->m_widget)));
            if (gtk_toolbar_get_item_index(m_toolbar, tool->m_item) != int(pos))
            {
                g_object_ref(tool->m_item);
                gtk_container_remove(
                    GTK_CONTAINER(m_toolbar), GTK_WIDGET(tool->m_item));
                gtk_toolbar_insert(m_toolbar, tool->m_item, int(pos));
                g_object_unref(tool->m_item);
            }
            break;
    }
    gtk_widget_show(GTK_WIDGET(tool->m_item));

    InvalidateBestSize();

    return true;
}
コード例 #30
0
ファイル: queuehandler.c プロジェクト: artifexor/HandBrake
void
ghb_queue_buttons_grey(signal_user_data_t *ud)
{
    GtkWidget *widget;
    GtkAction *action;
    gint queue_count;
    gint titleindex;
    gint queue_state, scan_state;
    gboolean show_start, show_stop, paused;

    queue_count = ghb_array_len(ud->queue);
    titleindex = ghb_settings_combo_int(ud->settings, "title");

    queue_state = ghb_get_queue_state();
    scan_state = ghb_get_scan_state();

    show_stop = queue_state & 
                (GHB_STATE_WORKING | GHB_STATE_SEARCHING | 
                 GHB_STATE_SCANNING | GHB_STATE_MUXING);
    show_start = !(scan_state & GHB_STATE_SCANNING) && 
                    (titleindex >= 0 || queue_count > 0);


    paused = queue_state & GHB_STATE_PAUSED;

    widget = GHB_WIDGET(ud->builder, "queue_add");
    gtk_widget_set_sensitive(widget, show_start);
    action = GHB_ACTION(ud->builder, "queue_add_menu");
    gtk_action_set_sensitive(action, show_start);
    action = GHB_ACTION(ud->builder, "queue_add_all_menu");
    gtk_action_set_sensitive(action, show_start);

    widget = GHB_WIDGET (ud->builder, "queue_start1");
    if (show_stop)
    {
        gtk_widget_set_sensitive (widget, TRUE);
        gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-stop");
        gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Stop");
        gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Stop Encoding");
    }
    else
    {
        gtk_widget_set_sensitive (widget, show_start);
        gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-start");
        gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Start");
        gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Start Encoding");
    }
    widget = GHB_WIDGET (ud->builder, "queue_start2");
    if (show_stop)
    {
        gtk_widget_set_sensitive (widget, TRUE);
        gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-stop");
        gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Stop");
        gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Stop Encoding");
    }
    else
    {
        gtk_widget_set_sensitive (widget, show_start);
        gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-start");
        gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Start");
        gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Start Encoding");
    }
    widget = GHB_WIDGET (ud->builder, "queue_pause1");
    if (paused)
    {
        gtk_widget_set_sensitive (widget, show_stop);
        gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-start");
        gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Resume");
        gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Resume Encoding");
    }
    else
    {
        gtk_widget_set_sensitive (widget, show_stop);
        gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-pause");
        gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Pause");
        gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Pause Encoding");
    }
    widget = GHB_WIDGET (ud->builder, "queue_pause2");
    if (paused)
    {
        gtk_widget_set_sensitive (widget, show_stop);
        gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-start");
        gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Resume");
        gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Resume Encoding");
    }
    else
    {
        gtk_widget_set_sensitive (widget, show_stop);
        gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-pause");
        gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Pause");
        gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Pause Encoding");
    }

    action = GHB_ACTION (ud->builder, "queue_start_menu");
    if (show_stop)
    {
        gtk_action_set_sensitive (action, TRUE);
#if GTK_CHECK_VERSION(2, 16, 0)
        gtk_action_set_icon_name(action, "hb-stop");
        gtk_action_set_label(action, "S_top Queue");
        gtk_action_set_tooltip(action, "Stop Encoding");
#else
        g_object_set_property(G_OBJECT(action), "icon-name", 
                                            ghb_string_value("hb-stop"));
        g_object_set_property(G_OBJECT(action), "label",
                                            ghb_string_value("S_top Queue"));
        g_object_set_property(G_OBJECT(action), "tooltip",
                                            ghb_string_value("Stop Encoding"));
#endif
    }
    else
    {
        gtk_action_set_sensitive (action, show_start);
#if GTK_CHECK_VERSION(2, 16, 0)
        gtk_action_set_icon_name(action, "hb-start");
        gtk_action_set_label(action, "_Start Queue");
        gtk_action_set_tooltip(action, "Start Encoding");
#else
        g_object_set_property(G_OBJECT(action), "icon-name", 
                                            ghb_string_value("hb-start"));
        g_object_set_property(G_OBJECT(action), "label",
                                            ghb_string_value("_Start Queue"));
        g_object_set_property(G_OBJECT(action), "tooltip",
                                            ghb_string_value("Start Encoding"));
#endif
    }
    action = GHB_ACTION (ud->builder, "queue_pause_menu");
    if (paused)
    {
        gtk_action_set_sensitive (action, show_start);
#if GTK_CHECK_VERSION(2, 16, 0)
        gtk_action_set_icon_name(action, "hb-start");
        gtk_action_set_label(action, "_Resume Queue");
        gtk_action_set_tooltip(action, "Resume Encoding");
#else
        g_object_set_property(G_OBJECT(action), "icon-name", 
                                        ghb_string_value("hb-start"));
        g_object_set_property(G_OBJECT(action), "label",
                                        ghb_string_value("_Resume Queue"));
        g_object_set_property(G_OBJECT(action), "tooltip",
                                        ghb_string_value("Resume Encoding"));
#endif
    }
    else
    {
        gtk_action_set_sensitive (action, show_stop);
#if GTK_CHECK_VERSION(2, 16, 0)
        gtk_action_set_icon_name(action, "hb-pause");
        gtk_action_set_label(action, "_Pause Queue");
        gtk_action_set_tooltip(action, "Pause Encoding");
#else
        g_object_set_property(G_OBJECT(action), "icon-name", 
                                        ghb_string_value("hb-pause"));
        g_object_set_property(G_OBJECT(action), "label",
                                        ghb_string_value("_Pause Queue"));
        g_object_set_property(G_OBJECT(action), "tooltip",
                                        ghb_string_value("Pause Encoding"));
#endif
    }
}