Place embedded windows with panel orientation, used on startup
[window-docker.git] / panel.c
blob39bd236213c91a97f18152dfaf88a8d19b6ff2ed
1 /*
2 * Window Docker
4 * Copyright (C) 2011 Nikita Zlobin <cook60020tmp@mail.ru>
6 **************************************************************************
7 * This file contains desktop panel implementation, used in Window Docker
8 **************************************************************************
10 * Window Docker is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
15 * Window Docker is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with Window Docker. If not, see <http://www.gnu.org/licenses/>
22 * or write to the Free Software Foundation, Inc.,
23 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "panel.h"
27 #include <stdlib.h>
29 static PanelWindow defaults = {
30 .win = NULL,
31 .container = NULL,
32 .orig = { .x = 0, .y = 0 },
34 .size = 0,
35 .pos = {
36 .x = 0, .y = 0,
37 .hidden = { .x = 0, .y = 0 }
40 .docking = {
41 .side = SIDE_NONE,
42 .pos = 0.0,
43 .border = 1,
44 .visible = TRUE,
45 .timeout = { .show = 10, .hide = 10, .id = 0},
46 .autohiding = FALSE
49 .enter_cb_id = 0,
50 .leave_cb_id = 0
53 #include "panel-int-mod.h"
55 /**
56 * Public API
59 PanelWindow * panelWindow_Alloc (void)
60 { return malloc (sizeof (PanelWindow)); }
62 void panelWindow_Init (PanelWindow * panel)
64 *panel = defaults;
66 GdkScreen * screen;
67 screen = gdk_screen_get_default ();
68 panel->scr.h = gdk_screen_get_height (screen);
69 panel->scr.w = gdk_screen_get_width (screen);
71 panel->win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
73 gtk_window_set_type_hint (GTK_WINDOW (panel->win), GDK_WINDOW_TYPE_HINT_DOCK);
74 gtk_window_set_decorated (GTK_WINDOW (panel->win), FALSE);
76 gtk_widget_set_events (panel->win, GDK_ALL_EVENTS_MASK);
77 gtk_window_set_accept_focus (GTK_WINDOW (panel->win), TRUE);
78 gtk_widget_set_can_focus (panel->win, TRUE);
80 set_Gravity (panel);
81 gtk_window_set_position (GTK_WINDOW (panel->win), GTK_WIN_POS_NONE);
83 /* Auto-hiding */
84 g_signal_connect (G_OBJECT (panel->win), "size-allocate", G_CALLBACK (on_resize), panel);
85 g_signal_connect (G_OBJECT (panel->win), "size-request", G_CALLBACK (on_size_request), panel);
87 panel->enter_cb_id = g_signal_connect (G_OBJECT (panel->win), "enter-notify-event", G_CALLBACK (on_enter), panel);
88 panel->leave_cb_id = g_signal_connect (G_OBJECT (panel->win), "leave-notify-event", G_CALLBACK (on_leave), panel);
91 void panelWindow_Side_Set (PanelWindow * panel, side_t side)
93 panel->docking.side = side;
94 update_pos (panel);
95 update_window_pos (panel);
98 void panelWindow_Pos_Set (PanelWindow * panel, double pos)
100 panel->docking.pos = pos;
101 update_pos (panel);
102 update_window_pos (panel);
105 void panelWindow_AH_Toggle (PanelWindow * panel, gboolean enabled)
107 if (panel->docking.autohiding == enabled) return;
108 panel->docking.autohiding = enabled;
110 if (enabled) hide (panel);
111 else show (panel);
114 void panelWindow_AH_ShowDuration_Set (PanelWindow * panel, double sec)
115 { panel->docking.timeout.show = 1 + sec * 1000; }
117 void panelWindow_AH_HideDuration_Set (PanelWindow * panel, double sec)
118 { panel->docking.timeout.hide = 1 + sec * 1000; }
120 void panelWindow_AH_Border_Set (PanelWindow * panel, guint thickness)
122 panel->docking.border = thickness;
123 update_pos (panel);
124 if (panel->docking.visible)
125 update_window_pos (panel);