GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Can't seem to load GnomeAppBar

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
jnavratil



Joined: 18 Aug 2008
Posts: 4

PostPosted: Mon Aug 18, 2008 12:48 am    Post subject: Can't seem to load GnomeAppBar Reply with quote

Greetings!

I'm fairly new to GTK having written a single app using glade-2 and the generated C code. I'm updating the app and wish to use glade-3 for several reasons. I found that I could create an interface and a simple app consisting of a menubar, a toolbar and several other structures with nothing but the on_window_destroy event coded until I added a GnomeAppBar.

Without the GnomeAppBar, the app rendered as expected and the 'destroy' icon properly called the coded callback. After adding the GnomeAppBar to the UI, nothing appeared to render (menus,buttons) and clicking the 'destroy' icon caused the window to be destroyed, but the app continued to run and the on_window_destroy function was never called.

I'm using Fedora 9 on a 32-bit athlon. I'm compiling with -Wall and receiving no errors or warnings. The app isn't coring, it just requires a ^C from the command line to quit.

The code is from a tutorial and is..

Code: (Plaintext)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <gtk/gtk.h>
 
void
on_window_destroy (GtkObject *object, gpointer user_data)
{
        gtk_main_quit();
}
 
int
main (int argc, char *argv[])
{
        GtkBuilder              *builder;
        GtkWidget               *window;
       
        gtk_init (&argc, &argv);
       
        builder = gtk_builder_new ();
        gtk_builder_add_from_file (builder, "blender.xml", NULL);
 
        window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
        gtk_builder_connect_signals (builder, NULL);         
        g_object_unref (G_OBJECT (builder));
       
        gtk_widget_show (window);       
        gtk_main ();

        return 0;
}
Back to top
dreblen
Never Seen the Sunlight


Joined: 14 Jun 2007
Posts: 643
Location: Falun, WI USA

PostPosted: Mon Aug 18, 2008 3:50 pm    Post subject: Reply with quote

it would be a big help if you posted your "blender.xml" file as well
Back to top
jnavratil



Joined: 18 Aug 2008
Posts: 4

PostPosted: Sun Aug 24, 2008 4:38 pm    Post subject: Reply with quote

Minor code change from initial posting, including change to name of xml file.

main.c ....

Code: (Plaintext)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

#include <gtk/gtk.h>
 
void
on_window_destroy (GtkObject *object, gpointer user_data)
{
    printf("Destroying...\n");
        gtk_main_quit();
}

void
on_btnPlay_clicked (GtkToolButton *toolbutton, gpointer user_data)
{
}

 
int
main (int argc, char *argv[])
{
        GtkBuilder              *builder;
        GtkWidget               *window;
       
        gtk_init (&argc, &argv);
       
        builder = gtk_builder_new ();
        gtk_builder_add_from_file (builder, "appBarError.xml", NULL);
 
        window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
        gtk_builder_connect_signals (builder, NULL);         
        g_object_unref (G_OBJECT (builder));
       
        gtk_widget_show (window);       
        gtk_main ();

        return 0;
}


appBarError.xml ....

