diff options
-rw-r--r-- | plugins/gtkui/Makefile.am | 1 | ||||
-rw-r--r-- | plugins/gtkui/callbacks.c | 11 | ||||
-rw-r--r-- | plugins/gtkui/gtksession.c | 46 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.c | 30 | ||||
-rw-r--r-- | session.h | 7 |
5 files changed, 35 insertions, 60 deletions
diff --git a/plugins/gtkui/Makefile.am b/plugins/gtkui/Makefile.am index 2055cada..e6fe0485 100644 --- a/plugins/gtkui/Makefile.am +++ b/plugins/gtkui/Makefile.am @@ -7,7 +7,6 @@ gtkui_la_SOURCES = gtkui.c gtkui.h\ drawing.h gdkdrawing.c\ progress.c progress.h\ search.c search.h\ - gtksession.c\ fileman.c gtkui_la_LDFLAGS = -module diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c index 26a6b95f..414eec6c 100644 --- a/plugins/gtkui/callbacks.c +++ b/plugins/gtkui/callbacks.c @@ -1175,7 +1175,16 @@ on_mainwin_configure_event (GtkWidget *widget, GdkEventConfigure *event, gpointer user_data) { - session_capture_window_attrs ((uintptr_t)widget); + if (GTK_WIDGET_VISIBLE (mainwin)) { + int x, y; + int w, h; + gtk_window_get_position (GTK_WINDOW (mainwin), &x, &y); + gtk_window_get_size (GTK_WINDOW (mainwin), &w, &h); + deadbeef->conf_set_int ("mainwin.geometry.x", x); + deadbeef->conf_set_int ("mainwin.geometry.y", y); + deadbeef->conf_set_int ("mainwin.geometry.w", w); + deadbeef->conf_set_int ("mainwin.geometry.h", h); + } return FALSE; } diff --git a/plugins/gtkui/gtksession.c b/plugins/gtkui/gtksession.c deleted file mode 100644 index 1c67a925..00000000 --- a/plugins/gtkui/gtksession.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - DeaDBeeF - ultimate music player for GNU/Linux systems with X11 - Copyright (C) 2009 Alexey Yakovenko - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -#include <stdio.h> -#include <gtk/gtk.h> -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif -#include "session.h" -#include "deadbeef.h" - -extern DB_functions_t *deadbeef; // defined in gtkui.c - -void -session_capture_window_attrs (uintptr_t window) { - GtkWindow *wnd = GTK_WINDOW (window); - int win_attrs[4]; - gtk_window_get_position (wnd, &win_attrs[0], &win_attrs[1]); - gtk_window_get_size (wnd, &win_attrs[2], &win_attrs[3]); - deadbeef->conf_set_int ("mainwin.geometry.x", win_attrs[0]); - deadbeef->conf_set_int ("mainwin.geometry.y", win_attrs[1]); - deadbeef->conf_set_int ("mainwin.geometry.w", win_attrs[2]); - deadbeef->conf_set_int ("mainwin.geometry.h", win_attrs[3]); -} - -void -session_restore_window_attrs (uintptr_t window) { - GtkWindow *wnd = GTK_WINDOW (window); - gtk_window_move (wnd, deadbeef->conf_get_int ("mainwin.geometry.x", 40), deadbeef->conf_get_int ("mainwin.geometry.y", 40)); - gtk_window_resize (wnd, deadbeef->conf_get_int ("mainwin.geometry.w", 500), deadbeef->conf_get_int ("mainwin.geometry.h", 300)); -} diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index d2dc0d4e..bf8003ad 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -25,7 +25,6 @@ #include "interface.h" #include "callbacks.h" #include "support.h" -#include "session.h" #define trace(...) { fprintf(stderr, __VA_ARGS__); } //#define trace(fmt,...) @@ -175,6 +174,7 @@ on_trayicon_scroll_event (GtkWidget *widget, } #if GTK_MINOR_VERSION<=14 + gboolean on_trayicon_activate (GtkWidget *widget, GdkEvent *event, @@ -184,13 +184,20 @@ on_trayicon_activate (GtkWidget *widget, gtk_widget_hide (mainwin); } else { + int x = deadbeef->conf_get_int ("mainwin.geometry.x", 40); + int y = deadbeef->conf_get_int ("mainwin.geometry.y", 40); + int w = deadbeef->conf_get_int ("mainwin.geometry.w", 500); + int h = deadbeef->conf_get_int ("mainwin.geometry.h", 300); + printf ("restore: %d %d %d %d\n", x, y, w, h); gtk_widget_show (mainwin); - session_restore_window_attrs ((uintptr_t)mainwin); + gtk_window_move (mainwin, x, y); + gtk_window_resize (mainwin, w, h); gtk_window_present (GTK_WINDOW (mainwin)); } return FALSE; } -#endif + +#else gboolean on_trayicon_button_press_event (GtkWidget *widget, @@ -203,7 +210,12 @@ on_trayicon_button_press_event (GtkWidget *widget, } else { gtk_widget_show (mainwin); - session_restore_window_attrs ((uintptr_t)mainwin); + int x = deadbeef->conf_get_int ("mainwin.geometry.x", 40); + int y = deadbeef->conf_get_int ("mainwin.geometry.y", 40); + int w = deadbeef->conf_get_int ("mainwin.geometry.w", 500); + 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); gtk_window_present (GTK_WINDOW (mainwin)); } } @@ -212,6 +224,7 @@ on_trayicon_button_press_event (GtkWidget *widget, } return FALSE; } +#endif gboolean on_trayicon_popup_menu (GtkWidget *widget, @@ -327,7 +340,14 @@ gtkui_thread (void *ctx) { gtk_window_set_icon (GTK_WINDOW (mainwin), mainwin_icon_pixbuf); gdk_pixbuf_unref (mainwin_icon_pixbuf); } - session_restore_window_attrs ((uintptr_t)mainwin); + { + int x = deadbeef->conf_get_int ("mainwin.geometry.x", 40); + int y = deadbeef->conf_get_int ("mainwin.geometry.y", 40); + int w = deadbeef->conf_get_int ("mainwin.geometry.w", 500); + 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); + } // order and looping const char *orderwidgets[3] = { "order_linear", "order_shuffle", "order_random" }; const char *loopingwidgets[3] = { "loop_all", "loop_disable", "loop_single" }; @@ -27,11 +27,4 @@ session_save (const char *fname); int session_load (const char *fname); -void -session_capture_window_attrs (uintptr_t window); - -void -session_restore_window_attrs (uintptr_t window); - - #endif // __SESSION_H |