本文整理汇总了C++中GTK_TOOL_BUTTON函数的典型用法代码示例。如果您正苦于以下问题:C++ GTK_TOOL_BUTTON函数的具体用法?C++ GTK_TOOL_BUTTON怎么用?C++ GTK_TOOL_BUTTON使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GTK_TOOL_BUTTON函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: XOJ_CHECK_TYPE
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;
}
示例2: gb_toggle_tool_button_new
/*
* 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;
}
示例3: toggleTimer
/* Starts, pauses and continues the timer */
static void toggleTimer()
{
if (prefs.timer_is_clock)
return;
switch (timerMode)
{
case 0:
timer = g_timer_new();
timerMode = 1;
gtk_widget_set_sensitive(GTK_WIDGET(resetButton), FALSE);
gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(startButton),
GTK_STOCK_MEDIA_PAUSE);
break;
case 1:
g_timer_stop(timer);
timerMode = 2;
gtk_widget_set_sensitive(GTK_WIDGET(resetButton), TRUE);
gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(startButton),
GTK_STOCK_MEDIA_PLAY);
break;
case 2:
g_timer_continue(timer);
timerMode = 1;
gtk_widget_set_sensitive(GTK_WIDGET(resetButton), FALSE);
gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(startButton),
GTK_STOCK_MEDIA_PAUSE);
break;
}
}
示例4: XOJ_CHECK_TYPE
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();
}
示例5: gtk_tool_button_create_menu_proxy
static gboolean
gtk_tool_button_create_menu_proxy (GtkToolItem *item)
{
GtkToolButton *button = GTK_TOOL_BUTTON (item);
GtkWidget *menu_item;
GtkWidget *menu_image = NULL;
GtkStockItem stock_item;
gboolean use_mnemonic = TRUE;
const char *label;
if (_gtk_tool_item_create_menu_proxy (item))
return TRUE;
if (GTK_IS_LABEL (button->priv->label_widget))
{
label = gtk_label_get_label (GTK_LABEL (button->priv->label_widget));
use_mnemonic = gtk_label_get_use_underline (GTK_LABEL (button->priv->label_widget));
}
else if (button->priv->label_text)
{
label = button->priv->label_text;
use_mnemonic = button->priv->use_underline;
}
else if (button->priv->stock_id && gtk_stock_lookup (button->priv->stock_id, &stock_item))
{
label = stock_item.label;
}
else
{
label = "";
}
if (use_mnemonic)
menu_item = gtk_image_menu_item_new_with_mnemonic (label);
else
menu_item = gtk_image_menu_item_new_with_label (label);
if (GTK_IS_IMAGE (button->priv->icon_widget))
{
menu_image = clone_image_menu_size (GTK_IMAGE (button->priv->icon_widget),
gtk_widget_get_settings (GTK_WIDGET (button)));
}
else if (button->priv->stock_id)
{
menu_image = gtk_image_new_from_stock (button->priv->stock_id, GTK_ICON_SIZE_MENU);
}
if (menu_image)
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), menu_image);
g_signal_connect_closure_by_id (menu_item,
g_signal_lookup ("activate", G_OBJECT_TYPE (menu_item)), 0,
g_cclosure_new_object_swap (G_CALLBACK (gtk_button_clicked),
G_OBJECT (GTK_TOOL_BUTTON (button)->priv->button)),
FALSE);
gtk_tool_item_set_proxy_menu_item (GTK_TOOL_ITEM (button), MENU_ID, menu_item);
return TRUE;
}
示例6: ink_radio_action_create_tool_item
static GtkWidget* ink_radio_action_create_tool_item( GtkAction* action )
{
InkRadioAction* act = INK_RADIO_ACTION( action );
GtkWidget* item = GTK_RADIO_ACTION_CLASS(ink_radio_action_parent_class)->parent_class.parent_class.create_tool_item(action);
if ( act->private_data->iconId ) {
if ( GTK_IS_TOOL_BUTTON(item) ) {
GtkToolButton* button = GTK_TOOL_BUTTON(item);
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 {
// For now trigger a warning but don't do anything else
GtkToolButton* button = GTK_TOOL_BUTTON(item);
(void)button;
}
}
// TODO investigate if needed
gtk_widget_show_all( item );
return item;
}
示例7: ink_toggle_action_create_tool_item
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;
}
示例8: schema_browser_perspective_customize
static void
schema_browser_perspective_customize (BrowserPerspective *perspective, GtkToolbar *toolbar, GtkHeaderBar *header)
{
g_print ("%s ()\n", __FUNCTION__);
customization_data_init (G_OBJECT (perspective), toolbar, header);
/* add perspective's actions */
customization_data_add_actions (G_OBJECT (perspective), win_entries, G_N_ELEMENTS (win_entries));
/* add to toolbar */
GtkToolItem *titem;
titem = gtk_toggle_tool_button_new ();
gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (titem), "user-bookmarks-symbolic");
gtk_widget_set_tooltip_text (GTK_WIDGET (titem), _("Show favorites"));
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), titem, -1);
gtk_actionable_set_action_name (GTK_ACTIONABLE (titem), "win.show-favorites");
gtk_widget_show (GTK_WIDGET (titem));
customization_data_add_part (G_OBJECT (perspective), G_OBJECT (titem));
#ifdef HAVE_GOOCANVAS
titem = gtk_tool_button_new (NULL, NULL);
gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (titem), "tab-new-symbolic");
gtk_widget_set_tooltip_text (GTK_WIDGET (titem), _("Create a new diagram"));
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), titem, -1);
gtk_actionable_set_action_name (GTK_ACTIONABLE (titem), "win.action-diagram-new");
gtk_widget_show (GTK_WIDGET (titem));
customization_data_add_part (G_OBJECT (perspective), G_OBJECT (titem));
#endif
}
示例9: download_handle
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;
}
示例10: gtk_radio_tool_button_new_from_widget
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;
}
示例11: XOJ_CHECK_TYPE
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;
}
示例12: toolbar_connect_click
void toolbar_connect_click(gpointer data)
{
GtkToolButton *toolbar_connect = GTK_TOOL_BUTTON(data);
if (!c_core->GetSession()->IsConnected())
{
INFO("debug", "connect button pressed\n");
if(!request_auth(gres.window))
{
push_status_bar("Insert valid credentials!");
}
else
if(!c_core->Connect())
push_status_bar("Connection failed!");
return;
}
if(c_core->GetSession()->IsConnected())
{
INFO("debug", "disconnect button pressed\n");
c_core->GetSession()->ClearPassword();
if(!c_core->Disconnect())
push_status_bar("Disconnection failed!?");
}
}
示例13: changed_download_progress
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);
}
示例14: connect_proxy_cb
static void
connect_proxy_cb (GtkUIManager *manager,
GtkAction *action,
GtkWidget *proxy,
NautilusWindow *window)
{
GdkPixbuf *icon;
GtkWidget *widget;
if (GTK_IS_MENU_ITEM (proxy)) {
g_signal_connect (proxy, "select",
G_CALLBACK (menu_item_select_cb), window);
g_signal_connect (proxy, "deselect",
G_CALLBACK (menu_item_deselect_cb), window);
/* This is a way to easily get pixbufs into the menu items */
icon = g_object_get_data (G_OBJECT (action), "menu-icon");
if (icon != NULL) {
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy),
gtk_image_new_from_pixbuf (icon));
}
}
if (GTK_IS_TOOL_BUTTON (proxy)) {
icon = g_object_get_data (G_OBJECT (action), "toolbar-icon");
if (icon != NULL) {
widget = gtk_image_new_from_pixbuf (icon);
gtk_widget_show (widget);
gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (proxy),
widget);
}
}
}
示例15: interactive_canvas_drag_data_received
static void
interactive_canvas_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection,
guint info,
guint time,
gpointer data)
{
/* find the tool button which is the source of this DnD operation */
GtkWidget *palette = gtk_drag_get_source_widget (context);
GtkWidget *tool_item = NULL;
while (palette && !GTK_IS_TOOL_PALETTE (palette))
palette = gtk_widget_get_parent (palette);
if (palette)
tool_item = gtk_tool_palette_get_drag_item (GTK_TOOL_PALETTE (palette),
selection);
/* create a drop indicator when a tool button was found */
g_assert (NULL == drop_item);
if (GTK_IS_TOOL_ITEM (tool_item))
{
drop_item = canvas_item_new (widget, GTK_TOOL_BUTTON (tool_item), x, y);
gdk_drag_status (context, GDK_ACTION_COPY, time);
gtk_widget_queue_draw (widget);
}
}