Code: (Plaintext)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<?xml version="1.0"?>
<!--Generated with glade3 3.4.4 on Sun Aug 24 11:29:04 2008 -->
<interface>
  <object class="GtkUIManager" id="uimanager1">
    <child>
      <object class="GtkActionGroup" id="actiongroup1">
        <child>
          <object class="GtkAction" id="menuitem1">
            <property name="name">menuitem1</property>
            <property name="label" translatable="yes">_File</property>
          </object>
        </child>
        <child>
          <object class="GtkAction" id="imagemenuitem1">
            <property name="stock_id" translatable="yes">gtk-new</property>
            <property name="name">imagemenuitem1</property>
          </object>
        </child>
        <child>
          <object class="GtkAction" id="imagemenuitem2">
            <property name="stock_id" translatable="yes">gtk-open</property>
            <property name="name">imagemenuitem2</property>
          </object>
        </child>
        <child>
          <object class="GtkAction" id="imagemenuitem3">
            <property name="stock_id" translatable="yes">gtk-save</property>
            <property name="name">imagemenuitem3</property>
          </object>
        </child>
        <child>
          <object class="GtkAction" id="imagemenuitem4">
            <property name="stock_id" translatable="yes">gtk-save-as</property>
            <property name="name">imagemenuitem4</property>
          </object>
        </child>
        <child>
          <object class="GtkAction" id="imagemenuitem5">
            <property name="stock_id" translatable="yes">gtk-quit</property>
            <property name="name">imagemenuitem5</property>
          </object>
        </child>
        <child>
          <object class="GtkAction" id="menuitem2">
            <property name="name">menuitem2</property>
            <property name="label" translatable="yes">_Edit</property>
          </object>
        </child>
        <child>
          <object class="GtkAction" id="imagemenuitem6">
            <property name="stock_id" translatable="yes">gtk-cut</property>
            <property name="name">imagemenuitem6</property>
          </object>
        </child>
        <child>
          <object class="GtkAction" id="imagemenuitem7">
            <property name="stock_id" translatable="yes">gtk-copy</property>
            <property name="name">imagemenuitem7</property>
          </object>
        </child>
        <child>
          <object class="GtkAction" id="imagemenuitem8">
            <property name="stock_id" translatable="yes">gtk-paste</property>
            <property name="name">imagemenuitem8</property>
          </object>
        </child>
        <child>
          <object class="GtkAction" id="imagemenuitem9">
            <property name="stock_id" translatable="yes">gtk-delete</property>
            <property name="name">imagemenuitem9</property>
          </object>
        </child>
        <child>
          <object class="GtkAction" id="menuitem3">
            <property name="name">menuitem3</property>
            <property name="label" translatable="yes">_View</property>
          </object>
        </child>
        <child>
          <object class="GtkAction" id="menuitem4">
            <property name="name">menuitem4</property>
            <property name="label" translatable="yes">_Help</property>
          </object>
        </child>
        <child>
          <object class="GtkAction" id="imagemenuitem10">
            <property name="stock_id" translatable="yes">gtk-about</property>
            <property name="name">imagemenuitem10</property>
          </object>
        </child>
      </object>
    </child>
    <ui>
      <menubar name="menubar1">
        <menu action="menuitem1">
          <menuitem action="imagemenuitem1"/>
          <menuitem action="imagemenuitem2"/>
          <menuitem action="imagemenuitem3"/>
          <menuitem action="imagemenuitem4"/>
          <separator/>
          <menuitem action="imagemenuitem5"/>
        </menu>
        <menu action="menuitem2">
          <menuitem action="imagemenuitem6"/>
          <menuitem action="imagemenuitem7"/>
          <menuitem action="imagemenuitem8"/>
          <menuitem action="imagemenuitem9"/>
        </menu>
        <menuitem action="menuitem3"/>
        <menu action="menuitem4">
          <menuitem action="imagemenuitem10"/>
        </menu>
      </menubar>
    </ui>
  </object>
  <object class="GtkWindow" id="window">
    <signal handler="on_window_destroy" name="destroy"/>
    <child>
      <object class="GtkVBox" id="vbox1">
        <property name="visible">True</property>
        <child>
          <object class="GtkMenuBar" constructor="uimanager1" id="menubar1">
            <property name="visible">True</property>
          </object>
          <packing>
            <property name="expand">False</property>
          </packing>
        </child>
        <child>
          <object class="GtkToolbar" id="toolbar1">
            <property name="visible">True</property>
            <child>
              <object class="GtkToolButton" id="btnQuit">
                <property name="visible">True</property>
                <property name="stock_id">gtk-quit</property>
              </object>
              <packing>
                <property name="expand">False</property>
              </packing>
            </child>
            <child>
              <object class="GtkToolButton" id="btnClear">
                <property name="visible">True</property>
                <property name="stock_id">gtk-clear</property>
              </object>
              <packing>
                <property name="expand">False</property>
              </packing>
            </child>
            <child>
              <object class="GtkToolButton" id="btnExecute">
                <property name="visible">True</property>
                <property name="stock_id">gtk-execute</property>
              </object>
              <packing>
                <property name="expand">False</property>
              </packing>
            </child>
            <child>
              <object class="GtkToolButton" id="btnPlay">
                <property name="visible">True</property>
                <property name="stock_id">gtk-media-play</property>
                <signal handler="on_btnPlay_clicked" name="clicked"/>
              </object>
              <packing>
                <property name="expand">False</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="position">1</property>
          </packing>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <placeholder/>
        </child>
        <child>
          <object class="GnomeAppBar" id="appbar1">
            <property name="visible">True</property>
            <property name="spacing">4</property>
            <property name="has_progress">True</property>
            <property name="has_status">True</property>
          </object>
          <packing>
            <property name="position">6</property>
          </packing>
        </child>
      </object>
    </child>
  </object>
