mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-08-27 03:49:12 +00:00
Store environment in window
This commit is contained in:
parent
8f5c463f01
commit
b759670df1
|
@ -157,6 +157,12 @@ public class Application : Gtk.Application
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!cmd.get_is_remote())
|
||||
{
|
||||
Options.command_line = cmd;
|
||||
}
|
||||
|
||||
var tmpcmd = Options.command_line;
|
||||
Options.command_line = cmd;
|
||||
|
||||
if (argv.length > 1)
|
||||
|
@ -176,6 +182,8 @@ public class Application : Gtk.Application
|
|||
activate();
|
||||
}
|
||||
|
||||
Options.command_line = tmpcmd;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -389,6 +397,7 @@ public class Application : Gtk.Application
|
|||
if (window != null)
|
||||
{
|
||||
// Present the window with this repository open
|
||||
window.set_environment(Options.command_line.get_environ());
|
||||
window.present();
|
||||
continue;
|
||||
}
|
||||
|
@ -409,7 +418,13 @@ public class Application : Gtk.Application
|
|||
|
||||
private void new_window(Repository? repo = null, string? hint = null)
|
||||
{
|
||||
Window.create_new(this, repo, hint);
|
||||
var window = Window.create_new(this, repo, hint);
|
||||
|
||||
if (window != null)
|
||||
{
|
||||
window.set_environment(Options.command_line.get_environ());
|
||||
}
|
||||
|
||||
present_window();
|
||||
}
|
||||
|
||||
|
@ -427,7 +442,10 @@ public class Application : Gtk.Application
|
|||
return;
|
||||
}
|
||||
|
||||
windows.first().data.present();
|
||||
var w = (Gitg.Window)windows.first().data;
|
||||
|
||||
w.set_environment(Options.command_line.get_environ());
|
||||
w.present();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
|
|||
private Repository? d_repository;
|
||||
private GitgExt.MessageBus d_message_bus;
|
||||
private string? d_action;
|
||||
private Gee.HashMap<string, string> d_environment;
|
||||
|
||||
private UIElements<GitgExt.Activity> d_activities;
|
||||
|
||||
|
@ -42,6 +43,8 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
|
|||
private MenuModel d_dash_model;
|
||||
private MenuModel d_activities_model;
|
||||
|
||||
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.Button d_dash_button;
|
||||
[GtkChild]
|
||||
|
@ -150,6 +153,13 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
|
|||
d_search_button.bind_property("active", d_search_bar, "search-mode-enabled", BindingFlags.BIDIRECTIONAL);
|
||||
|
||||
d_activities_switcher.set_stack(d_stack_activities);
|
||||
|
||||
d_environment = new Gee.HashMap<string, string>();
|
||||
|
||||
foreach (var e in Environment.list_variables())
|
||||
{
|
||||
d_environment[e] = Environment.get_variable(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void on_close_activated()
|
||||
|
@ -593,6 +603,25 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
|
|||
return true;
|
||||
}
|
||||
|
||||
public void set_environment(string[] environment)
|
||||
{
|
||||
d_environment = new Gee.HashMap<string, string>();
|
||||
|
||||
foreach (var e in environment)
|
||||
{
|
||||
string[] parts = e.split("=", 2);
|
||||
|
||||
if (parts.length == 1)
|
||||
{
|
||||
d_environment[parts[0]] = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
d_environment[parts[0]] = parts[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Window? create_new(Gtk.Application app,
|
||||
Repository? repository,
|
||||
string? action)
|
||||
|
@ -686,6 +715,11 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
|
|||
infobar.hide();
|
||||
});
|
||||
}
|
||||
|
||||
public Gee.Map<string, string> environment
|
||||
{
|
||||
owned get { return d_environment; }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -58,6 +58,8 @@ public interface Application : Object
|
|||
public abstract void show_infobar(string primary_msg,
|
||||
string secondary_msg,
|
||||
Gtk.MessageType type);
|
||||
|
||||
public abstract Gee.Map<string, string> environment { owned get; }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue