Skip to content

Commit

Permalink
Merge pull request thestinger#567 from jelly/remove_geometry
Browse files Browse the repository at this point in the history
Remove geometry
  • Loading branch information
jelly authored Feb 11, 2018
2 parents 7138bc4 + b019a80 commit a4af9e7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 28 deletions.
1 change: 0 additions & 1 deletion config
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#dynamic_title = true
font = Monospace 9
#fullscreen = true
#geometry = 640x480
#icon_name = terminal
#mouse_autohide = false
#scroll_on_output = false
Expand Down
2 changes: 0 additions & 2 deletions man/termite.1
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ Set the termite window's title to \fITITLE\fP. This disables dynamic
titles.
.IP "\fB\-d\fR, \fB\-\-directory\fR\fB=\fR\fIDIRECTORY\fR"
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"
Expand Down
2 changes: 0 additions & 2 deletions man/termite.config.5
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ Whether to hide url hints not matching input in url hints mode.
The font description for the terminal's font.
.IP \fIfullscreen\fR
Enables entering fullscreen mode by pressing F11.
.IP \fIgeometry\fR
The default window geometry for new terminal windows.
.IP \fIicon_name\fR
The name of the icon to be used for the terminal process.
.IP \fImodify_other_keys\fR
Expand Down
31 changes: 8 additions & 23 deletions termite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,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, GtkWidget *scrollbar, GtkWidget *hbox,
config_info *info, char **geometry, char **icon, bool *show_scrollbar);
config_info *info, char **icon, bool *show_scrollbar);
static void set_config(GtkWindow *window, VteTerminal *vte, GtkWidget *scrollbar, GtkWidget *hbox,
config_info *info, char **geometry, char **icon, bool *show_scrollbar,
config_info *info, char **icon, bool *show_scrollbar,
GKeyFile *config);
static long first_row(VteTerminal *vte);

Expand Down Expand Up @@ -1417,7 +1417,7 @@ static void load_theme(GtkWindow *window, VteTerminal *vte, GKeyFile *config, hi
}

static void load_config(GtkWindow *window, VteTerminal *vte, GtkWidget *scrollbar,
GtkWidget *hbox, config_info *info, char **geometry, char **icon,
GtkWidget *hbox, config_info *info, char **icon,
bool *show_scrollbar) {
const std::string default_path = "/termite/config";
GKeyFile *config = g_key_file_new();
Expand Down Expand Up @@ -1453,19 +1453,14 @@ static void load_config(GtkWindow *window, VteTerminal *vte, GtkWidget *scrollba
}

if (loaded) {
set_config(window, vte, scrollbar, hbox, info, geometry, icon, show_scrollbar, config);
set_config(window, vte, scrollbar, hbox, info, icon, show_scrollbar, config);
}
g_key_file_free(config);
}

static void set_config(GtkWindow *window, VteTerminal *vte, GtkWidget *scrollbar, GtkWidget *hbox,
config_info *info, char **geometry, char **icon, bool *show_scrollbar_ptr,
config_info *info, char **icon, bool *show_scrollbar_ptr,
GKeyFile *config) {
if (geometry) {
if (auto s = get_config_string(config, "options", "geometry")) {
*geometry = *s;
}
}

auto cfg_bool = [config](const char *key, gboolean value) {
return get_config<gboolean>(g_key_file_get_boolean,
Expand Down Expand Up @@ -1624,7 +1619,7 @@ int main(int argc, char **argv) {
gboolean version = FALSE, hold = FALSE;

GOptionContext *context = g_option_context_new(nullptr);
char *role = nullptr, *geometry = nullptr, *execute = nullptr, *config_file = nullptr;
char *role = nullptr, *execute = nullptr, *config_file = nullptr;
char *title = nullptr, *icon = nullptr;
bool show_scrollbar = false;
const GOptionEntry entries[] = {
Expand All @@ -1633,7 +1628,6 @@ int main(int argc, char **argv) {
{"role", 'r', 0, G_OPTION_ARG_STRING, &role, "The role to use", "ROLE"},
{"title", 't', 0, G_OPTION_ARG_STRING, &title, "Window title", "TITLE"},
{"directory", 'd', 0, G_OPTION_ARG_STRING, &directory, "Change to directory", "DIRECTORY"},
{"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"},
Expand Down Expand Up @@ -1713,11 +1707,11 @@ int main(int argc, char **argv) {
};

load_config(GTK_WINDOW(window), vte, scrollbar, hbox, &info.config,
geometry ? nullptr : &geometry, icon ? nullptr : &icon, &show_scrollbar);
icon ? nullptr : &icon, &show_scrollbar);

reload_config = [&]{
load_config(GTK_WINDOW(window), vte, scrollbar, hbox, &info.config,
nullptr, nullptr, nullptr);
nullptr, nullptr);
};
signal(SIGUSR1, [](int){ reload_config(); });

Expand Down Expand Up @@ -1779,15 +1773,6 @@ int main(int argc, char **argv) {
}
}

if (geometry) {
gtk_widget_show_all(panel_overlay);
gtk_widget_show_all(info.panel.entry);
if (!gtk_window_parse_geometry(GTK_WINDOW(window), geometry)) {
g_printerr("invalid geometry string: %s\n", geometry);
}
g_free(geometry);
}

if (icon) {
gtk_window_set_icon_name(GTK_WINDOW(window), icon);
g_free(icon);
Expand Down

0 comments on commit a4af9e7

Please sign in to comment.