Let GitgExtView decide where should GitgExtPanels be placed

This commit is contained in:
Techlive Zheng 2013-05-21 15:41:49 +08:00 committed by Ignacio Casal Quinteiro
parent ad335d08b2
commit ed7abdb90c
10 changed files with 128 additions and 111 deletions

View file

@ -221,12 +221,12 @@ AC_SUBST(GITG_PLUGIN_DATADIR)
GITG_PLUGIN_LIBDIR="$libdir/gitg/plugins" GITG_PLUGIN_LIBDIR="$libdir/gitg/plugins"
AC_SUBST(GITG_PLUGIN_LIBDIR) AC_SUBST(GITG_PLUGIN_LIBDIR)
GITG_PLUGIN_CFLAGS="$GITG_CFLAGS" GITG_PLUGIN_CFLAGS="-I\$(top_srcdir)/libgd $GITG_CFLAGS"
GITG_PLUGIN_LIBS="$GITG_LIBS \ GITG_PLUGIN_LIBS="$GITG_LIBS \
\$(top_builddir)/libgd/libgd.la \
\$(top_builddir)/libgitg/libgitg-1.0.la \ \$(top_builddir)/libgitg/libgitg-1.0.la \
\$(top_builddir)/libgitg-ext/libgitg-ext-1.0.la \ \$(top_builddir)/libgitg-ext/libgitg-ext-1.0.la \
\$(top_builddir)/libgitg-gtk/libgitg-gtk-1.0.la" \$(top_builddir)/libgitg-gtk/libgitg-gtk-1.0.la \
\$(top_builddir)/libgd/libgd.la"
AC_SUBST(GITG_PLUGIN_CFLAGS) AC_SUBST(GITG_PLUGIN_CFLAGS)
AC_SUBST(GITG_PLUGIN_LIBS) AC_SUBST(GITG_PLUGIN_LIBS)

View file

@ -117,9 +117,6 @@
<key name="size" type="(ii)"> <key name="size" type="(ii)">
<default>(650, 500)</default> <default>(650, 500)</default>
</key> </key>
<key name="paned-panels-position" type="i">
<default>150</default>
</key>
<key name="hpaned-commit1-position" type="i"> <key name="hpaned-commit1-position" type="i">
<default>200</default> <default>200</default>
</key> </key>

View file

