JNIEXPORT jint JNICALL Java_org_gnome_gtk_GtkToolbar_gtk_1toolbar_1get_1item_1index ( JNIEnv* env, jclass cls, jlong _self, jlong _item ) { gint result; jint _result; GtkToolbar* self; GtkToolItem* item; // convert parameter self self = (GtkToolbar*) _self; // convert parameter item item = (GtkToolItem*) _item; // call function result = gtk_toolbar_get_item_index(self, item); // cleanup parameter self // cleanup parameter item // translate return value to JNI type _result = (jint) result; // and finally return _result; }
/** Inserts a toolbar item before the Quit button, or after the previous plugin toolbar item. * A separator is added on the first call to this function, and will be shown when @a item is * shown; hidden when @a item is hidden. * @note You should still destroy @a item yourself, usually in @ref plugin_cleanup(). * @param plugin Must be @ref geany_plugin. * @param item The item to add. */ GEANY_API_SYMBOL void plugin_add_toolbar_item(GeanyPlugin *plugin, GtkToolItem *item) { GtkToolbar *toolbar = GTK_TOOLBAR(main_widgets.toolbar); gint pos; GeanyAutoSeparator *autosep; g_return_if_fail(plugin); autosep = &plugin->priv->toolbar_separator; if (!autosep->widget) { GtkToolItem *sep; pos = toolbar_get_insert_position(); sep = gtk_separator_tool_item_new(); gtk_toolbar_insert(toolbar, sep, pos); autosep->widget = GTK_WIDGET(sep); toolbar_item_ref(sep); } else { pos = gtk_toolbar_get_item_index(toolbar, GTK_TOOL_ITEM(autosep->widget)); g_return_if_fail(pos >= 0); } gtk_toolbar_insert(toolbar, item, pos + autosep->item_count + 1); toolbar_item_ref(item); /* hide the separator widget if there are no toolbar items showing for the plugin */ ui_auto_separator_add_ref(autosep, GTK_WIDGET(item)); }
static void drag_data_delete_cb (GtkWidget *widget, GdkDragContext *context, EggEditableToolbar *etoolbar) { int pos, toolbar_pos; widget = gtk_widget_get_ancestor (widget, GTK_TYPE_TOOL_ITEM); g_return_if_fail (widget != NULL); g_return_if_fail (EGG_IS_EDITABLE_TOOLBAR (etoolbar)); pos = gtk_toolbar_get_item_index (GTK_TOOLBAR (gtk_widget_get_parent (widget)), GTK_TOOL_ITEM (widget)); toolbar_pos = get_toolbar_position (etoolbar, gtk_widget_get_parent (widget)); egg_toolbars_model_remove_item (etoolbar->priv->model, toolbar_pos, pos); }
static void remove_item_cb (GtkAction *action, EggEditableToolbar *etoolbar) { GtkWidget *toolitem = gtk_widget_get_ancestor (egg_editable_toolbar_get_selected (etoolbar), GTK_TYPE_TOOL_ITEM); int pos, toolbar_pos; toolbar_pos = get_toolbar_position (etoolbar, gtk_widget_get_parent (toolitem)); pos = gtk_toolbar_get_item_index (GTK_TOOLBAR (gtk_widget_get_parent (toolitem)), GTK_TOOL_ITEM (toolitem)); egg_toolbars_model_remove_item (etoolbar->priv->model, toolbar_pos, pos); if (egg_toolbars_model_n_items (etoolbar->priv->model, toolbar_pos) == 0) { egg_toolbars_model_remove_toolbar (etoolbar->priv->model, toolbar_pos); } }
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; }
void e_mail_shell_view_update_send_receive_menus (EMailShellView *mail_shell_view) { EMailShellViewPrivate *priv; EShellWindow *shell_window; EShellView *shell_view; GtkWidget *widget; const gchar *widget_path; g_return_if_fail (E_IS_MAIL_SHELL_VIEW (mail_shell_view)); priv = E_MAIL_SHELL_VIEW_GET_PRIVATE (mail_shell_view); shell_view = E_SHELL_VIEW (mail_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); if (!e_shell_view_is_active (shell_view)) { if (priv->send_receive_tool_item) { GtkWidget *toolbar; toolbar = e_shell_window_get_managed_widget ( shell_window, "/main-toolbar"); g_return_if_fail (toolbar != NULL); gtk_container_remove ( GTK_CONTAINER (toolbar), GTK_WIDGET (priv->send_receive_tool_item)); gtk_container_remove ( GTK_CONTAINER (toolbar), GTK_WIDGET (priv->send_receive_tool_separator)); priv->send_receive_tool_item = NULL; priv->send_receive_tool_separator = NULL; } return; } widget_path = "/main-menu/file-menu" "/mail-send-receiver/mail-send-receive-submenu"; widget = e_shell_window_get_managed_widget (shell_window, widget_path); if (widget != NULL) gtk_menu_item_set_submenu ( GTK_MENU_ITEM (widget), create_send_receive_submenu (mail_shell_view)); if (!priv->send_receive_tool_item) { GtkWidget *toolbar; GtkToolItem *tool_item; gint index; toolbar = e_shell_window_get_managed_widget ( shell_window, "/main-toolbar"); g_return_if_fail (toolbar != NULL); widget_path = "/main-toolbar/toolbar-actions/mail-send-receiver"; widget = e_shell_window_get_managed_widget ( shell_window, widget_path); g_return_if_fail (widget != NULL); index = gtk_toolbar_get_item_index ( GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (widget)); tool_item = gtk_separator_tool_item_new (); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), tool_item, index); gtk_widget_show (GTK_WIDGET (tool_item)); priv->send_receive_tool_separator = tool_item; tool_item = GTK_TOOL_ITEM ( e_menu_tool_button_new (_("Send / Receive"))); gtk_tool_item_set_is_important (tool_item, TRUE); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), tool_item, index); gtk_widget_show (GTK_WIDGET (tool_item)); priv->send_receive_tool_item = tool_item; e_binding_bind_property ( ACTION (MAIL_SEND_RECEIVE), "sensitive", tool_item, "sensitive", G_BINDING_SYNC_CREATE); } if (priv->send_receive_tool_item) gtk_menu_tool_button_set_menu ( GTK_MENU_TOOL_BUTTON (priv->send_receive_tool_item), create_send_receive_submenu (mail_shell_view)); }
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; }
gboolean configure_event_cb (GtkWidget *widget, GdkEvent *event, gpointer user_data) { GtkWidget *toolbar_widget; g_return_val_if_fail(widget != NULL && HILDON_IS_WINDOW(widget), FALSE); g_return_val_if_fail(event->type == GDK_CONFIGURE, FALSE); g_return_val_if_fail(user_data != NULL, FALSE); AppUIData *app_ui_data = (AppUIData *) user_data; GdkEventConfigure *configure_event = (GdkEventConfigure*)event; if (configure_event->height > configure_event->width) { /* Portrait mode */ app_ui_data->isPortrait = TRUE; gtk_tool_item_set_expand(app_ui_data->current_page_item, FALSE); if(app_ui_data->current_zoom_item != NULL) gtk_container_remove(app_ui_data->toolbar, app_ui_data->current_zoom_item); toolbar_widget = gtk_ui_manager_get_widget(app_ui_data->ui_manager, "/ToolBar/" "pdfv_me_menu_screen_zoom_out"); if (toolbar_widget != NULL) gtk_container_remove(app_ui_data->toolbar, toolbar_widget); toolbar_widget = gtk_ui_manager_get_widget(app_ui_data->ui_manager, "/ToolBar/" "pdfv_me_menu_screen_zoom_in"); if (toolbar_widget != NULL) gtk_container_remove(app_ui_data->toolbar, toolbar_widget); } else { /* Landscape mode */ app_ui_data->isPortrait = FALSE; gtk_tool_item_set_expand(app_ui_data->current_page_item, TRUE); if(gtk_toolbar_get_item_index(app_ui_data->toolbar, app_ui_data->current_zoom_item) != TOOLBAR_POS_CURRENT_ZOOM_WIDGET) { toolbar_widget = gtk_ui_manager_get_widget(app_ui_data->ui_manager, "/ToolBar/" "pdfv_me_menu_screen_zoom_out"); if (toolbar_widget != NULL) gtk_toolbar_insert(GTK_TOOLBAR(app_ui_data->toolbar), toolbar_widget, (TOOLBAR_POS_CURRENT_ZOOM_WIDGET-1)); if(app_ui_data->current_zoom_item != NULL) gtk_toolbar_insert(GTK_TOOLBAR(app_ui_data->toolbar), app_ui_data->current_zoom_item, TOOLBAR_POS_CURRENT_ZOOM_WIDGET); toolbar_widget = gtk_ui_manager_get_widget(app_ui_data->ui_manager, "/ToolBar/" "pdfv_me_menu_screen_zoom_in"); if (toolbar_widget != NULL) gtk_toolbar_insert(GTK_TOOLBAR(app_ui_data->toolbar), toolbar_widget, (TOOLBAR_POS_CURRENT_ZOOM_WIDGET+1)); } } return FALSE; }
static VALUE rg_item_index(VALUE self, VALUE item) { return INT2NUM(gtk_toolbar_get_item_index(_SELF(self), GTK_TOOL_ITEM(RVAL2GOBJ(item)))); }