Blubb
This commit is contained in:
parent
2a7984da34
commit
58993e58be
@ -12,6 +12,7 @@ gobject-sys = "^0.4.0"
|
|||||||
gtk-sys = "^0.4.0"
|
gtk-sys = "^0.4.0"
|
||||||
libpijul = "^0.7.3"
|
libpijul = "^0.7.3"
|
||||||
log = "^0.3.8"
|
log = "^0.3.8"
|
||||||
|
base64 = "^0.6.0"
|
||||||
|
|
||||||
[dependencies.gdk]
|
[dependencies.gdk]
|
||||||
features = [
|
features = [
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
<object class="GtkWindow" id="main">
|
<object class="GtkWindow" id="main">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="title" translatable="yes">Pigui</property>
|
<property name="title" translatable="yes">Pigui</property>
|
||||||
|
<property name="default_width">440</property>
|
||||||
|
<property name="default_height">440</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -15,11 +17,18 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkTreeView">
|
<object class="GtkScrolledWindow">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<child internal-child="selection">
|
<property name="shadow_type">in</property>
|
||||||
<object class="GtkTreeSelection"/>
|
<child>
|
||||||
|
<object class="GtkTreeView" id="branch_tree">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<child internal-child="selection">
|
||||||
|
<object class="GtkTreeSelection"/>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
@ -29,11 +38,18 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkTreeView">
|
<object class="GtkScrolledWindow">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<child internal-child="selection">
|
<property name="shadow_type">in</property>
|
||||||
<object class="GtkTreeSelection"/>
|
<child>
|
||||||
|
<object class="GtkTreeView" id="patch_tree">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<child internal-child="selection">
|
||||||
|
<object class="GtkTreeSelection"/>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
|
@ -8,6 +8,8 @@ extern crate glib_sys;
|
|||||||
extern crate gobject_sys;
|
extern crate gobject_sys;
|
||||||
extern crate gtk;
|
extern crate gtk;
|
||||||
extern crate gtk_sys;
|
extern crate gtk_sys;
|
||||||
|
extern crate libpijul;
|
||||||
|
extern crate base64;
|
||||||
|
|
||||||
extern crate flexi_logger;
|
extern crate flexi_logger;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
use gtk;
|
use gtk;
|
||||||
|
use gtk::prelude::*;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use gtk::WidgetExt;
|
use gtk::WidgetExt;
|
||||||
|
use libpijul;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
|
||||||
pub struct AppS {
|
pub struct AppS {
|
||||||
@ -23,7 +26,9 @@ impl AppS {
|
|||||||
|
|
||||||
pub struct Gui {
|
pub struct Gui {
|
||||||
_cant_construct: (),
|
_cant_construct: (),
|
||||||
pub window: gtk::Window
|
pub window: gtk::Window,
|
||||||
|
pub branch_tree: gtk::TreeView,
|
||||||
|
pub patch_tree: gtk::TreeView,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Gui {
|
impl Gui {
|
||||||
@ -31,12 +36,91 @@ impl Gui {
|
|||||||
return Gui {
|
return Gui {
|
||||||
_cant_construct: (),
|
_cant_construct: (),
|
||||||
window: builder.get_object("main").unwrap(),
|
window: builder.get_object("main").unwrap(),
|
||||||
|
branch_tree: builder.get_object("branch_tree").unwrap(),
|
||||||
|
patch_tree: builder.get_object("patch_tree").unwrap(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn init(appstate: Rc<AppS>) {
|
pub fn init(appstate: Rc<AppS>) {
|
||||||
|
{
|
||||||
|
let ls = gtk::ListStore::new(&[gtk::Type::String]);
|
||||||
|
|
||||||
|
let branches = get_branches("/home/hasufell/git/pijul/.pijul/pristine");
|
||||||
|
|
||||||
|
for branch in branches {
|
||||||
|
ls.insert_with_values(None, &[0], &[&branch.as_str()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let renderer = gtk::CellRendererText::new();
|
||||||
|
let col = gtk::TreeViewColumn::new();
|
||||||
|
col.set_title("Branch");
|
||||||
|
col.set_resizable(true);
|
||||||
|
col.pack_start(&renderer, true);
|
||||||
|
col.add_attribute(&renderer, "text", 0);
|
||||||
|
col.set_clickable(true);
|
||||||
|
col.set_sort_column_id(0);
|
||||||
|
|
||||||
|
appstate.gui.branch_tree.append_column(&col);
|
||||||
|
appstate.gui.branch_tree.set_model(Some(&ls));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let ls = gtk::ListStore::new(&[gtk::Type::String]);
|
||||||
|
let patches = get_patches("/home/hasufell/git/pijul/.pijul/pristine",
|
||||||
|
"master");
|
||||||
|
for patch in patches {
|
||||||
|
ls.insert_with_values(None, &[0], &[&patch.as_str()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
let renderer = gtk::CellRendererText::new();
|
||||||
|
let col = gtk::TreeViewColumn::new();
|
||||||
|
col.set_title("Patch");
|
||||||
|
col.set_resizable(true);
|
||||||
|
col.pack_start(&renderer, true);
|
||||||
|
col.add_attribute(&renderer, "text", 0);
|
||||||
|
col.set_clickable(true);
|
||||||
|
col.set_sort_column_id(0);
|
||||||
|
|
||||||
|
appstate.gui.patch_tree.append_column(&col);
|
||||||
|
appstate.gui.patch_tree.set_model(Some(&ls));
|
||||||
|
}
|
||||||
|
|
||||||
appstate.gui.window.show_all();
|
appstate.gui.window.show_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fn get_branches(path: &str) -> Vec<String> {
|
||||||
|
let mut vec = Vec::new();
|
||||||
|
|
||||||
|
let repo = libpijul::Repository::open(path, None).unwrap();
|
||||||
|
let txn = repo.txn_begin().unwrap();
|
||||||
|
|
||||||
|
let branches = txn.iter_branches(None).map(|x| String::from(x.name.as_str()));
|
||||||
|
|
||||||
|
vec.extend(branches);
|
||||||
|
return vec;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn get_patches(path: &str, branch: &str) -> Vec<String> {
|
||||||
|
let mut vec = Vec::new();
|
||||||
|
|
||||||
|
let repo = libpijul::Repository::open(path, None).unwrap();
|
||||||
|
let txn = repo.txn_begin().unwrap();
|
||||||
|
|
||||||
|
let branch = txn.get_branch(branch).unwrap();
|
||||||
|
|
||||||
|
let patches = txn.iter_patches(&branch, None).map(|x| {
|
||||||
|
let p = libpijul::fs_representation::read_patch(Path::new("/home/hasufell/git/pijul"),
|
||||||
|
txn.external_hash(x.0)).unwrap();
|
||||||
|
p.header().name.clone()
|
||||||
|
});
|
||||||
|
|
||||||
|
vec.extend(patches);
|
||||||
|
|
||||||
|
return vec;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user