source: trunk/third/bonobo/bonobo/bonobo-desktop-window.c @ 16750

Revision 16750, 4.4 KB checked in by ghudson, 23 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r16749, which included commits to RCS files with non-trunk default branches.
Line 
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/*
3 * Bonobo Desktop Window Control implementation.
4 * Enables applications to export their geometry control through CORBA.
5 *
6 * Author:
7 *   Miguel de Icaza (miguel@kernel.org)
8 *
9 * Copyright 1999 Helix Code, Inc.
10 */
11#include <config.h>
12#include <gtk/gtkplug.h>
13#include <bonobo/bonobo-exception.h>
14#include <bonobo/bonobo-main.h>
15#include <bonobo/bonobo-desktop-window.h>
16#include <gdk/gdkprivate.h>
17#include <gdk/gdkx.h>
18
19#define PARENT_TYPE BONOBO_X_OBJECT_TYPE
20
21/**
22 * bonobo_desktop_window_construct:
23 * @desk_win: The BonoboDesktopWindow object to be initialized.
24 * @toplevel: Window we will have control over.
25 *
26 * Returns: the intialized BonoboDesktopWindow object.
27 */
28BonoboDesktopWindow *
29bonobo_desktop_window_construct (BonoboDesktopWindow *desk_win,
30                                 GtkWindow           *toplevel)
31{
32        g_return_val_if_fail (GTK_IS_WINDOW (toplevel), NULL);
33        g_return_val_if_fail (BONOBO_IS_DESKTOP_WINDOW (desk_win), NULL);
34       
35        desk_win->window = toplevel;
36
37        return desk_win;
38}
39
40/**
41 * bonobo_desktop_window_new:
42 * @toplevel: The toplevel Gtk window to control
43 * container process.
44 *
45 * Returns: a new BonoboDesktopWindow
46 */
47BonoboDesktopWindow *
48bonobo_desktop_window_new (GtkWindow *toplevel)
49{
50        BonoboDesktopWindow *desktop_window;
51       
52        g_return_val_if_fail (GTK_IS_WINDOW (toplevel), NULL);
53
54        desktop_window = gtk_type_new (bonobo_desktop_window_get_type ());
55       
56        return bonobo_desktop_window_construct (desktop_window, toplevel);
57}
58
59static CORBA_char *
60impl_Desktop_Window_get_title (PortableServer_Servant servant, CORBA_Environment * ev)
61{
62        BonoboDesktopWindow *desk_win = BONOBO_DESKTOP_WINDOW (bonobo_object_from_servant (servant));
63
64        return CORBA_string_dup (desk_win->window->title);
65}
66
67static void
68impl_Desktop_Window_set_title (PortableServer_Servant servant,
69                               const CORBA_char *value,
70                               CORBA_Environment * ev)
71{
72        BonoboDesktopWindow *desk_win = BONOBO_DESKTOP_WINDOW (bonobo_object_from_servant (servant));
73
74        gtk_window_set_title (desk_win->window, value);
75}
76
77static Bonobo_Desktop_Window_Geometry
78impl_Desktop_Window_getGeometry (PortableServer_Servant servant,
79                                 CORBA_Environment * ev)
80{
81        BonoboDesktopWindow *desk_win = BONOBO_DESKTOP_WINDOW (bonobo_object_from_servant (servant));
82        Bonobo_Desktop_Window_Geometry geo;
83        gint x, y;
84       
85        gdk_window_get_origin (GTK_WIDGET (desk_win->window)->window, &x, &y);
86        geo.x = x;
87        geo.y = y;
88        geo.width = GTK_WIDGET (desk_win->window)->allocation.width;
89        geo.height = GTK_WIDGET (desk_win->window)->allocation.height;
90
91        return geo;
92}
93
94static void
95impl_Desktop_Window_setGeometry (PortableServer_Servant               servant,
96                                 const Bonobo_Desktop_Window_Geometry *geo,
97                                 CORBA_Environment                   *ev)
98{
99        BonoboDesktopWindow *desk_win = BONOBO_DESKTOP_WINDOW (bonobo_object_from_servant (servant));
100
101        gtk_widget_set_uposition (GTK_WIDGET (desk_win->window), geo->x, geo->y);
102        gtk_widget_set_usize (GTK_WIDGET (desk_win->window), geo->width, geo->height);
103}
104
105static CORBA_unsigned_long
106impl_Desktop_Window_getWindowId (PortableServer_Servant servant, CORBA_Environment * ev)
107{
108        BonoboDesktopWindow *desk_win = BONOBO_DESKTOP_WINDOW (bonobo_object_from_servant (servant));
109
110        return GDK_WINDOW_XWINDOW (GTK_WIDGET (desk_win->window)->window);
111}
112
113static void
114bonobo_desktop_window_class_init (BonoboDesktopWindowClass *klass)
115{
116        POA_Bonobo_Desktop_Window__epv *epv = &klass->epv;
117
118        epv->_get_title = impl_Desktop_Window_get_title;
119        epv->_set_title = impl_Desktop_Window_set_title;
120        epv->getGeometry = impl_Desktop_Window_getGeometry;
121        epv->setGeometry = impl_Desktop_Window_setGeometry;
122        epv->getWindowId = impl_Desktop_Window_getWindowId;
123}
124
125static void
126bonobo_desktop_window_init (GtkObject *object)
127{
128        /* nothing to do */
129}
130
131BONOBO_X_TYPE_FUNC_FULL (BonoboDesktopWindow,
132                           Bonobo_Desktop_Window,
133                           PARENT_TYPE,
134                           bonobo_desktop_window);
135
136/**
137 * bonobo_desktop_window_control:
138 * @object: Object to be aggregated.
139 * @win: Window to be controled.
140 *
141 * Attaches a Bonobo::Desktop::Window corba handler to a Bonobo
142 * object controlling the window @win. 
143 */
144void
145bonobo_desktop_window_control (BonoboObject *object, GtkWindow *win)
146{
147        BonoboObject *win_control_object;
148       
149        g_return_if_fail (object != NULL);
150        g_return_if_fail (win != NULL);
151        g_return_if_fail (BONOBO_IS_OBJECT (object));
152        g_return_if_fail (GTK_IS_WINDOW (win));
153
154        win_control_object = BONOBO_OBJECT (bonobo_desktop_window_new (win));
155        bonobo_object_add_interface (object, win_control_object);
156}
Note: See TracBrowser for help on using the repository browser.