Split headerbar on it's own glade.ui file.
This commit is contained in:
parent
a4e2944622
commit
ac51370088
@ -24,71 +24,6 @@
|
|||||||
<column type="gchararray"/>
|
<column type="gchararray"/>
|
||||||
</columns>
|
</columns>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkHeaderBar" id="headerbar1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="title">Hello</property>
|
|
||||||
<property name="subtitle">World!</property>
|
|
||||||
<property name="show_close_button">True</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="homebutton">
|
|
||||||
<property name="label">gtk-home</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="use_stock">True</property>
|
|
||||||
<property name="always_show_image">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="position">3</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="refbutton">
|
|
||||||
<property name="label">gtk-refresh</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="use_underline">True</property>
|
|
||||||
<property name="use_stock">True</property>
|
|
||||||
<property name="always_show_image">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="pack_type">end</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="addbutton">
|
|
||||||
<property name="label">gtk-add</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="use_underline">True</property>
|
|
||||||
<property name="use_stock">True</property>
|
|
||||||
<property name="always_show_image">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="pack_type">end</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="searchbutton">
|
|
||||||
<property name="label">gtk-find</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="use_underline">True</property>
|
|
||||||
<property name="use_stock">True</property>
|
|
||||||
<property name="always_show_image">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="pack_type">end</property>
|
|
||||||
<property name="position">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<object class="GtkWindow" id="window1">
|
<object class="GtkWindow" id="window1">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="default_width">800</property>
|
<property name="default_width">800</property>
|
||||||
|
|||||||
101
hammond-gtk/gtk/headerbar.ui
Normal file
101
hammond-gtk/gtk/headerbar.ui
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Generated with glade 3.20.0 -->
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk+" version="3.20"/>
|
||||||
|
<object class="GtkHeaderBar" id="headerbar1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="title">Hello</property>
|
||||||
|
<property name="subtitle">World!</property>
|
||||||
|
<property name="show_close_button">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="homebutton">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="always_show_image">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="stock">gtk-home</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="position">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="addbutton">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="tooltip_text" translatable="yes">Add Podcast</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<property name="always_show_image">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="stock">gtk-add</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<style>
|
||||||
|
<class name="image-button"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="pack_type">end</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="refbutton">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<property name="always_show_image">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="stock">gtk-refresh</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="pack_type">end</property>
|
||||||
|
<property name="position">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkToggleButton" id="searchbutton">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="tooltip_text" translatable="yes">Search</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="search-button-image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="icon_name">edit-find-symbolic</property>
|
||||||
|
<property name="icon_size">1</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<style>
|
||||||
|
<class name="image-button"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="pack_type">end</property>
|
||||||
|
<property name="position">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</interface>
|
||||||
@ -52,10 +52,13 @@ fn create_tree_store(connection: &SqliteConnection, builder: >k::Builder) -> T
|
|||||||
podcast_model.insert_with_values(
|
podcast_model.insert_with_values(
|
||||||
Some(&iter),
|
Some(&iter),
|
||||||
None,
|
None,
|
||||||
&[0, 1, 2, 6, 7, 8],
|
|
||||||
&[
|
&[
|
||||||
&ep.id(), &ep.title().unwrap(), &ep.description().unwrap_or_default(), &ep.uri(),
|
0, 1, 2, 6, 7, 8
|
||||||
&ep.local_uri().unwrap_or_default(), &ep.published_date().unwrap_or_default(),
|
],
|
||||||
|
&[
|
||||||
|
&ep.id(), &ep.title().unwrap(), &ep.description().unwrap_or_default(),
|
||||||
|
&ep.uri(), &ep.local_uri().unwrap_or_default(),
|
||||||
|
&ep.published_date().unwrap_or_default(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -105,20 +108,22 @@ fn main() {
|
|||||||
|
|
||||||
// Adapted copy of the way gnome-music does albumview
|
// Adapted copy of the way gnome-music does albumview
|
||||||
let glade_src = include_str!("../gtk/foo.ui");
|
let glade_src = include_str!("../gtk/foo.ui");
|
||||||
|
let header_src = include_str!("../gtk/headerbar.ui");
|
||||||
let builder = gtk::Builder::new_from_string(glade_src);
|
let builder = gtk::Builder::new_from_string(glade_src);
|
||||||
|
let header_build = gtk::Builder::new_from_string(header_src);
|
||||||
|
|
||||||
// Get the main window
|
// Get the main window
|
||||||
// let window: gtk::Window = builder.get_object("window1").unwrap();
|
// let window: gtk::Window = builder.get_object("window1").unwrap();
|
||||||
let window: gtk::Window = builder.get_object("window2").unwrap();
|
let window: gtk::Window = builder.get_object("window2").unwrap();
|
||||||
// Get the headerbar
|
// Get the headerbar
|
||||||
let header: gtk::HeaderBar = builder.get_object("headerbar1").unwrap();
|
let header: gtk::HeaderBar = header_build.get_object("headerbar1").unwrap();
|
||||||
window.set_titlebar(&header);
|
window.set_titlebar(&header);
|
||||||
|
|
||||||
let refresh_button: gtk::Button = builder.get_object("refbutton").unwrap();
|
let refresh_button: gtk::Button = header_build.get_object("refbutton").unwrap();
|
||||||
// TODO: Have a small dropdown menu
|
// TODO: Have a small dropdown menu
|
||||||
let _add_button: gtk::Button = builder.get_object("addbutton").unwrap();
|
let _add_button: gtk::Button = header_build.get_object("addbutton").unwrap();
|
||||||
let _search_button: gtk::Button = builder.get_object("searchbutton").unwrap();
|
let _search_button: gtk::Button = header_build.get_object("searchbutton").unwrap();
|
||||||
let _home_button: gtk::Button = builder.get_object("homebutton").unwrap();
|
let _home_button: gtk::Button = header_build.get_object("homebutton").unwrap();
|
||||||
|
|
||||||
// FIXME: This locks the ui atm.
|
// FIXME: This locks the ui atm.
|
||||||
refresh_button.connect_clicked(|_| {
|
refresh_button.connect_clicked(|_| {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user