</interface>


Remove the 'GnoreAppBar' object and things appear to work properly. The difference between the failing xml file and a successful one is...

Code: (Plaintext)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
188,196c188
<           <object class="GnomeAppBar" id="appbar1">
<             <property name="visible">True</property>
<             <property name="spacing">4</property>
<             <property name="has_progress">True</property>
<             <property name="has_status">True</property>
<           </object>
<           <packing>
<             <property name="position">6</property>
<           </packing>
---
>           <placeholder/>

Back to top
dreblen
Never Seen the Sunlight


Joined: 14 Jun 2007
Posts: 643
Location: Falun, WI USA

PostPosted: Sun Aug 24, 2008 7:10 pm    Post subject: Reply with quote

it seems to work if you change
Code: (XML/HTML)
1
<object class="GnomeAppBar" id="appbar1">

to
Code: (XML/HTML)
1
<object class="GnomeAppbar" id="appbar1">

all you need to do is change the B in AppBar to a b
Back to top
jnavratil



Joined: 18 Aug 2008
Posts: 4

PostPosted: Mon Aug 25, 2008 1:54 pm    Post subject: Reply with quote

Thanks for the response, but no joy. I'm getting the same behaviour. I tried removing the properties and generally mucked about with the class name with the same result. It seems that I am missing something in my installation but, at the same time, gtk_builder_add_from_file may have a bug. Prior to renaming the GnomeAppBar class name, did you observe the behaviour that I did; a window with no menu or tool bar and an unhandled on_window_destroy event?
Back to top
dreblen
Never Seen the Sunlight


Joined: 14 Jun 2007
Posts: 643
Location: Falun, WI USA

PostPosted: Mon Aug 25, 2008 2:54 pm    Post subject: Reply with quote

yes, prior to changing the class name I had the same behavior.

are you compiling with
Code: (Plaintext)
1
`pkg-config --cflags --libs libgnomeui-2.0`

and are you #including <gnome.h>?
I don't know if these are necessary, but that's what I was compiling with.
You also need to compile with -export-dynamic for the callbacks to be found
Back to top
errol



Joined: 28 Apr 2008
Posts: 2
Location: UK

PostPosted: Mon Aug 25, 2008 3:20 pm    Post subject: Reply with quote

GnomeAppBar is a GNOME widget, so you will need to initialise GNOME using gnome_init() before you can use it. The current example is only initialising GTK. You could alternatively use GtkStatusBar instead, if you do not need the progress bar or add a progress bar to it if you really need it.
Back to top
dreblen
Never Seen the Sunlight


Joined: 14 Jun 2007
Posts: 643
Location: Falun, WI USA

PostPosted: Mon Aug 25, 2008 3:32 pm    Post subject: Reply with quote

good point, although I believe that gnome_init is deprecated and gnome_program_init is to be used instead
http://library.gnome.org/devel/libgnomeui/stable/libgnomeui-gnome-ui-init.html
http://library.gnome.org/devel/libgnome/stable/libgnome-gnome-program.html#gnome-program-init
Back to top
jnavratil



Joined: 18 Aug 2008
Posts: 4

PostPosted: Tue Aug 26, 2008 1:12 am    Post subject: Reply with quote

Thanks for everyone's help. While my application is far from complete or even minimally tested, I am focusing on the specific failure I encountered.. With that in mind, I report that I did not need to #include <gnome.h> or call gnome_program_init in order to get a properly rendered UI. The object name change from GnomeAppBar to GnomeAppbar was required along with the following compile/link command....

Code: (Plaintext)
1
gcc -Wall -g -o sniffer main.c -export-dynamic `pkg-config --cflags --libs  libgnomeui-2.0`


Previously I had been using ....

Code: (Plaintext)
1
gcc -Wall -g -o sniffer main.c -export-dynamic `pkg-config --cflags --libs gtk+-2.0`


It seems that there may be two conflated issues...

(1) glade-3 / gtk-builder-convert generates a GnomeAppBar class name which appears to be invalid.

(2) gtk_builder_add_from_file() seems to fail without generating any errors when improperly linked.

Does anyone think either of these should be considered glade-3 bugs?
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP