GTK+2 panel 

GTK+2 panel Git Source Tree

Root/callbacks.c

1#include "config.h"
2#include "callbacks.h"
3#include "netwm.h"
4
5#define WNCK_I_KNOW_THIS_IS_UNSTABLE 1
6#include <libwnck/libwnck.h>
7
8#define PANEL_HEIGHT 30
9
10
11void
12gp_init (void)
13{
14}
15
16void
17gp_logout (void)
18{
19 GtkWidget *dialog;
20 GtkResponseType response;
21
22 dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
23 GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
24 "Are you sure you want to quit?");
25 gtk_window_set_title (GTK_WINDOW (dialog), PACKAGE_STRING);
26 gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
27 response = gtk_dialog_run (GTK_DIALOG (dialog));
28 gtk_widget_destroy (dialog);
29
30 if (response == GTK_RESPONSE_YES)
31 gtk_main_quit ();
32}
33
34void
35gp_showdesktop_toggled (GtkToggleButton *toggler)
36{
37 WnckScreen *screen;
38 gboolean to_hide;
39
40 g_return_if_fail (GTK_IS_WIDGET (toggler));
41
42 screen = wnck_screen_get_default ();
43 wnck_screen_force_update (screen);
44 g_object_get (toggler, "active", &to_hide, NULL);
45
46 /* TODO: make a per-desktop flag (and update the toggle button state) */
47 wnck_screen_toggle_showing_desktop (screen, to_hide);
48}
49
50void
51gp_spawn (GtkWidget *widget)
52{
53 const gchar *application;
54 GError *error;
55
56 g_return_if_fail (GTK_IS_WIDGET (widget));
57
58 application = gtk_widget_get_name (widget);
59 g_return_if_fail (application != NULL);
60
61 error = NULL;
62 if (!g_spawn_command_line_async (application, &error))
63 {
64 GtkWidget *dialog;
65 dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
66 GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE,
67 "Unable to spawn '%s':\n%s",
68 application, error->message);
69 gtk_window_set_title (GTK_WINDOW (dialog), PACKAGE_STRING);
70 gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
71 gtk_dialog_run (GTK_DIALOG (dialog));
72 gtk_widget_destroy (dialog);
73 }
74}
75
76void
77_gp_panel_realize (GtkWidget *widget)
78{
79 GdkGeometry geometry;
80 Window window;
81 gint32 data[] = { 0, 0, 0, 0 };
82
83 g_return_if_fail (GTK_IS_WINDOW (widget));
84
85 gtk_window_move (GTK_WINDOW (widget), 0, 0);
86
87 geometry.min_width = geometry.max_width = geometry.base_width = gdk_screen_width ();
88 geometry.min_height = geometry.max_height = geometry.base_height = PANEL_HEIGHT;
89 gtk_window_set_geometry_hints (GTK_WINDOW (widget), widget, &geometry,
90 GDK_HINT_MIN_SIZE|GDK_HINT_MAX_SIZE|GDK_HINT_BASE_SIZE);
91 gtk_window_set_resizable (GTK_WINDOW (widget), FALSE);
92
93 window = GDK_WINDOW_XID (widget->window);
94 data[2] = PANEL_HEIGHT;
95 gpwm_window_change_property32 (window, "_NET_WM_STRUT", XA_CARDINAL, data, G_N_ELEMENTS (data));
96}

Archive Download this file

Branches

Tags