]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/plugintoolbar.cpp
Merge commit '3a78d902017a780e65f21f12c709aa746dfcab84' into garux-merge
[xonotic/netradiant.git] / radiant / plugintoolbar.cpp
index a43fe9896b480d8b88a41d215a57549d79554e0c..e3c8cb95cd5ba72a00c9c5d8396ad6ebad07ef57 100644 (file)
 ui::Image new_plugin_image( const char* filename ){
        {
                StringOutputStream fullpath( 256 );
-               fullpath << GameToolsPath_get() << g_pluginsDir << "bitmaps/" << filename;
+               fullpath << AppPath_get() << g_pluginsDir << "bitmaps/" << filename;
                if ( auto image = image_new_from_file_with_mask(fullpath.c_str()) ) return image;
        }
 
        {
                StringOutputStream fullpath( 256 );
-               fullpath << AppPath_get() << g_pluginsDir << "bitmaps/" << filename;
+               fullpath << GameToolsPath_get() << g_pluginsDir << "bitmaps/" << filename;
                if ( auto image = image_new_from_file_with_mask(fullpath.c_str()) ) return image;
        }
 
@@ -57,21 +57,30 @@ ui::Image new_plugin_image( const char* filename ){
 
 void toolbar_insert( ui::Toolbar toolbar, const char* icon, const char* text, const char* tooltip, IToolbarButton::EType type, GCallback handler, gpointer data ){
        if (type == IToolbarButton::eSpace) {
-               auto it = ui::ToolItem(gtk_separator_tool_item_new());
+               auto it = ui::ToolItem::from(gtk_separator_tool_item_new());
                it.show();
                toolbar.add(it);
                return;
        }
+       #define GARUX_DISABLE_SPACER_NOFOCUS
+       #ifndef GARUX_DISABLE_SPACER_NOFOCUS
+       else {
+               GTK_WIDGET_UNSET_FLAGS( widget, GTK_CAN_FOCUS );
+               GTK_WIDGET_UNSET_FLAGS( widget, GTK_CAN_DEFAULT );
+       }
+       #endif // GARUX_DISABLE_SPACER_NOFOCUS
+
        if (type == IToolbarButton::eButton) {
-               auto button = ui::ToolButton(GTK_TOOL_BUTTON(gtk_tool_button_new(new_plugin_image(icon), text)));
+               auto button = ui::ToolButton::from(gtk_tool_button_new(new_plugin_image(icon), text));
                gtk_widget_set_tooltip_text(button, tooltip);
                gtk_widget_show_all(button);
                button.connect("clicked", G_CALLBACK(handler), data);
                toolbar.add(button);
                return;
        }
+
        if (type == IToolbarButton::eToggleButton) {
-               auto button = ui::ToolButton(GTK_TOOL_BUTTON(gtk_toggle_tool_button_new()));
+               auto button = ui::ToolButton::from(gtk_toggle_tool_button_new());
                gtk_tool_button_set_icon_widget(button, new_plugin_image(icon));
                gtk_tool_button_set_label(button, text);
                gtk_widget_set_tooltip_text(button, tooltip);
@@ -80,6 +89,7 @@ void toolbar_insert( ui::Toolbar toolbar, const char* icon, const char* text, co
                toolbar.add(button);
                return;
        }
+
        ERROR_MESSAGE( "invalid toolbar button type" );
 }
 
@@ -120,9 +130,10 @@ void PluginToolbar_clear(){
 
 ui::Toolbar create_plugin_toolbar(){
 
-       auto toolbar = ui::Toolbar(GTK_TOOLBAR( gtk_toolbar_new() ));
+       auto toolbar = ui::Toolbar::from( gtk_toolbar_new() );
        gtk_orientable_set_orientation( GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL );
        gtk_toolbar_set_style( toolbar, GTK_TOOLBAR_ICONS );
+//     gtk_toolbar_set_show_arrow( toolbar, TRUE );
        toolbar.show();
 
        g_plugin_toolbar = toolbar;