@ -49,10 +49,7 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
private Gtk.ScrolledWindow d_dash_scrolled_window; private Gtk.ScrolledWindow d_dash_scrolled_window;
private GitgGtk.DashView d_dash_view; private GitgGtk.DashView d_dash_view;
private Gtk.Paned d_paned_panels;
private Gd.Stack d_stack_view; private Gd.Stack d_stack_view;
private Gd.Stack d_stack_panel;
private static const ActionEntry[] win_entries = { private static const ActionEntry[] win_entries = {
{"search", on_search_activated, null, "false", null}, {"search", on_search_activated, null, "false", null},
@ -143,7 +140,7 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
d_header_bar.set_subtitle(Markup.escape_text(head_name)); d_header_bar.set_subtitle(Markup.escape_text(head_name));
d_main_stack.transition_type = Gd.StackTransitionType.SLIDE_LEFT; d_main_stack.transition_type = Gd.StackTransitionType.SLIDE_LEFT;
d_main_stack.set_visible_child(d_paned_panels); d_main_stack.set_visible_child(d_stack_view);
d_commit_view_switcher.show(); d_commit_view_switcher.show();
d_button_dash.show(); d_button_dash.show();
d_dash_view.add_repository(d_repository); d_dash_view.add_repository(d_repository);
@ -435,12 +432,9 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
repository = r; repository = r;
}); });
d_paned_panels = builder.get_object("paned_panels") as Gtk.Paned;
d_stack_view = builder.get_object("stack_view") as Gd.Stack; d_stack_view = builder.get_object("stack_view") as Gd.Stack;
d_stack_panel = builder.get_object("stack_panel") as Gd.Stack;
d_commit_view_switcher = builder.get_object("commit-view-switcher") as Gd.StackSwitcher; d_commit_view_switcher = builder.get_object("commit-view-switcher") as Gd.StackSwitcher;
d_commit_view_switcher.stack = d_stack_panel;
d_gear_menu = builder.get_object("gear-menubutton") as Gtk.MenuButton; d_gear_menu = builder.get_object("gear-menubutton") as Gtk.MenuButton;
@ -482,11 +476,6 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
} }
}); });
d_interface_settings.bind("orientation",
d_paned_panels,
"orientation",
SettingsBindFlags.GET);
base.parser_finished(builder); base.parser_finished(builder);
} }
@ -497,11 +486,27 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
if (view != null) if (view != null)
{ {
view.on_view_activated(); if (view.stack_panel != null)
} {
d_commit_view_switcher.stack = view.stack_panel; //todo
// Update panels // Initialize peas extensions set for this view
d_panels.update(); var engine = PluginsEngine.get_default();
d_panels = new UIElements<GitgExt.Panel>(new Peas.ExtensionSet(engine,
typeof(GitgExt.Panel),
"application",
this),
view.stack_panel);
d_panels.activated.connect(on_panel_activated);
}
view.on_view_activated();
d_panels.update();
}
notify_property("current_view"); notify_property("current_view");
} }
@ -568,14 +573,6 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
d_views.activated.connect(on_view_activated); d_views.activated.connect(on_view_activated);
d_panels = new UIElements<GitgExt.Panel>(new Peas.ExtensionSet(engine,
typeof(GitgExt.Panel),
"application",
this),
d_stack_panel);
d_panels.activated.connect(on_panel_activated);
// Setup window geometry saving // Setup window geometry saving
Gdk.WindowState window_state = (Gdk.WindowState)d_state_settings.get_int("state"); Gdk.WindowState window_state = (Gdk.WindowState)d_state_settings.get_int("state");
if (Gdk.WindowState.MAXIMIZED in window_state) { if (Gdk.WindowState.MAXIMIZED in window_state) {
@ -586,11 +583,6 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
d_state_settings.get ("size", "(ii)", out width, out height); d_state_settings.get ("size", "(ii)", out width, out height);
resize (width, height); resize (width, height);
d_state_settings.bind("paned-panels-position",
d_paned_panels,
"position",
SettingsBindFlags.GET | SettingsBindFlags.SET);
return true; return true;
} }

View file

@ -145,37 +145,9 @@
</object> </object>
</child> </child>
<child> <child>
<object class="GtkPaned" id="paned_panels"> <object class="GdStack" id="stack_view">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="position">300</property>
<property name="orientation">vertical</property>
<style>
<class name="panels-paned"/>
</style>
<child>
<object class="GdStack" id="stack_view">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
<child>
<object class="GdStack" id="stack_panel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="resize">False</property>
<property name="shrink">True</property>
</packing>
</child>
</object> </object>
</child> </child>
</object> </object>

View file

@ -3,6 +3,7 @@ lib_LTLIBRARIES = libgitg-ext-1.0.la
INCLUDES = \ INCLUDES = \
-I$(top_srcdir) \ -I$(top_srcdir) \
-I$(srcdir) \ -I$(srcdir) \
-I$(top_srcdir)/libgd \
$(LIBGITG_EXT_CFLAGS) \ $(LIBGITG_EXT_CFLAGS) \
$(WARN_CFLAGS) \ $(WARN_CFLAGS) \
-DDATADIR=\""$(datadir)"\" \ -DDATADIR=\""$(datadir)"\" \
@ -14,12 +15,15 @@ COMMON_VALA_FLAGS = \
--pkg gio-2.0 \ --pkg gio-2.0 \
--pkg gtk+-3.0 \ --pkg gtk+-3.0 \
--pkg gee-1.0 \ --pkg gee-1.0 \
--pkg gd-1.0 \
--basedir $(top_srcdir) \ --basedir $(top_srcdir) \
--vapidir $(top_builddir)/libgd \
--vapidir $(top_builddir)/libgitg --vapidir $(top_builddir)/libgitg
AM_VALAFLAGS = \ AM_VALAFLAGS = \
$(COMMON_VALA_FLAGS) \ $(COMMON_VALA_FLAGS) \
--gir GitgExt-1.0.gir \ --gir GitgExt-1.0.gir \
--girdir $(top_builddir)/libgd \
--girdir $(top_builddir)/libgitg \ --girdir $(top_builddir)/libgitg \
--includedir libgitg-ext \ --includedir libgitg-ext \
--header libgitg-ext.h \ --header libgitg-ext.h \
@ -79,7 +83,7 @@ typelibdir = $(INTROSPECTION_TYPELIBDIR)
typelib_DATA = GitgExt-1.0.typelib typelib_DATA = GitgExt-1.0.typelib
%.typelib: %.gir %.typelib: %.gir
$(INTROSPECTION_COMPILER) $(INTROSPECTION_COMPILER_ARGS) --includedir=. --includedir=$(top_builddir)/libgitg -o $@ $< $(INTROSPECTION_COMPILER) $(INTROSPECTION_COMPILER_ARGS) --includedir=. --includedir=$(top_builddir)/libgd --includedir=$(top_builddir)/libgitg -o $@ $<
if ENABLE_PYTHON if ENABLE_PYTHON
overridesdir = $(pyoverridesdir) overridesdir = $(pyoverridesdir)

