Add command line switch to set icon.
This commit is contained in:
parent
2a87f8dd63
commit
d91ce8d614
|
@ -25,6 +25,8 @@ titles.
|
|||
Tell termite to change to \fIDIRECTORY\fP when launching.
|
||||
.IP "\fB\-\-geometry\fR\fB=\fR\fIGEOMETRY\fR"
|
||||
Override the window geometry in pixels.
|
||||
.IP "\fB\-\-icon\fR\f8=\fR\fIICON\fR"
|
||||
Override the window icon name.
|
||||
.IP "\fB\-\-hold\fR"
|
||||
Keep termite open after the child process exits.
|
||||
.IP "\fB\-\-display\fR\fB=\fR\fIDISPLAY\fR"
|
||||
|
|
30
termite.cc
30
termite.cc
|
@ -157,9 +157,9 @@ static void overlay_show(search_panel_info *info, overlay_mode mode, VteTerminal
|
|||
static void get_vte_padding(VteTerminal *vte, int *left, int *top, int *right, int *bottom);
|
||||
static char *check_match(VteTerminal *vte, GdkEventButton *event);
|
||||
static void load_config(GtkWindow *window, VteTerminal *vte, config_info *info,
|
||||
char **geometry);
|
||||
char **geometry, char **icon);
|
||||
static void set_config(GtkWindow *window, VteTerminal *vte, config_info *info,
|
||||
char **geometry, GKeyFile *config);
|
||||
char **geometry, char **icon, GKeyFile *config);
|
||||
static long first_row(VteTerminal *vte);
|
||||
|
||||
static std::function<void ()> reload_config;
|
||||
|
@ -1316,7 +1316,7 @@ static void load_theme(GtkWindow *window, VteTerminal *vte, GKeyFile *config, hi
|
|||
}
|
||||
|
||||
static void load_config(GtkWindow *window, VteTerminal *vte, config_info *info,
|
||||
char **geometry) {
|
||||
char **geometry, char **icon) {
|
||||
const std::string default_path = "/termite/config";
|
||||
GKeyFile *config = g_key_file_new();
|
||||
|
||||
|
@ -1341,13 +1341,13 @@ static void load_config(GtkWindow *window, VteTerminal *vte, config_info *info,
|
|||
}
|
||||
|
||||
if (loaded) {
|
||||
set_config(window, vte, info, geometry, config);
|
||||
set_config(window, vte, info, geometry, icon, config);
|
||||
}
|
||||
g_key_file_free(config);
|
||||
}
|
||||
|
||||
static void set_config(GtkWindow *window, VteTerminal *vte, config_info *info,
|
||||
char **geometry, GKeyFile *config) {
|
||||
char **geometry, char **icon, GKeyFile *config) {
|
||||
if (geometry) {
|
||||
if (auto s = get_config_string(config, "options", "geometry")) {
|
||||
*geometry = *s;
|
||||
|
@ -1434,9 +1434,10 @@ static void set_config(GtkWindow *window, VteTerminal *vte, config_info *info,
|
|||
g_free(*s);
|
||||
}
|
||||
|
||||
if (auto s = get_config_string(config, "options", "icon_name")) {
|
||||
gtk_window_set_icon_name(window, *s);
|
||||
g_free(*s);
|
||||
if (icon) {
|
||||
if (auto s = get_config_string(config, "options", "icon_name")) {
|
||||
*icon = *s;
|
||||
}
|
||||
}
|
||||
|
||||
if (info->size_hints) {
|
||||
|
@ -1484,7 +1485,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
GOptionContext *context = g_option_context_new(nullptr);
|
||||
char *role = nullptr, *geometry = nullptr, *execute = nullptr, *config_file = nullptr;
|
||||
char *title = nullptr;
|
||||
char *title = nullptr, *icon = nullptr;
|
||||
const GOptionEntry entries[] = {
|
||||
{"version", 'v', 0, G_OPTION_ARG_NONE, &version, "Version info", nullptr},
|
||||
{"exec", 'e', 0, G_OPTION_ARG_STRING, &execute, "Command to execute", "COMMAND"},
|
||||
|
@ -1494,6 +1495,7 @@ int main(int argc, char **argv) {
|
|||
{"geometry", 0, 0, G_OPTION_ARG_STRING, &geometry, "Window geometry", "GEOMETRY"},
|
||||
{"hold", 0, 0, G_OPTION_ARG_NONE, &hold, "Remain open after child process exits", nullptr},
|
||||
{"config", 'c', 0, G_OPTION_ARG_STRING, &config_file, "Path of config file", "CONFIG"},
|
||||
{"icon", 'i', 0, G_OPTION_ARG_STRING, &icon, "Icon", "ICON"},
|
||||
{nullptr, 0, 0, G_OPTION_ARG_NONE, nullptr, nullptr, nullptr}
|
||||
};
|
||||
g_option_context_add_main_entries(context, entries, nullptr);
|
||||
|
@ -1560,10 +1562,11 @@ int main(int argc, char **argv) {
|
|||
gtk_window_fullscreen
|
||||
};
|
||||
|
||||
load_config(GTK_WINDOW(window), vte, &info.config, geometry ? nullptr : &geometry);
|
||||
load_config(GTK_WINDOW(window), vte, &info.config, geometry ? nullptr : &geometry,
|
||||
icon ? nullptr : &icon);
|
||||
|
||||
reload_config = [&]{
|
||||
load_config(GTK_WINDOW(window), vte, &info.config, nullptr);
|
||||
load_config(GTK_WINDOW(window), vte, &info.config, nullptr, nullptr);
|
||||
};
|
||||
signal(SIGUSR1, [](int){ reload_config(); });
|
||||
|
||||
|
@ -1630,6 +1633,11 @@ int main(int argc, char **argv) {
|
|||
g_free(geometry);
|
||||
}
|
||||
|
||||
if (icon) {
|
||||
gtk_window_set_icon_name(GTK_WINDOW(window), icon);
|
||||
g_free(icon);
|
||||
}
|
||||
|
||||
gtk_widget_grab_focus(vte_widget);
|
||||
gtk_widget_show_all(window);
|
||||
gtk_widget_hide(info.panel.entry);
|
||||
|
|
Loading…
Reference in New Issue