From f6ba2741345fbab44947e9f81ff0ea543aeba030 Mon Sep 17 00:00:00 2001 From: TingPing Date: Thu, 19 Sep 2013 17:52:17 -0400 Subject: [PATCH] Add fullscreen to to view menu --- src/common/cfgfiles.c | 1 + src/common/hexchat.h | 1 + src/fe-gtk/maingui.c | 8 +++++++- src/fe-gtk/menu.c | 28 ++++++++++++++++++++++------ src/fe-gtk/plugin-tray.c | 4 ++++ 5 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c index 675ed837..b7d55e87 100644 --- a/src/common/cfgfiles.c +++ b/src/common/cfgfiles.c @@ -477,6 +477,7 @@ const struct prefs vars[] = {"gui_url_mod", P_OFFINT (hex_gui_url_mod), TYPE_INT}, {"gui_usermenu", P_OFFINT (hex_gui_usermenu), TYPE_BOOL}, {"gui_win_height", P_OFFINT (hex_gui_win_height), TYPE_INT}, + {"gui_win_fullscreen", P_OFFINT (hex_gui_win_fullscreen), TYPE_INT}, {"gui_win_left", P_OFFINT (hex_gui_win_left), TYPE_INT}, {"gui_win_modes", P_OFFINT (hex_gui_win_modes), TYPE_BOOL}, {"gui_win_save", P_OFFINT (hex_gui_win_save), TYPE_BOOL}, diff --git a/src/common/hexchat.h b/src/common/hexchat.h index 68da144d..1307f260 100644 --- a/src/common/hexchat.h +++ b/src/common/hexchat.h @@ -289,6 +289,7 @@ struct hexchatprefs int hex_gui_ulist_sort; int hex_gui_url_mod; int hex_gui_win_height; + int hex_gui_win_fullscreen; int hex_gui_win_left; int hex_gui_win_state; int hex_gui_win_top; diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c index 11b76261..b643485a 100644 --- a/src/fe-gtk/maingui.c +++ b/src/fe-gtk/maingui.c @@ -495,6 +495,10 @@ mg_windowstate_cb (GtkWindow *wid, GdkEventWindowState *event, gpointer userdata if (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) prefs.hex_gui_win_state = 1; + prefs.hex_gui_win_fullscreen = 0; + if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) + prefs.hex_gui_win_fullscreen = 1; + return FALSE; } @@ -505,7 +509,7 @@ mg_configure_cb (GtkWidget *wid, GdkEventConfigure *event, session *sess) { if (mg_gui) { - if (prefs.hex_gui_win_save) + if (prefs.hex_gui_win_save && !prefs.hex_gui_win_state && !prefs.hex_gui_win_fullscreen) { sess = current_sess; gtk_window_get_position (GTK_WINDOW (wid), &prefs.hex_gui_win_left, @@ -3313,6 +3317,8 @@ mg_create_tabwindow (session *sess) prefs.hex_gui_win_top); if (prefs.hex_gui_win_state) gtk_window_maximize (GTK_WINDOW (win)); + if (prefs.hex_gui_win_fullscreen) + gtk_window_fullscreen (GTK_WINDOW (win)); gtk_container_set_border_width (GTK_CONTAINER (win), GUI_BORDER); g_signal_connect (G_OBJECT (win), "delete_event", diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c index 8d87f84e..e348e36a 100644 --- a/src/fe-gtk/menu.c +++ b/src/fe-gtk/menu.c @@ -890,6 +890,23 @@ menu_cmbuttons_toggle (GtkWidget *wid, gpointer ud) prefs.hex_gui_mode_buttons); } +static void +menu_fullscreen_toggle (GtkWidget *wid, gpointer ud) +{ + if (!prefs.hex_gui_win_fullscreen) + gtk_window_fullscreen (GTK_WINDOW(parent_window)); + else + { + gtk_window_unfullscreen (GTK_WINDOW(parent_window)); + + /* At least on Windows we need to manually reposition the window */ + gtk_window_resize (GTK_WINDOW(parent_window), + prefs.hex_gui_win_width, prefs.hex_gui_win_height); + gtk_window_move (GTK_WINDOW(parent_window), + prefs.hex_gui_win_left, prefs.hex_gui_win_top); + } +} + void menu_middlemenu (session *sess, GdkEventButton *event) { @@ -1722,6 +1739,8 @@ static struct mymenu mymenu[] = { {N_("Text"), menu_metres_text, 0, M_MENURADIO, 0, 0, 1}, {N_("Both"), menu_metres_both, 0, M_MENURADIO, 0, 0, 1}, {0, 0, 0, M_END, 0, 0, 0}, /* 32 */ + { 0, 0, 0, M_SEP, 0, 0, 0 }, + {N_ ("Toggle _Fullscreen"), menu_fullscreen_toggle, 0, M_MENUITEM, 0, 0, 1, GDK_KEY_F11}, {N_("_Server"), 0, 0, M_NEWMENU, 0, 0, 1}, {N_("_Disconnect"), menu_disconnect, GTK_STOCK_DISCONNECT, M_MENUSTOCK, MENU_ID_DISCONNECT, 0, 1}, @@ -1729,7 +1748,7 @@ static struct mymenu mymenu[] = { {N_("_Join a Channel..."), menu_join, GTK_STOCK_JUMP_TO, M_MENUSTOCK, MENU_ID_JOIN, 0, 1}, {N_("_List of Channels..."), menu_chanlist, GTK_STOCK_INDEX, M_MENUITEM, 0, 0, 1}, {0, 0, 0, M_SEP, 0, 0, 0}, -#define AWAY_OFFSET (39) +#define AWAY_OFFSET (41) {N_("Marked _Away"), menu_away, 0, M_MENUTOG, MENU_ID_AWAY, 0, 1, GDK_a}, {N_("_Usermenu"), 0, 0, M_NEWMENU, MENU_ID_USERMENU, 0, 1}, /* 40 */ @@ -1762,7 +1781,7 @@ static struct mymenu mymenu[] = { {N_("_Copy Selection"), menu_copy_selection, 0, M_MENUITEM, 0, 0, 1, GDK_C}, {N_("C_lear Text"), menu_flushbuffer, GTK_STOCK_CLEAR, M_MENUSTOCK, 0, 0, 1}, {N_("Save Text..."), menu_savebuffer, GTK_STOCK_SAVE, M_MENUSTOCK, 0, 0, 1}, -#define SEARCH_OFFSET 68 +#define SEARCH_OFFSET (70) {N_("Search"), 0, GTK_STOCK_JUSTIFY_LEFT, M_MENUSUB, 0, 0, 1}, {N_("Search Text..."), menu_search, GTK_STOCK_FIND, M_MENUSTOCK, 0, 0, 1, GDK_f}, {N_("Search Next" ), menu_search_next, GTK_STOCK_FIND, M_MENUSTOCK, 0, 0, 1, GDK_g}, @@ -1770,11 +1789,7 @@ static struct mymenu mymenu[] = { {0, 0, 0, M_END, 0, 0, 0}, {N_("_Help"), 0, 0, M_NEWMENU, 0, 0, 1}, /* 74 */ - {N_("_Contents"), menu_docs, GTK_STOCK_HELP, M_MENUSTOCK, 0, 0, 1, GDK_F1}, -#if 0 - {N_("Check for updates"), menu_update, 0, M_MENUITEM, 0, 1}, -#endif {N_("_About"), menu_about, GTK_STOCK_ABOUT, M_MENUSTOCK, 0, 0, 1}, {0, 0, 0, M_END, 0, 0, 0}, @@ -2296,6 +2311,7 @@ normalitem: gtk_widget_add_accelerator (item, "activate", accel_group, mymenu[i].key, mymenu[i].key == GDK_F1 ? 0 : + mymenu[i].key == GDK_F11 ? 0 : mymenu[i].key == GDK_w ? close_mask : (g_ascii_isupper (mymenu[i].key)) ? STATE_SHIFT | STATE_CTRL : diff --git a/src/fe-gtk/plugin-tray.c b/src/fe-gtk/plugin-tray.c index 731d5857..aa0b0cee 100644 --- a/src/fe-gtk/plugin-tray.c +++ b/src/fe-gtk/plugin-tray.c @@ -408,6 +408,7 @@ tray_toggle_visibility (gboolean force_hide) static int x, y; static GdkScreen *screen; static int maximized; + static int fullscreen; GtkWindow *win; if (!sticon) @@ -431,6 +432,7 @@ tray_toggle_visibility (gboolean force_hide) gtk_window_get_position (win, &x, &y); screen = gtk_window_get_screen (win); maximized = prefs.hex_gui_win_state; + fullscreen = prefs.hex_gui_win_fullscreen; gtk_widget_hide (GTK_WIDGET (win)); } else @@ -441,6 +443,8 @@ tray_toggle_visibility (gboolean force_hide) gtk_window_move (win, x, y); if (maximized) gtk_window_maximize (win); + if (fullscreen) + gtk_window_fullscreen (win); gtk_widget_show (GTK_WIDGET (win)); gtk_window_present (win); }