[Glade-users] filechooserdialog
- From: ichapman at videotron.ca (Ian Chapman)
- Subject: [Glade-users] filechooserdialog
- Date: Tue, 22 Apr 2014 19:20:20 -0400
Hi,
I'm new to glade and have followed Micah's tutorial as far as it goes
and it is also behind Glade 3.14.2. The "gtk-builder-convert" is not
needed as glade 3.14.2 produces a glade file that the sample.c was able
to use. I changed "on_window_destroy (GtkObject *object, gpointer
user_data)" to "on_window_destroy (GObject *object, gpointer
user_data)". Also to be able to use the signals I had to add gmodule-2.0
to compile the program and also compiled with gtk+-3.0. So far so good,
file/new, save, save as print on my terminal as expected. Where I go
wrong is trying to use the top level "GtkFileChooserDialog". I created a
new "filedialog.glade" and "filedialog.c" and call it from my main.c
when file/open is clicked. It's sort of doing the right sort of thing
but is convoluted into a two stage process.
The first stage I get a chooser with the two buttons that I added. I
select a file and click the "filechooserbutton1" and I get a second file
chooser with open and cancel buttons that I did not add. I select
another file click open and the newly selected file prints on my
terminal like I expected.
How do I get to this second stage without going through the first
redundant stage? Putting the functionality of filechooserbutton1 into
file/open would be handy. I can send you my files if anyone would like
to sort out what I'm doing wrong. I've added two files that demo what
I'm seeing.
Thanks in advance. Ian.
//=================================
dialog.c
#include <gtk/gtk.h>
// gcc -Wall -g -o dialog dialog.c -export-dynamic `pkg-config --cflags
--libs gtk+-3.0 gmodule-2.0`
void
on_window_destroy (GObject *object, gpointer user_data)
{
printf("gtk main quit.\n");
gtk_main_quit();
}
void
clica(GtkFileChooser *filechooserbutton1){//this button was inserted
through Glade
// char cNome[250];
printf("\n clica clicked. \n");
gchar* cNome_pt =
gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(filechooserbutton1));
printf("\n cNome_pt = %s", cNome_pt);
printf("\n Exiting clica. \n");
gtk_main_quit ();
return; }
int
main (int argc, char *argv[])
{
GtkBuilder *builder;
GtkWidget *filechooserdialog;
gtk_init (&argc, &argv);
builder = gtk_builder_new ();
gtk_builder_add_from_file (builder, "dialog.glade", NULL);
filechooserdialog = GTK_WIDGET (gtk_builder_get_object (builder,
"filechooserdialog"));
gtk_builder_connect_signals (builder, NULL);
g_object_unref (G_OBJECT (builder));
gtk_widget_show (filechooserdialog);
gtk_main ();
return 0;
}
//=================================================
diolog.glade
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkFileChooserDialog" id="filechooserdialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="role">GtkFileChooserDialog</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="filechooserdialog-vbox1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="filechooserdialog-action_area1">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="button1">
<property name="label" translatable="yes">button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFileChooserButton" id="filechooserbutton1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<signal name="file-set" handler="clica" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkTextView" id="textview1">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">button1</action-widget>
</action-widgets>
</object>
</interface>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/glade-users/attachments/20140422/855e022e/attachment.html>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]