diff options
-rw-r--r-- | plugins/gtkui/callbacks.c | 37 | ||||
-rw-r--r-- | plugins/gtkui/callbacks.h | 5 | ||||
-rw-r--r-- | plugins/gtkui/deadbeef.glade | 1 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.c | 9 | ||||
-rw-r--r-- | plugins/gtkui/interface.c | 3 |
5 files changed, 54 insertions, 1 deletions
diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c index 414eec6c..bba9aa4f 100644 --- a/plugins/gtkui/callbacks.c +++ b/plugins/gtkui/callbacks.c @@ -1175,7 +1175,12 @@ on_mainwin_configure_event (GtkWidget *widget, GdkEventConfigure *event, gpointer user_data) { - if (GTK_WIDGET_VISIBLE (mainwin)) { +#if GTK_CHECK_VERSION(2,2,0) + GdkWindowState window_state = gdk_window_get_state (GDK_WINDOW (mainwin->window)); +#else + GdkWindowState window_state = gdk_window_get_state (G_OBJECT (mainwin)); +#endif + if (!(window_state & GDK_WINDOW_STATE_MAXIMIZED) && GTK_WIDGET_VISIBLE (mainwin)) { int x, y; int w, h; gtk_window_get_position (GTK_WINDOW (mainwin), &x, &y); @@ -1184,6 +1189,7 @@ on_mainwin_configure_event (GtkWidget *widget, deadbeef->conf_set_int ("mainwin.geometry.y", y); deadbeef->conf_set_int ("mainwin.geometry.w", w); deadbeef->conf_set_int ("mainwin.geometry.h", h); + printf ("save %d %d %d %d\n", x, y, w, h); } return FALSE; } @@ -1968,3 +1974,32 @@ on_configure_plugin_clicked (GtkButton *button, } } + +gboolean +on_mainwin_window_state_event (GtkWidget *widget, + GdkEventWindowState *event, + gpointer user_data) +{ + // based on pidgin maximization handler +#if GTK_CHECK_VERSION(2,2,0) + if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) { + if (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) { + deadbeef->conf_set_int ("mainwin.geometry.maximized", 1); + } + else { + deadbeef->conf_set_int ("mainwin.geometry.maximized", 0); + } + } +#else + GdkWindowState new_window_state = gdk_window_get_state(G_OBJECT(widget)); + + if (new_window_state & GDK_WINDOW_STATE_MAXIMIZED) { + deadbeef->conf_set_int ("mainwin.geometry.maximized", 1); + } + else { + deadbeef->conf_set_int ("mainwin.geometry.maximized", 0); + } +#endif + return FALSE; +} + diff --git a/plugins/gtkui/callbacks.h b/plugins/gtkui/callbacks.h index 0f4624f2..acf23a02 100644 --- a/plugins/gtkui/callbacks.h +++ b/plugins/gtkui/callbacks.h @@ -696,3 +696,8 @@ on_addlocation_entry_activate (GtkEntry *entry, void on_configure_plugin_clicked (GtkButton *button, gpointer user_data); + +gboolean +on_mainwin_window_state_event (GtkWidget *widget, + GdkEventWindowState *event, + gpointer user_data); diff --git a/plugins/gtkui/deadbeef.glade b/plugins/gtkui/deadbeef.glade index c622f6b5..9615d476 100644 --- a/plugins/gtkui/deadbeef.glade +++ b/plugins/gtkui/deadbeef.glade @@ -25,6 +25,7 @@ <signal name="key_press_event" handler="on_mainwin_key_press_event" last_modification_time="Thu, 30 Jul 2009 21:14:26 GMT"/> <signal name="delete_event" handler="on_mainwin_delete_event" last_modification_time="Thu, 13 Aug 2009 20:35:55 GMT"/> <signal name="configure_event" handler="on_mainwin_configure_event" last_modification_time="Sun, 23 Aug 2009 15:26:53 GMT"/> + <signal name="window_state_event" handler="on_mainwin_window_state_event" last_modification_time="Wed, 09 Dec 2009 19:39:55 GMT"/> <child> <widget class="GtkVBox" id="vbox1"> diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index bf8003ad..0c30773d 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -192,6 +192,9 @@ on_trayicon_activate (GtkWidget *widget, gtk_widget_show (mainwin); gtk_window_move (mainwin, x, y); gtk_window_resize (mainwin, w, h); + if (deadbeef->conf_get_int ("mainwin.geometry.maximized", 0)) { + gtk_window_maximize (GTK_WINDOW (mainwin)); + } gtk_window_present (GTK_WINDOW (mainwin)); } return FALSE; @@ -216,6 +219,9 @@ on_trayicon_button_press_event (GtkWidget *widget, int h = deadbeef->conf_get_int ("mainwin.geometry.h", 300); gtk_window_move (GTK_WINDOW (mainwin), x, y); gtk_window_resize (GTK_WINDOW (mainwin), w, h); + if (deadbeef->conf_get_int ("mainwin.geometry.maximized", 0)) { + gtk_window_maximize (GTK_WINDOW (mainwin)); + } gtk_window_present (GTK_WINDOW (mainwin)); } } @@ -347,6 +353,9 @@ gtkui_thread (void *ctx) { int h = deadbeef->conf_get_int ("mainwin.geometry.h", 300); gtk_window_move (GTK_WINDOW (mainwin), x, y); gtk_window_resize (GTK_WINDOW (mainwin), w, h); + if (deadbeef->conf_get_int ("mainwin.geometry.maximized", 0)) { + gtk_window_maximize (GTK_WINDOW (mainwin)); + } } // order and looping const char *orderwidgets[3] = { "order_linear", "order_shuffle", "order_random" }; diff --git a/plugins/gtkui/interface.c b/plugins/gtkui/interface.c index 1c1d41e9..d3df2830 100644 --- a/plugins/gtkui/interface.c +++ b/plugins/gtkui/interface.c @@ -489,6 +489,9 @@ create_mainwin (void) g_signal_connect ((gpointer) mainwin, "configure_event", G_CALLBACK (on_mainwin_configure_event), NULL); + g_signal_connect ((gpointer) mainwin, "window_state_event", + G_CALLBACK (on_mainwin_window_state_event), + NULL); g_signal_connect ((gpointer) open, "activate", G_CALLBACK (on_open_activate), NULL); |