summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorTingPing <tingping@tingping.se>2013-10-23 09:11:30 -0400
committerTingPing <tingping@tingping.se>2013-10-27 13:24:15 -0400
commite8d4f3f848b34a939696ccf1309abcf468c8ff10 (patch)
tree36c7332103403fa10d285a68b7e2146b57308356 /src
parent30a47cf62e50c79693dfe641977fad9cbe66f86d (diff)
Properly set away and fullscreen menu items
Diffstat (limited to 'src')
-rw-r--r--src/fe-gtk/fe-gtk.h2
-rw-r--r--src/fe-gtk/maingui.c6
-rw-r--r--src/fe-gtk/menu.c34
-rw-r--r--src/fe-gtk/menu.h6
4 files changed, 38 insertions, 10 deletions
diff --git a/src/fe-gtk/fe-gtk.h b/src/fe-gtk/fe-gtk.h
index 6f5b47c5..623f2c01 100644
--- a/src/fe-gtk/fe-gtk.h
+++ b/src/fe-gtk/fe-gtk.h
@@ -179,7 +179,7 @@ typedef struct session_gui
 		GtkWidget *shbox, *shentry;	/* search bar hbox */
 		gulong search_changed_signal; /* hook for search change event so blanking the box doesn't suck */
 
-#define MENU_ID_NUM 12
+#define MENU_ID_NUM 13
 	GtkWidget *menu_item[MENU_ID_NUM+1]; /* some items we may change state of */
 
 	void *chanview;	/* chanview.h */
diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c
index 60060431..0f8db0bf 100644
--- a/src/fe-gtk/maingui.c
+++ b/src/fe-gtk/maingui.c
@@ -453,6 +453,8 @@ mg_windowstate_cb (GtkWindow *wid, GdkEventWindowState *event, gpointer userdata
 	if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)
 		prefs.hex_gui_win_fullscreen = 1;
 
+	menu_set_fullscreen (current_sess->gui, prefs.hex_gui_win_fullscreen);
+
 	return FALSE;
 }
 
@@ -951,7 +953,7 @@ mg_populate (session *sess)
 	}
 
 	/* menu items */
-	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (gui->menu_item[MENU_ID_AWAY]), sess->server->is_away);
+	menu_set_away (gui, sess->server->is_away);
 	gtk_widget_set_sensitive (gui->menu_item[MENU_ID_AWAY], sess->server->connected);
 	gtk_widget_set_sensitive (gui->menu_item[MENU_ID_JOIN], sess->server->end_of_motd);
 	gtk_widget_set_sensitive (gui->menu_item[MENU_ID_DISCONNECT],
@@ -3482,7 +3484,7 @@ fe_set_away (server *serv)
 		{
 			if (!sess->gui->is_tab || sess == current_tab)
 			{
-				GTK_CHECK_MENU_ITEM (sess->gui->menu_item[MENU_ID_AWAY])->active = serv->is_away;
+				menu_set_away (sess->gui, serv->is_away);
 				/* gray out my nickname */
 				mg_set_myself_away (sess->gui, serv->is_away);
 			}
diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c
index 72ba6b50..824828b3 100644
--- a/src/fe-gtk/menu.c
+++ b/src/fe-gtk/menu.c
@@ -1390,7 +1390,7 @@ menu_join (GtkWidget * wid, gpointer none)
 static void
 menu_away (GtkCheckMenuItem *item, gpointer none)
 {
-	handle_command (current_sess, item->active ? "away" : "back", FALSE);
+	handle_command (current_sess, gtk_check_menu_item_get_active (item) ? "away" : "back", FALSE);
 }
 
 static void
@@ -1746,7 +1746,7 @@ static struct mymenu mymenu[] = {
 		{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_ ("_Fullscreen"), menu_fullscreen_toggle, 0, M_MENUTOG, MENU_ID_FULLSCREEN, 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},
@@ -1801,6 +1801,26 @@ static struct mymenu mymenu[] = {
 	{0, 0, 0, M_END, 0, 0, 0},
 };
 
+void
+menu_set_away (session_gui *gui, int away)
+{
+	GtkCheckMenuItem *item = GTK_CHECK_MENU_ITEM (gui->menu_item[MENU_ID_AWAY]);
+
+	g_signal_handlers_block_by_func (G_OBJECT (item), menu_away, NULL);
+	gtk_check_menu_item_set_active (item, away);
+	g_signal_handlers_unblock_by_func (G_OBJECT (item), menu_away, NULL);
+}
+
+void
+menu_set_fullscreen (session_gui *gui, int full)
+{
+	GtkCheckMenuItem *item = GTK_CHECK_MENU_ITEM (gui->menu_item[MENU_ID_FULLSCREEN]);
+
+	g_signal_handlers_block_by_func (G_OBJECT (item), menu_fullscreen_toggle, NULL);
+	gtk_check_menu_item_set_active (item, full);
+	g_signal_handlers_unblock_by_func (G_OBJECT (item), menu_fullscreen_toggle, NULL);
+}
+
 GtkWidget *
 create_icon_menu (char *labeltext, void *stock_name, int is_stock)
 {
@@ -2317,7 +2337,6 @@ normalitem:
 				gtk_widget_add_accelerator (item, "activate", accel_group,
 										mymenu[i].key,
 										mymenu[i].key == GDK_KEY_F1 ? 0 :
-										mymenu[i].key == GDK_KEY_F11 ? 0 :
 										mymenu[i].key == GDK_KEY_w ? close_mask :
 										(g_ascii_isupper (mymenu[i].key)) ?
 											STATE_SHIFT | STATE_CTRL :
@@ -2342,11 +2361,14 @@ togitem:
 													 mymenu[i].state);*/
 			if (mymenu[i].key != 0)
 				gtk_widget_add_accelerator (item, "activate", accel_group,
-									mymenu[i].key, mymenu[i].id == MENU_ID_AWAY ?
-									away_mask : STATE_CTRL, GTK_ACCEL_VISIBLE);
+											mymenu[i].key,
+											mymenu[i].id == MENU_ID_FULLSCREEN ? 0 :
+											mymenu[i].id == MENU_ID_AWAY ? away_mask :
+											STATE_CTRL, GTK_ACCEL_VISIBLE);
 			if (mymenu[i].callback)
 				g_signal_connect (G_OBJECT (item), "toggled",
-										G_CALLBACK (mymenu[i].callback), 0);
+									G_CALLBACK (mymenu[i].callback), NULL);
+
 			if (submenu)
 				gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item);
 			else
diff --git a/src/fe-gtk/menu.h b/src/fe-gtk/menu.h
index 3dd96261..ca3dee63 100644
--- a/src/fe-gtk/menu.h
+++ b/src/fe-gtk/menu.h
@@ -39,6 +39,9 @@ void menu_bar_toggle (void);
 void menu_add_plugin_items (GtkWidget *menu, char *root, char *target);
 void menu_change_layout (void);
 
+void menu_set_away (session_gui *gui, int away);
+void menu_set_fullscreen (session_gui *gui, int fullscreen);
+
 /* for menu_quick functions */
 #define XCMENU_DOLIST 1
 #define XCMENU_SHADED 1
@@ -58,8 +61,9 @@ void menu_change_layout (void);
 #define MENU_ID_RECONNECT 10
 #define MENU_ID_JOIN 11
 #define MENU_ID_USERMENU 12
+#define MENU_ID_FULLSCREEN 13
 
-#if (MENU_ID_NUM < MENU_ID_USERMENU)
+#if (MENU_ID_NUM < MENU_ID_FULLSCREEN)
 #error MENU_ID_NUM is set wrong
 #endif