View file

@ -81,6 +81,8 @@ public interface View : Object, UIElement
* *
*/ */
public abstract bool is_default_for(string action); public abstract bool is_default_for(string action);
public abstract Gd.Stack stack_panel { get; }
} }
} }

View file

@ -1,7 +1,6 @@
INCLUDES = \ INCLUDES = \
-I$(top_srcdir) \ -I$(top_srcdir) \
-I$(srcdir) \ -I$(srcdir) \
-I$(top_srcdir)/libgd \
$(GITG_PLUGIN_CFLAGS) \ $(GITG_PLUGIN_CFLAGS) \
$(WARN_CFLAGS) \ $(WARN_CFLAGS) \
-DDATADIR=\""$(datadir)"\" \ -DDATADIR=\""$(datadir)"\" \

View file

@ -36,6 +36,8 @@ namespace GitgHistory
private Gtk.Paned d_main; private Gtk.Paned d_main;
private GitgHistory.NavigationView d_navigation; private GitgHistory.NavigationView d_navigation;
private Gtk.Paned d_paned_panels;
private Gd.Stack d_stack_panel;
private Gtk.TreeView d_commit_list; private Gtk.TreeView d_commit_list;
public string id public string id
@ -43,6 +45,11 @@ namespace GitgHistory
owned get { return "/org/gnome/gitg/Views/History"; } owned get { return "/org/gnome/gitg/Views/History"; }
} }
public Gd.Stack stack_panel
{
get { return d_stack_panel; }
}
public void foreach_selected(GitgExt.ForeachObjectSelectionFunc func) public void foreach_selected(GitgExt.ForeachObjectSelectionFunc func)
{ {
bool breakit = false; bool breakit = false;
@ -181,6 +188,8 @@ namespace GitgHistory
{ {
var ret = GitgExt.UI.from_builder("history/view-history.ui", var ret = GitgExt.UI.from_builder("history/view-history.ui",
"paned_views", "paned_views",
"paned_panels",
"stack_panel",
"navigation_view", "navigation_view",
"commit_list_view", "commit_list_view",
"renderer_commit_list_author", "renderer_commit_list_author",
@ -206,6 +215,9 @@ namespace GitgHistory
d_navigation.set_level_indentation(12); d_navigation.set_level_indentation(12);
} }
d_paned_panels = ret["paned_panels"] as Gtk.Paned;
d_stack_panel = ret["stack_panel"] as Gd.Stack;
d_commit_list = ret["commit_list_view"] as Gtk.TreeView; d_commit_list = ret["commit_list_view"] as Gtk.TreeView;
d_commit_list.model = d_model; d_commit_list.model = d_model;
d_commit_list.get_selection().changed.connect((sel) => { d_commit_list.get_selection().changed.connect((sel) => {
@ -220,6 +232,16 @@ namespace GitgHistory
d_main, d_main,
"position", "position",
SettingsBindFlags.GET | SettingsBindFlags.SET); SettingsBindFlags.GET | SettingsBindFlags.SET);
state_settings.bind("paned-panels-position",
d_paned_panels,
"position",
SettingsBindFlags.GET | SettingsBindFlags.SET);
var interface_settings = new Settings("org.gnome.gitg.preferences.interface");
interface_settings.bind("orientation",
d_paned_panels,
"orientation",
SettingsBindFlags.GET);
} }
private void update_walker(Navigation n, Gitg.Ref? head) private void update_walker(Navigation n, Gitg.Ref? head)

View file

@ -7,6 +7,9 @@
<key name="paned-views-position" type="i"> <key name="paned-views-position" type="i">
<default>200</default> <default>200</default>
</key> </key>
<key name="paned-panels-position" type="i">
<default>450</default>
</key>
</schema> </schema>
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.history.preferences" path="/org/gnome/gitg/history/preferences/"> <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.history.preferences" path="/org/gnome/gitg/history/preferences/">
<key name="collapse-inactive-lanes" type="i"> <key name="collapse-inactive-lanes" type="i">

View file

@ -37,70 +37,96 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkScrolledWindow" id="scrolled_window_commit_list"> <object class="GtkPaned" id="paned_panels">
<property name="visible">True</property> <property name="visible">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="shadow-type">none</property> <property name="orientation">vertical</property>
<property name="position">300</property>
<style>
<class name="panels-paned"/>
</style>
<child> <child>
<object class="GitgGtkCommitListView" id="commit_list_view"> <object class="GtkScrolledWindow" id="scrolled_window_commit_list">
<property name="visible">True</property> <property name="visible">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="rules_hint">True</property> <property name="shadow-type">none</property>
<property name="fixed-height-mode">True</property>
<property name="headers-visible">False</property>
<child> <child>
<object class="GtkTreeViewColumn" id="column_commit_list_subject"> <object class="GitgGtkCommitListView" id="commit_list_view">
<property name="title" translatable="yes">Subject</property> <property name="visible">True</property>
<property name="sizing">fixed</property> <property name="can_focus">True</property>
<property name="resizable">True</property> <property name="rules_hint">True</property>
<property name="expand">True</property> <property name="fixed-height-mode">True</property>
<property name="fixed-width">600</property> <property name="headers-visible">False</property>
<child> <child>
<object class="GitgGtkCellRendererLanes" id="renderer_commit_list_subject"> <object class="GtkTreeViewColumn" id="column_commit_list_subject">
<property name="ellipsize">end</property> <property name="title" translatable="yes">Subject</property>
<property name="sizing">fixed</property>
<property name="resizable">True</property>
<property name="expand">True</property>
<property name="fixed-width">600</property>
<child>
<object class="GitgGtkCellRendererLanes" id="renderer_commit_list_subject">
<property name="ellipsize">end</property>
</object>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object> </object>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child> </child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="column_commit_list_author">
<property name="title" translatable="yes">Author</property>
<property name="sizing">fixed</property>
<property name="resizable">True</property>
<property name="fixed-width">200</property>
<child> <child>
<object class="GdStyledTextRenderer" id="renderer_commit_list_author"> <object class="GtkTreeViewColumn" id="column_commit_list_author">
<property name="ellipsize">end</property> <property name="title" translatable="yes">Author</property>
<property name="sizing">fixed</property>
<property name="resizable">True</property>
<property name="fixed-width">200</property>
<child>
<object class="GdStyledTextRenderer" id="renderer_commit_list_author">
<property name="ellipsize">end</property>
</object>
<attributes>
<attribute name="text">4</attribute>
</attributes>
</child>
</object> </object>
<attributes>
<attribute name="text">4</attribute>
</attributes>
</child> </child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="column_commit_list_author_date">
<property name="title" translatable="yes">Date</property>
<property name="sizing">fixed</property>
<property name="resizable">True</property>
<property name="fixed-width">250</property>
<child> <child>
<object class="GdStyledTextRenderer" id="renderer_commit_list_author_date"> <object class="GtkTreeViewColumn" id="column_commit_list_author_date">
<property name="ellipsize">end</property> <property name="title" translatable="yes">Date</property>
<property name="sizing">fixed</property>
<property name="resizable">True</property>
<property name="fixed-width">250</property>
<child>
<object class="GdStyledTextRenderer" id="renderer_commit_list_author_date">
<property name="ellipsize">end</property>
</object>
<attributes>
<attribute name="text">6</attribute>
</attributes>
</child>
</object> </object>
<attributes>
<attribute name="text">6</attribute>
</attributes>
</child> </child>
</object> </object>
</child> </child>
</object> </object>
</child> </child>
<child>
<object class="GdStack" id="stack_panel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
</object> </object>
</child> </child>
</object> </object>