File indexing completed on 2024-05-05 05:34:56

0001 
0002 /*
0003 * this file is part of the oxygen gtk engine
0004 * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
0005 *
0006 * based on the Null Theme Engine for Gtk+.
0007 * SPDX-FileCopyrightText: 2008 Robert Staudinger <robert.staudinger@gmail.com>
0008 *
0009 * SPDX-License-Identifier: LGPL-2.0-or-later
0010 */
0011 
0012 #include "oxygendemowidget.h"
0013 
0014 namespace Oxygen
0015 {
0016 
0017     //_______________________________________________________
0018     void DemoWidget::realize( void )
0019     {
0020         assert( !_mainWidget );
0021         assert( _widget );
0022 
0023         // create main widget (vbox)
0024         _mainWidget = gtk_vbox_new( false, 0 );
0025         gtk_box_set_spacing( GTK_BOX( _mainWidget ), 10 );
0026         gtk_widget_show( _mainWidget );
0027 
0028         // horizontal box
0029         GtkWidget* hbox( gtk_hbox_new( false, 0 ) );
0030         gtk_box_pack_start( GTK_BOX( _mainWidget ), hbox, false, true, 0 );
0031         gtk_widget_show( hbox );
0032 
0033         // label
0034         std::string comments( _comments.empty() ? _name:_comments );
0035         GtkWidget* label( gtk_label_new( comments.c_str() ) );
0036 
0037         PangoAttrList* attributes( pango_attr_list_new() );
0038         pango_attr_list_insert( attributes, pango_attr_weight_new( PANGO_WEIGHT_BOLD ) );
0039         gtk_label_set_attributes( GTK_LABEL( label ), attributes );
0040         pango_attr_list_unref( attributes );
0041 
0042         gtk_box_pack_start( GTK_BOX( hbox ), label, false, true, 0 );
0043 
0044         gtk_widget_show( label );
0045 
0046         // icon
0047         if( !_iconName.empty() )
0048         {
0049             GtkIconTheme* theme( gtk_icon_theme_get_default() );
0050             GdkPixbuf* icon( gtk_icon_theme_load_icon( theme, _iconName.c_str(), 22, (GtkIconLookupFlags) 0, 0L ) );
0051             GtkWidget* image( gtk_image_new_from_pixbuf( icon ) );
0052             gtk_box_pack_end( GTK_BOX( hbox ), image, false, false, 0 );
0053             gtk_widget_show( image );
0054 
0055         }
0056 
0057         // main content
0058         gtk_box_pack_start( GTK_BOX( _mainWidget ), _widget, true, true, 0 );
0059         gtk_widget_show( _widget );
0060     }
0061 }