From 4e582af3ff02eebe2c5a1172dbd3052a0fafcf60 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Tue, 24 May 2011 06:51:16 +0000 Subject: [PATCH] Add fullscreen view --- data/main.ui.in | 50 ++++++++++++++++++++++++++++++++++++++++------ src/aweather-gui.c | 22 +++++++++++++++++++- 2 files changed, 65 insertions(+), 7 deletions(-) diff --git a/data/main.ui.in b/data/main.ui.in index 23a0494..7f419aa 100644 --- a/data/main.ui.in +++ b/data/main.ui.in @@ -121,6 +121,19 @@ True + + + True + fullscreen + True + True + + + + + True + + True @@ -210,6 +223,28 @@ True + + + True + fullscreen + True + toolbutton1 + True + + + False + True + + + + + True + + + False + True + + True @@ -236,7 +271,7 @@ - + True @@ -283,7 +318,7 @@ - + True vertical 5 @@ -426,9 +461,8 @@ 5 Preferences - AWeather normal - False - + True @@ -657,7 +691,6 @@ About - AWeather center-on-parent dialog - False AWeather @VERSION@ Copyright ©2008-2009 Andy Spencer @@ -909,8 +942,8 @@ The hypothetical commands `show w' and `show c' should show the appropriate part Andy Spencer <andy753421@gmail.com> True - + True @@ -958,4 +991,9 @@ The hypothetical commands `show w' and `show c' should show the appropriate part gtk-clear + + Fullscreen + gtk-fullscreen + + diff --git a/src/aweather-gui.c b/src/aweather-gui.c index 6c5b5a6..7b42818 100644 --- a/src/aweather-gui.c +++ b/src/aweather-gui.c @@ -34,8 +34,13 @@ G_MODULE_EXPORT gboolean on_gui_key_press(GtkWidget *widget, GdkEventKey *event, { g_debug("AWeatherGui: on_gui_key_press - key=%x, state=%x", event->keyval, event->state); + GObject *action = aweather_gui_get_object(self, "fullscreen"); + gboolean full = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); if (event->keyval == GDK_q) gtk_widget_destroy(GTK_WIDGET(self)); + else if (event->keyval == GDK_F11 || + (event->keyval == GDK_Escape && full)) + gtk_action_activate(GTK_ACTION(action)); else if (event->keyval == GDK_r && event->state & GDK_CONTROL_MASK) grits_viewer_refresh(self->viewer); else if (event->keyval == GDK_Tab || event->keyval == GDK_ISO_Left_Tab) { @@ -109,6 +114,21 @@ G_MODULE_EXPORT void on_zoomout(GtkAction *action, AWeatherGui *self) grits_viewer_zoom(self->viewer, 4./3); } +G_MODULE_EXPORT void on_fullscreen(GtkToggleAction *action, AWeatherGui *self) +{ + g_message("fullscreen"); + gchar *hide[] = {"main_menu", "main_sidebar", "main_tabs"}; + if (gtk_toggle_action_get_active(action)) { + gtk_window_fullscreen(GTK_WINDOW(self)); + for (int i = 0; i < G_N_ELEMENTS(hide); i++) + gtk_widget_hide(aweather_gui_get_widget(self, hide[i])); + } else { + gtk_window_unfullscreen(GTK_WINDOW(self)); + for (int i = 0; i < G_N_ELEMENTS(hide); i++) + gtk_widget_show(aweather_gui_get_widget(self, hide[i])); + } +} + G_MODULE_EXPORT void on_refresh(GtkAction *action, AWeatherGui *self) { grits_viewer_refresh(self->viewer); @@ -246,7 +266,7 @@ static void site_setup(AWeatherGui *self) gtk_tree_store_append(store, &state, NULL); gtk_tree_store_set (store, &state, 0, cities[i].code, 1, cities[i].name, -1); - } else if (cities[i].type == LOCATION_CITY) { + } else { gtk_tree_store_append(store, &city, &state); gtk_tree_store_set (store, &city, 0, cities[i].code, 1, cities[i].name, -1); -- 2.43.2