annotate finch/libgnt/gntwindow.c @ 28796:5d8867f11f0d

If we're sending a file, and libpurple tells us to cancel it, then just set the slpcall->wasted flag. Upper level code should take care of destroying it without getting confused. Refs #6523.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Mon, 14 Dec 2009 05:42:16 +0000
parents 253e5d3988ca
children 88d889b54df4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17928
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 15817
diff changeset
1 /**
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 15817
diff changeset
2 * GNT - The GLib Ncurses Toolkit
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 15817
diff changeset
3 *
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 15817
diff changeset
4 * GNT is the legal property of its developers, whose names are too numerous
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 15817
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 15817
diff changeset
6 * source distribution.
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 15817
diff changeset
7 *
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 15817
diff changeset
8 * This library is free software; you can redistribute it and/or modify
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 15817
diff changeset
9 * it under the terms of the GNU General Public License as published by
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 15817
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 15817
diff changeset
11 * (at your option) any later version.
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 15817
diff changeset
12 *
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 15817
diff changeset
13 * This program is distributed in the hope that it will be useful,
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 15817
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 15817
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 15817
diff changeset
16 * GNU General Public License for more details.
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 15817
diff changeset
17 *
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 15817
diff changeset
18 * You should have received a copy of the GNU General Public License
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 15817
diff changeset
19 * along with this program; if not, write to the Free Software
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18069
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
17928
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 15817
diff changeset
21 */
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 15817
diff changeset
22
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 #include "gntstyle.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 #include "gntwindow.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include <string.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27
21212
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
28 struct _GntWindowPriv
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
29 {
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
30 GHashTable *accels; /* key => menuitem-id */
21454
d78e440584e0 Add maximize flags for windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21212
diff changeset
31 GntWindowFlags flags;
21212
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
32 };
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
33
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 enum
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 {
17707
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
36 SIG_WORKSPACE_HIDE,
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
37 SIG_WORKSPACE_SHOW,
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
38 SIGS,
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 };
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40
17707
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
41 static guint signals[SIGS] = { 0 };
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
42
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 static GntBoxClass *parent_class = NULL;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 static void (*org_destroy)(GntWidget *widget);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 static gboolean
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 show_menu(GntBindable *bind, GList *null)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 GntWindow *win = GNT_WINDOW(bind);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 if (win->menu) {
24921
253e5d3988ca Show the submenu for the toplevel menu without requiring a keypress from the user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21681
diff changeset
52 GntMenu *menu = win->menu;
253e5d3988ca Show the submenu for the toplevel menu without requiring a keypress from the user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21681
diff changeset
53
253e5d3988ca Show the submenu for the toplevel menu without requiring a keypress from the user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21681
diff changeset
54 gnt_screen_menu_show(menu);
253e5d3988ca Show the submenu for the toplevel menu without requiring a keypress from the user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21681
diff changeset
55 if (menu->type == GNT_MENU_TOPLEVEL) {
253e5d3988ca Show the submenu for the toplevel menu without requiring a keypress from the user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21681
diff changeset
56 GntMenuItem *item;
253e5d3988ca Show the submenu for the toplevel menu without requiring a keypress from the user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21681
diff changeset
57 item = g_list_nth_data(menu->list, menu->selected);
253e5d3988ca Show the submenu for the toplevel menu without requiring a keypress from the user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21681
diff changeset
58 if (item && gnt_menuitem_get_submenu(item)) {
253e5d3988ca Show the submenu for the toplevel menu without requiring a keypress from the user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21681
diff changeset
59 gnt_widget_activate(GNT_WIDGET(menu));
253e5d3988ca Show the submenu for the toplevel menu without requiring a keypress from the user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21681
diff changeset
60 }
253e5d3988ca Show the submenu for the toplevel menu without requiring a keypress from the user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21681
diff changeset
61 }
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 return FALSE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 gnt_window_destroy(GntWidget *widget)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 GntWindow *window = GNT_WINDOW(widget);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 if (window->menu)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 gnt_widget_destroy(GNT_WIDGET(window->menu));
21212
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
73 if (window->priv) {
21681
261fd722db1f Fix for a glib assertion
Richard Nelson <wabz@pidgin.im>
parents: 21454
diff changeset
74 if (window->priv->accels)
261fd722db1f Fix for a glib assertion
Richard Nelson <wabz@pidgin.im>
parents: 21454
diff changeset
75 g_hash_table_destroy(window->priv->accels);
21212
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
76 g_free(window->priv);
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
77 }
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 org_destroy(widget);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 gnt_window_class_init(GntWindowClass *klass)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 GntWidgetClass *wid_class = GNT_WIDGET_CLASS(klass);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 parent_class = GNT_BOX_CLASS(klass);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 org_destroy = wid_class->destroy;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 wid_class->destroy = gnt_window_destroy;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90
17707
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
91 signals[SIG_WORKSPACE_HIDE] =
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
92 g_signal_new("workspace-hidden",
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
93 G_TYPE_FROM_CLASS(klass),
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
94 G_SIGNAL_RUN_LAST,
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
95 0,
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
96 NULL, NULL,
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
97 g_cclosure_marshal_VOID__VOID,
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
98 G_TYPE_NONE, 0);
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
99
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
100 signals[SIG_WORKSPACE_SHOW] =
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
101 g_signal_new("workspace-shown",
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
102 G_TYPE_FROM_CLASS(klass),
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
103 G_SIGNAL_RUN_LAST,
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
104 0,
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
105 NULL, NULL,
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
106 g_cclosure_marshal_VOID__VOID,
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
107 G_TYPE_NONE, 0);
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
108
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 gnt_bindable_class_register_action(bindable, "show-menu", show_menu,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 GNT_KEY_CTRL_O, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 gnt_bindable_register_binding(bindable, "show-menu", GNT_KEY_F10, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), bindable);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 GNTDEBUG;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 gnt_window_init(GTypeInstance *instance, gpointer class)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 GntWidget *widget = GNT_WIDGET(instance);
21212
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
121 GntWindow *win = GNT_WINDOW(widget);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_CAN_TAKE_FOCUS);
21212
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
124 win->priv = g_new0(GntWindowPriv, 1);
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
125 win->priv->accels = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 GNTDEBUG;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 /******************************************************************************
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 * GntWindow API
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 *****************************************************************************/
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 GType
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 gnt_window_get_gtype(void)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 static GType type = 0;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 if(type == 0)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 static const GTypeInfo info = {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 sizeof(GntWindowClass),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 NULL, /* base_init */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 NULL, /* base_finalize */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 (GClassInitFunc)gnt_window_class_init,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 NULL, /* class_finalize */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 NULL, /* class_data */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 sizeof(GntWindow),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 0, /* n_preallocs */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 gnt_window_init, /* instance_init */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 NULL /* value_table */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 };
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 type = g_type_register_static(GNT_TYPE_BOX,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 "GntWindow",
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 &info, 0);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 return type;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 GntWidget *gnt_window_new()
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 GntWidget *widget = g_object_new(GNT_TYPE_WINDOW, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 return widget;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 GntWidget *gnt_window_box_new(gboolean homo, gboolean vert)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 GntWidget *wid = gnt_window_new();
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 GntBox *box = GNT_BOX(wid);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 box->homogeneous = homo;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 box->vertical = vert;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 box->alignment = vert ? GNT_ALIGN_LEFT : GNT_ALIGN_MID;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 return wid;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178
17707
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
179 void
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
180 gnt_window_workspace_hiding(GntWindow *window)
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
181 {
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
182 if (window->menu)
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
183 gnt_widget_hide(GNT_WIDGET(window->menu));
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
184 g_signal_emit(window, signals[SIG_WORKSPACE_HIDE], 0);
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
185 }
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
186
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
187 void
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
188 gnt_window_workspace_showing(GntWindow *window)
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
189 {
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
190 g_signal_emit(window, signals[SIG_WORKSPACE_SHOW], 0);
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
191 }
3c3fc1432a01 Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents: 15817
diff changeset
192
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 void gnt_window_set_menu(GntWindow *window, GntMenu *menu)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 /* If a menu already existed, then destroy that first. */
21212
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
196 const char *name = gnt_widget_get_name(GNT_WIDGET(window));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 if (window->menu)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 gnt_widget_destroy(GNT_WIDGET(window->menu));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 window->menu = menu;
21212
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
200 if (name && window->priv) {
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
201 if (!gnt_style_read_menu_accels(name, window->priv->accels)) {
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
202 g_hash_table_destroy(window->priv->accels);
21454
d78e440584e0 Add maximize flags for windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21212
diff changeset
203 window->priv->accels = NULL;
21212
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
204 }
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
205 }
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207
21212
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
208 const char * gnt_window_get_accel_item(GntWindow *window, const char *key)
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
209 {
21454
d78e440584e0 Add maximize flags for windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21212
diff changeset
210 if (window->priv->accels)
21212
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
211 return g_hash_table_lookup(window->priv->accels, key);
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
212 return NULL;
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
213 }
b65f1bff6412 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
214
21454
d78e440584e0 Add maximize flags for windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21212
diff changeset
215 void gnt_window_set_maximize(GntWindow *window, GntWindowFlags maximize)
d78e440584e0 Add maximize flags for windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21212
diff changeset
216 {
d78e440584e0 Add maximize flags for windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21212
diff changeset
217 if (maximize & GNT_WINDOW_MAXIMIZE_X)
d78e440584e0 Add maximize flags for windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21212
diff changeset
218 window->priv->flags |= GNT_WINDOW_MAXIMIZE_X;
d78e440584e0 Add maximize flags for windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21212
diff changeset
219 else
d78e440584e0 Add maximize flags for windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21212
diff changeset
220 window->priv->flags &= ~GNT_WINDOW_MAXIMIZE_X;
d78e440584e0 Add maximize flags for windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21212
diff changeset
221
d78e440584e0 Add maximize flags for windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21212
diff changeset
222 if (maximize & GNT_WINDOW_MAXIMIZE_Y)
d78e440584e0 Add maximize flags for windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21212
diff changeset
223 window->priv->flags |= GNT_WINDOW_MAXIMIZE_Y;
d78e440584e0 Add maximize flags for windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21212
diff changeset
224 else
d78e440584e0 Add maximize flags for windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21212
diff changeset
225 window->priv->flags &= ~GNT_WINDOW_MAXIMIZE_Y;
d78e440584e0 Add maximize flags for windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21212
diff changeset
226 }
d78e440584e0 Add maximize flags for windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21212
diff changeset
227
d78e440584e0 Add maximize flags for windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21212
diff changeset
228 GntWindowFlags gnt_window_get_maximize(GntWindow *window)
d78e440584e0 Add maximize flags for windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21212
diff changeset
229 {
d78e440584e0 Add maximize flags for windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21212
diff changeset
230 return (window->priv->flags & (GNT_WINDOW_MAXIMIZE_X | GNT_WINDOW_MAXIMIZE_Y));
d78e440584e0 Add maximize flags for windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21212
diff changeset
231 }
d78e440584e0 Add maximize flags for windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21212
diff changeset
232