static VALUE rg_insert_space(VALUE self, VALUE pos) { gtk_toolbar_insert_space(_SELF(self), NUM2INT(pos)); return self; }
bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase) { wxToolBarTool *tool = (wxToolBarTool *)toolBase; // if we have inserted a space before all the tools we must change the GTK // index by 1 size_t posGtk = m_xMargin > 1 ? pos + 1 : pos; if ( tool->IsButton() ) { if ( !HasFlag(wxTB_NOICONS) ) { wxBitmap bitmap = tool->GetNormalBitmap(); wxCHECK_MSG( bitmap.Ok(), false, wxT("invalid bitmap for wxToolBar icon") ); wxCHECK_MSG( bitmap.GetBitmap() == NULL, false, wxT("wxToolBar doesn't support GdkBitmap") ); wxCHECK_MSG( bitmap.GetPixmap() != NULL, false, wxT("wxToolBar::Add needs a wxBitmap") ); GtkWidget *tool_pixmap = (GtkWidget *)NULL; GdkPixmap *pixmap = bitmap.GetPixmap(); GdkBitmap *mask = (GdkBitmap *)NULL; if ( bitmap.GetMask() ) mask = bitmap.GetMask()->GetBitmap(); tool_pixmap = gtk_pixmap_new( pixmap, mask ); gtk_pixmap_set_build_insensitive( GTK_PIXMAP(tool_pixmap), TRUE ); gtk_misc_set_alignment( GTK_MISC(tool_pixmap), 0.5, 0.5 ); tool->m_pixmap = tool_pixmap; } } switch ( tool->GetStyle() ) { case wxTOOL_STYLE_BUTTON: // for a radio button we need the widget which starts the radio // group it belongs to, i.e. the first radio button immediately // preceding this one { GtkWidget *widget = NULL; if ( tool->IsRadio() ) { wxToolBarToolsList::compatibility_iterator node = wxToolBarToolsList::compatibility_iterator(); if ( pos ) node = m_tools.Item(pos - 1); while ( node ) { wxToolBarTool *toolNext = (wxToolBarTool *)node->GetData(); if ( !toolNext->IsRadio() ) break; widget = toolNext->m_item; node = node->GetPrevious(); } if ( !widget ) { // 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_toolbar_insert_element ( m_toolbar, tool->GetGtkChildType(), widget, tool->GetLabel().empty() ? NULL : (const char*) wxGTK_CONV( tool->GetLabel() ), tool->GetShortHelp().empty() ? NULL : (const char*) wxGTK_CONV( tool->GetShortHelp() ), "", // tooltip_private_text (?) tool->m_pixmap, (GtkSignalFunc)gtk_toolbar_callback, (gpointer)tool, posGtk ); if ( !tool->m_item ) { wxFAIL_MSG( _T("gtk_toolbar_insert_element() failed") ); return false; } gtk_signal_connect( GTK_OBJECT(tool->m_item), "enter_notify_event", GTK_SIGNAL_FUNC(gtk_toolbar_tool_callback), (gpointer)tool ); gtk_signal_connect( GTK_OBJECT(tool->m_item), "leave_notify_event", GTK_SIGNAL_FUNC(gtk_toolbar_tool_callback), (gpointer)tool ); } break; case wxTOOL_STYLE_SEPARATOR: gtk_toolbar_insert_space( m_toolbar, posGtk ); // skip the rest return true; case wxTOOL_STYLE_CONTROL: gtk_toolbar_insert_widget( m_toolbar, tool->GetControl()->m_widget, (const char *) NULL, (const char *) NULL, posGtk ); break; } GtkRequisition req; (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request ) (m_widget, &req ); m_width = req.width + m_xMargin; m_height = req.height + 2*m_yMargin; InvalidateBestSize(); return true; }
static DebugWindow * debug_window_new(void) { DebugWindow *win; GtkWidget *vbox; GtkWidget *toolbar; GtkWidget *sw; GtkWidget *button; GtkWidget *image; int width, height; win = g_new0(DebugWindow, 1); width = gaim_prefs_get_int("/gaim/gtk/debug/width"); height = gaim_prefs_get_int("/gaim/gtk/debug/height"); GAIM_DIALOG(win->window); gaim_debug(GAIM_DEBUG_INFO, "gtkdebug", "Setting dimensions to %d, %d\n", width, height); gtk_window_set_default_size(GTK_WINDOW(win->window), width, height); gtk_window_set_role(GTK_WINDOW(win->window), "debug"); gtk_window_set_title(GTK_WINDOW(win->window), _("Debug Window")); g_signal_connect(G_OBJECT(win->window), "delete_event", G_CALLBACK(debug_window_destroy), NULL); g_signal_connect(G_OBJECT(win->window), "configure_event", G_CALLBACK(configure_cb), win); /* Setup the vbox */ vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(win->window), vbox); if (gaim_prefs_get_bool("/gaim/gtk/debug/toolbar")) { /* Setup our top button bar thingie. */ toolbar = gtk_toolbar_new(); gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH_HORIZ); gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar), GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); /* Find button */ gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_FIND, NULL, NULL, G_CALLBACK(find_cb), win, -1); /* Save */ gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_SAVE, NULL, NULL, G_CALLBACK(save_cb), win, -1); /* Clear button */ gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_CLEAR, NULL, NULL, G_CALLBACK(clear_cb), win, -1); gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1); /* Pause */ image = gtk_image_new_from_stock(GAIM_STOCK_PAUSE, GTK_ICON_SIZE_MENU); button = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, _("Pause"), NULL, NULL, image, G_CALLBACK(pause_cb), win); /* Timestamps */ button = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, _("Timestamps"), NULL, NULL, NULL, G_CALLBACK(timestamps_cb), win); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), gaim_prefs_get_bool("/gaim/gtk/debug/timestamps")); win->timestamps_handle = gaim_prefs_connect_callback("/gaim/gtk/debug/timestamps", timestamps_pref_cb, button); } /* Now our scrolled window... */ sw = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); /* ... which has a gtkimhtml in it. */ win->text = gtk_imhtml_new(NULL, NULL); gtk_container_add(GTK_CONTAINER(sw), win->text); /* Pack it in... Not like that, sicko. */ gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); gtk_widget_show_all(win->window); return win; }