diff options
author | Antenore Gatta <antenore@simbiosi.org> | 2020-05-20 18:13:58 +0300 |
---|---|---|
committer | Antenore Gatta <antenore@simbiosi.org> | 2020-05-20 18:14:08 +0300 |
commit | b86788060cf1abaacf5ea1f89c73194be90e4062 (patch) | |
tree | 54910b89585b7c96b18d158c992dba9492b7af25 /src | |
parent | 315787f77e0f0b9cc510ed173e2fb1f0d58f8677 (diff) |
SSH plugin - adding font resize - closes #2201
Signed-off-by: Antenore Gatta <antenore@simbiosi.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/remmina_pref.c | 13 | ||||
-rw-r--r-- | src/remmina_pref.h | 2 | ||||
-rw-r--r-- | src/remmina_pref_dialog.c | 6 | ||||
-rw-r--r-- | src/remmina_pref_dialog.h | 2 | ||||
-rw-r--r-- | src/remmina_ssh_plugin.c | 41 | ||||
-rw-r--r-- | src/remmina_ssh_plugin.h | 2 |
6 files changed, 65 insertions, 1 deletions
diff --git a/src/remmina_pref.c b/src/remmina_pref.c index e62ebbba9..1e55faaa0 100644 --- a/src/remmina_pref.c +++ b/src/remmina_pref.c @@ -639,6 +639,19 @@ void remmina_pref_init(void) else remmina_pref.vte_shortcutkey_select_all = GDK_KEY_a; + if (g_key_file_has_key(gkeyfile, "remmina_pref", "vte_shortcutkey_increase_font", NULL)) + remmina_pref.vte_shortcutkey_increase_font = g_key_file_get_integer(gkeyfile, "remmina_pref", "vte_shortcutkey_increase_font", + NULL); + else + remmina_pref.vte_shortcutkey_increase_font = GDK_KEY_Page_Up; + + if (g_key_file_has_key(gkeyfile, "remmina_pref", "vte_shortcutkey_decrease_font", NULL)) + remmina_pref.vte_shortcutkey_decrease_font = g_key_file_get_integer(gkeyfile, "remmina_pref", "vte_shortcutkey_decrease_font", + NULL); + else + remmina_pref.vte_shortcutkey_decrease_font = GDK_KEY_Page_Down; + + /* If we have a color scheme file, we switch to it, GIO will merge it in the * remmina.pref file */ if (g_file_test(remmina_colors_file, G_FILE_TEST_IS_REGULAR)) { diff --git a/src/remmina_pref.h b/src/remmina_pref.h index 2b3a32fb6..8f575829a 100644 --- a/src/remmina_pref.h +++ b/src/remmina_pref.h @@ -169,6 +169,8 @@ typedef struct _RemminaPref { guint vte_shortcutkey_copy; guint vte_shortcutkey_paste; guint vte_shortcutkey_select_all; + guint vte_shortcutkey_increase_font; + guint vte_shortcutkey_decrease_font; /* In View menu */ gboolean hide_toolbar; gboolean small_toolbutton; diff --git a/src/remmina_pref_dialog.c b/src/remmina_pref_dialog.c index dd048358b..52be09225 100644 --- a/src/remmina_pref_dialog.c +++ b/src/remmina_pref_dialog.c @@ -346,6 +346,8 @@ void remmina_pref_on_dialog_destroy(GtkWidget *widget, gpointer user_data) remmina_pref.vte_shortcutkey_copy = remmina_key_chooser_get_keyval(gtk_button_get_label(remmina_pref_dialog->button_keyboard_copy)); remmina_pref.vte_shortcutkey_paste = remmina_key_chooser_get_keyval(gtk_button_get_label(remmina_pref_dialog->button_keyboard_paste)); remmina_pref.vte_shortcutkey_select_all = remmina_key_chooser_get_keyval(gtk_button_get_label(remmina_pref_dialog->button_keyboard_select_all)); + remmina_pref.vte_shortcutkey_increase_font = remmina_key_chooser_get_keyval(gtk_button_get_label(remmina_pref_dialog->button_keyboard_increase_font)); + remmina_pref.vte_shortcutkey_decrease_font = remmina_key_chooser_get_keyval(gtk_button_get_label(remmina_pref_dialog->button_keyboard_decrease_font)); remmina_pref_save(); remmina_pref_init(); @@ -602,6 +604,8 @@ static void remmina_pref_dialog_init(void) remmina_pref_dialog_set_button_label(remmina_pref_dialog->button_keyboard_copy, remmina_pref.vte_shortcutkey_copy); remmina_pref_dialog_set_button_label(remmina_pref_dialog->button_keyboard_paste, remmina_pref.vte_shortcutkey_paste); remmina_pref_dialog_set_button_label(remmina_pref_dialog->button_keyboard_select_all, remmina_pref.vte_shortcutkey_select_all); + remmina_pref_dialog_set_button_label(remmina_pref_dialog->button_keyboard_increase_font, remmina_pref.vte_shortcutkey_increase_font); + remmina_pref_dialog_set_button_label(remmina_pref_dialog->button_keyboard_decrease_font, remmina_pref.vte_shortcutkey_decrease_font); remmina_plugin_manager_for_each_plugin(REMMINA_PLUGIN_TYPE_PREF, remmina_pref_dialog_add_pref_plugin, remmina_pref_dialog->dialog); @@ -682,6 +686,8 @@ GtkDialog* remmina_pref_dialog_new(gint default_tab, GtkWindow *parent) remmina_pref_dialog->button_keyboard_copy = GTK_BUTTON(GET_OBJECT("button_keyboard_copy")); remmina_pref_dialog->button_keyboard_paste = GTK_BUTTON(GET_OBJECT("button_keyboard_paste")); remmina_pref_dialog->button_keyboard_select_all = GTK_BUTTON(GET_OBJECT("button_keyboard_select_all")); + remmina_pref_dialog->button_keyboard_increase_font = GTK_BUTTON(GET_OBJECT("button_keyboard_increase_font")); + remmina_pref_dialog->button_keyboard_decrease_font = GTK_BUTTON(GET_OBJECT("button_keyboard_decrease_font")); remmina_pref_dialog->label_terminal_foreground = GTK_LABEL(GET_OBJECT("label_terminal_foreground")); remmina_pref_dialog->colorbutton_foreground = GTK_COLOR_BUTTON(GET_OBJECT("colorbutton_foreground")); remmina_pref_dialog->label_terminal_background = GTK_LABEL(GET_OBJECT("label_terminal_background")); diff --git a/src/remmina_pref_dialog.h b/src/remmina_pref_dialog.h index 89d88aecb..e29fd79d5 100644 --- a/src/remmina_pref_dialog.h +++ b/src/remmina_pref_dialog.h @@ -111,6 +111,8 @@ typedef struct _RemminaPrefDialog { GtkButton * button_keyboard_copy; GtkButton * button_keyboard_paste; GtkButton * button_keyboard_select_all; + GtkButton * button_keyboard_increase_font; + GtkButton * button_keyboard_decrease_font; GtkLabel * label_terminal_cursor_color; GtkLabel * label_terminal_normal_colors; GtkLabel * label_terminal_bright_colors; diff --git a/src/remmina_ssh_plugin.c b/src/remmina_ssh_plugin.c index bf5d42f60..57d5982f0 100644 --- a/src/remmina_ssh_plugin.c +++ b/src/remmina_ssh_plugin.c @@ -58,11 +58,17 @@ #define REMMINA_PLUGIN_SSH_FEATURE_TOOL_COPY 1 #define REMMINA_PLUGIN_SSH_FEATURE_TOOL_PASTE 2 #define REMMINA_PLUGIN_SSH_FEATURE_TOOL_SELECT_ALL 3 +#define REMMINA_PLUGIN_SSH_FEATURE_TOOL_INCREASE_FONT 4 +#define REMMINA_PLUGIN_SSH_FEATURE_TOOL_DECREASE_FONT 5 #define GET_PLUGIN_DATA(gp) (RemminaPluginSshData *)g_object_get_data(G_OBJECT(gp), "plugin-data"); /** Palette colors taken from sakura */ #define PALETTE_SIZE 16 +/* Min fontsize and increase */ +#define FONT_SCALE 0.75 +#define SCALE_FACTOR 0.1 +#define FONT_MINIMAL_SIZE (PANGO_SCALE*6) enum color_schemes { LINUX, TANGO, GRUVBOX, SOLARIZED_DARK, SOLARIZED_LIGHT, XTERM, CUSTOM }; @@ -408,6 +414,20 @@ remmina_plugin_ssh_vte_select_all(GtkMenuItem *menuitem, gpointer vte) } void +remmina_plugin_ssh_vte_decrease_font(GtkMenuItem *menuitem, gpointer vte) +{ + TRACE_CALL(__func__); + vte_terminal_set_font_scale(VTE_TERMINAL(vte), vte_terminal_get_font_scale(VTE_TERMINAL(vte))-SCALE_FACTOR); +} + +void +remmina_plugin_ssh_vte_increase_font(GtkMenuItem *menuitem, gpointer vte) +{ + TRACE_CALL(__func__); + vte_terminal_set_font_scale(VTE_TERMINAL(vte), vte_terminal_get_font_scale(VTE_TERMINAL(vte))+SCALE_FACTOR); +} + +void remmina_plugin_ssh_vte_copy_clipboard(GtkMenuItem *menuitem, gpointer vte) { TRACE_CALL(__func__); @@ -514,11 +534,15 @@ void remmina_plugin_ssh_popup_ui(RemminaProtocolWidget *gp) GtkWidget *copy = gtk_menu_item_new_with_label(_("Copy (host + C)")); GtkWidget *paste = gtk_menu_item_new_with_label(_("Paste (host + V)")); GtkWidget *save = gtk_menu_item_new_with_label(_("Save session to file")); + GtkWidget *font_incr = gtk_menu_item_new_with_label(_("Increase font size (Host + Page_Up)")); + GtkWidget *font_decr = gtk_menu_item_new_with_label(_("Decrease font size (Host + Page_Down)")); gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_all); gtk_menu_shell_append(GTK_MENU_SHELL(menu), copy); gtk_menu_shell_append(GTK_MENU_SHELL(menu), paste); gtk_menu_shell_append(GTK_MENU_SHELL(menu), save); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), font_incr); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), font_decr); g_signal_connect(G_OBJECT(gpdata->vte), "button_press_event", G_CALLBACK(remmina_ssh_plugin_popup_menu), menu); @@ -531,6 +555,10 @@ void remmina_plugin_ssh_popup_ui(RemminaProtocolWidget *gp) G_CALLBACK(remmina_plugin_ssh_vte_paste_clipboard), gpdata->vte); g_signal_connect(G_OBJECT(save), "activate", G_CALLBACK(remmina_plugin_ssh_vte_save_session), gp); + g_signal_connect(G_OBJECT(font_incr), "activate", + G_CALLBACK(remmina_plugin_ssh_vte_increase_font), gpdata->vte); + g_signal_connect(G_OBJECT(font_decr), "activate", + G_CALLBACK(remmina_plugin_ssh_vte_decrease_font), gpdata->vte); gtk_widget_show_all(menu); } @@ -912,6 +940,14 @@ remmina_plugin_ssh_call_feature(RemminaProtocolWidget *gp, const RemminaProtocol case REMMINA_PLUGIN_SSH_FEATURE_TOOL_SELECT_ALL: vte_terminal_select_all(VTE_TERMINAL(gpdata->vte)); return; + case REMMINA_PLUGIN_SSH_FEATURE_TOOL_INCREASE_FONT: + vte_terminal_set_font_scale(VTE_TERMINAL(gpdata->vte), + vte_terminal_get_font_scale(VTE_TERMINAL(gpdata->vte))+SCALE_FACTOR); + return; + case REMMINA_PLUGIN_SSH_FEATURE_TOOL_DECREASE_FONT: + vte_terminal_set_font_scale(VTE_TERMINAL(gpdata->vte), + vte_terminal_get_font_scale(VTE_TERMINAL(gpdata->vte))-SCALE_FACTOR); + return; } } @@ -1000,6 +1036,8 @@ static RemminaProtocolFeature remmina_plugin_ssh_features[] = { REMMINA_PROTOCOL_FEATURE_TYPE_TOOL, REMMINA_PLUGIN_SSH_FEATURE_TOOL_COPY, N_("Copy"), N_("_Copy"), NULL }, { REMMINA_PROTOCOL_FEATURE_TYPE_TOOL, REMMINA_PLUGIN_SSH_FEATURE_TOOL_PASTE, N_("Paste"), N_("_Paste"), NULL }, { REMMINA_PROTOCOL_FEATURE_TYPE_TOOL, REMMINA_PLUGIN_SSH_FEATURE_TOOL_SELECT_ALL, N_("Select all"), N_("_Select all"), NULL }, + { REMMINA_PROTOCOL_FEATURE_TYPE_TOOL, REMMINA_PLUGIN_SSH_FEATURE_TOOL_INCREASE_FONT, N_("Increase font size"), N_("_Increase font size"), NULL }, + { REMMINA_PROTOCOL_FEATURE_TYPE_TOOL, REMMINA_PLUGIN_SSH_FEATURE_TOOL_DECREASE_FONT, N_("Decrease font size"), N_("_Decrease font size"), NULL }, { REMMINA_PROTOCOL_FEATURE_TYPE_END, 0, NULL, NULL, NULL } }; @@ -1205,7 +1243,8 @@ remmina_ssh_plugin_register(void) remmina_plugin_ssh_features[0].opt3 = GUINT_TO_POINTER(remmina_pref.vte_shortcutkey_copy); remmina_plugin_ssh_features[1].opt3 = GUINT_TO_POINTER(remmina_pref.vte_shortcutkey_paste); remmina_plugin_ssh_features[2].opt3 = GUINT_TO_POINTER(remmina_pref.vte_shortcutkey_select_all); - remmina_plugin_ssh_features[3].opt3 = GUINT_TO_POINTER(remmina_pref.vte_shortcutkey_select_all); + remmina_plugin_ssh_features[3].opt3 = GUINT_TO_POINTER(remmina_pref.vte_shortcutkey_increase_font); + remmina_plugin_ssh_features[4].opt3 = GUINT_TO_POINTER(remmina_pref.vte_shortcutkey_decrease_font); remmina_plugin_service = &remmina_plugin_manager_service; diff --git a/src/remmina_ssh_plugin.h b/src/remmina_ssh_plugin.h index 18529da79..a933bab20 100644 --- a/src/remmina_ssh_plugin.h +++ b/src/remmina_ssh_plugin.h @@ -59,6 +59,8 @@ void remmina_plugin_ssh_vte_terminal_set_encoding_and_pty(VteTerminal *terminal, void remmina_plugin_ssh_vte_select_all(GtkMenuItem *menuitem, gpointer vte); void remmina_plugin_ssh_vte_copy_clipboard(GtkMenuItem *menuitem, gpointer vte); void remmina_plugin_ssh_vte_paste_clipboard(GtkMenuItem *menuitem, gpointer vte); +void remmina_plugin_ssh_vte_decrease_font(GtkMenuItem *menuitem, gpointer vte); +void remmina_plugin_ssh_vte_increase_font(GtkMenuItem *menuitem, gpointer vte); gboolean remmina_ssh_plugin_popup_menu(GtkWidget *widget, GdkEvent *event, GtkWidget *menu); #endif |