Back to index

bamf  0.2.120
bamf-legacy-window-test.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2010 Canonical Ltd
00003  *
00004  * This program is free software: you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License version 3 as
00006  * published by the Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  * GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00015  *
00016  * Authored by: Jason Smith <jason.smith@canonical.com>
00017  *
00018  */
00019 
00020 #include "bamf-legacy-window-test.h"
00021 
00022 G_DEFINE_TYPE (BamfLegacyWindowTest, bamf_legacy_window_test, BAMF_TYPE_LEGACY_WINDOW);
00023 
00024 gint
00025 bamf_legacy_window_test_get_pid (BamfLegacyWindow *legacy_window)
00026 {
00027   BamfLegacyWindowTest *self;
00028 
00029   self = BAMF_LEGACY_WINDOW_TEST (legacy_window);
00030 
00031   return  self->pid;
00032 }
00033 
00034 guint32
00035 bamf_legacy_window_test_get_xid (BamfLegacyWindow *legacy_window)
00036 {
00037   BamfLegacyWindowTest *self;
00038 
00039   self = BAMF_LEGACY_WINDOW_TEST (legacy_window);
00040 
00041   return self->xid;
00042 }
00043 
00044 void
00045 bamf_legacy_window_test_set_attention (BamfLegacyWindowTest *self, gboolean val)
00046 {
00047   if (self->needs_attention == val)
00048     return;
00049 
00050   self->needs_attention = val;
00051 
00052   g_signal_emit_by_name (self, "state-changed");
00053 }
00054 
00055 gboolean
00056 bamf_legacy_window_test_needs_attention (BamfLegacyWindow *legacy_window)
00057 {
00058   BamfLegacyWindowTest *self;
00059 
00060   self = BAMF_LEGACY_WINDOW_TEST (legacy_window);
00061 
00062   return self->needs_attention;
00063 }
00064 
00065 void
00066 bamf_legacy_window_test_set_active (BamfLegacyWindowTest *self, gboolean val)
00067 {
00068   if (self->is_active == val)
00069     return;
00070 
00071   self->is_active = val;
00072 
00073   g_signal_emit_by_name (self, "state-changed");
00074 }
00075 
00076 gboolean
00077 bamf_legacy_window_test_is_active (BamfLegacyWindow *legacy_window)
00078 {
00079   BamfLegacyWindowTest *self;
00080 
00081   self = BAMF_LEGACY_WINDOW_TEST (legacy_window);
00082 
00083   return self->is_active;
00084 }
00085 
00086 void
00087 bamf_legacy_window_test_set_desktop (BamfLegacyWindowTest *self, gboolean val)
00088 {
00089   if (self->is_desktop == val)
00090     return;
00091 
00092   self->is_desktop = val;
00093 
00094   g_signal_emit_by_name (self, "state-changed");
00095 }
00096 
00097 gboolean
00098 bamf_legacy_window_test_is_desktop (BamfLegacyWindow *legacy_window)
00099 {
00100   BamfLegacyWindowTest *self;
00101 
00102   self = BAMF_LEGACY_WINDOW_TEST (legacy_window);
00103 
00104   return self->is_desktop;
00105 }
00106 
00107 void
00108 bamf_legacy_window_test_set_skip (BamfLegacyWindowTest *self, gboolean val)
00109 {
00110   if (self->is_skip == val)
00111     return;
00112 
00113   self->is_skip = val;
00114 
00115   g_signal_emit_by_name (self, "state-changed");
00116 }
00117 
00118 gboolean
00119 bamf_legacy_window_test_is_skip_tasklist (BamfLegacyWindow *legacy_window)
00120 {
00121   BamfLegacyWindowTest *self;
00122 
00123   self = BAMF_LEGACY_WINDOW_TEST (legacy_window);
00124 
00125   return self->is_skip;
00126 }
00127 
00128 void
00129 bamf_legacy_window_test_set_name (BamfLegacyWindowTest *self, char *val)
00130 {
00131   if (g_strcmp0 (self->name, val) == 0)
00132     return;
00133 
00134   self->name = val;
00135 
00136   g_signal_emit_by_name (self, "name-changed");
00137 }
00138 
00139 static const char *
00140 bamf_legacy_window_test_get_name (BamfLegacyWindow *legacy_window)
00141 {
00142   BamfLegacyWindowTest *self;
00143 
00144   self = BAMF_LEGACY_WINDOW_TEST (legacy_window);
00145 
00146   return  self->name;
00147 }
00148 
00149 static const char *
00150 bamf_legacy_window_test_get_class (BamfLegacyWindow *legacy_window)
00151 {
00152   BamfLegacyWindowTest *self;
00153 
00154   self = BAMF_LEGACY_WINDOW_TEST (legacy_window);
00155 
00156   return  self->klass;
00157 }
00158 
00159 char *
00160 bamf_legacy_window_test_get_exec_string (BamfLegacyWindow *legacy_window)
00161 {
00162   BamfLegacyWindowTest *self;
00163 
00164   self = BAMF_LEGACY_WINDOW_TEST (legacy_window);
00165 
00166   return self->exec;
00167 }
00168 
00169 char *
00170 bamf_legacy_window_test_get_app_id (BamfLegacyWindow *legacy_window)
00171 {
00172   BamfLegacyWindowTest *self;
00173   g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (legacy_window), NULL);
00174 
00175   self = BAMF_LEGACY_WINDOW_TEST (legacy_window);
00176 
00177   return self->application_id;
00178 }
00179 
00180 char *
00181 bamf_legacy_window_test_get_unique_bus_name (BamfLegacyWindow *legacy_window)
00182 {
00183   BamfLegacyWindowTest *self;
00184   g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (legacy_window), NULL);
00185 
00186   self = BAMF_LEGACY_WINDOW_TEST (legacy_window);
00187 
00188   return self->unique_bus_name;
00189 }
00190 
00191 char *
00192 bamf_legacy_window_test_get_menu_object_path (BamfLegacyWindow *legacy_window)
00193 {
00194   BamfLegacyWindowTest *self;
00195   g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (legacy_window), NULL);
00196 
00197   self = BAMF_LEGACY_WINDOW_TEST (legacy_window);
00198 
00199   return self->dbus_menu_object_path;
00200 }
00201 
00202 void
00203 bamf_legacy_window_test_get_geometry (BamfLegacyWindow *legacy_window,
00204                                       gint *x, gint *y,
00205                                       gint *width, gint *height)
00206 {
00207   BamfLegacyWindowTest *self;
00208   g_return_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (legacy_window));
00209 
00210   self = BAMF_LEGACY_WINDOW_TEST (legacy_window);
00211 
00212   *x = self->geometry.x;
00213   *y = self->geometry.y;
00214   *width = self->geometry.width;
00215   *height = self->geometry.height;
00216 }
00217 
00218 BamfWindowMaximizationType
00219 bamf_legacy_window_test_maximized (BamfLegacyWindow *legacy_window)
00220 {
00221   BamfLegacyWindowTest *self;
00222   g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (legacy_window), BAMF_WINDOW_FLOATING);
00223 
00224   self = BAMF_LEGACY_WINDOW_TEST (legacy_window);
00225 
00226   return self->maximized;
00227 }
00228 
00229 void
00230 bamf_legacy_window_test_close (BamfLegacyWindowTest *self)
00231 {
00232   g_signal_emit_by_name (self, "closed");
00233 }
00234 
00235 void
00236 bamf_legacy_window_test_set_geometry (BamfLegacyWindowTest *self, int x, int y,
00237                                  int width, int height)
00238 {
00239   g_return_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (self));
00240 
00241   self->geometry.x = x;
00242   self->geometry.y = y;
00243   self->geometry.width = width;
00244   self->geometry.height = height;
00245   g_signal_emit_by_name (self, BAMF_LEGACY_WINDOW_SIGNAL_GEOMETRY_CHANGED);
00246 }
00247 
00248 void
00249 bamf_legacy_window_test_set_maximized (BamfLegacyWindowTest *self,
00250                                   BamfWindowMaximizationType maximized)
00251 {
00252   g_return_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (self));
00253 
00254   self->maximized = maximized;
00255   g_signal_emit_by_name (self, BAMF_LEGACY_WINDOW_SIGNAL_GEOMETRY_CHANGED);
00256   g_signal_emit_by_name (self, BAMF_LEGACY_WINDOW_SIGNAL_STATE_CHANGED);
00257 }
00258 
00259 void
00260 bamf_legacy_window_test_set_application_id (BamfLegacyWindowTest *self, const char *id)
00261 {
00262   g_return_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (self));
00263 
00264   self->application_id = g_strdup (id);
00265 }
00266 
00267 void
00268 bamf_legacy_window_test_set_unique_bus_name (BamfLegacyWindowTest *self, const char *bus_name)
00269 {
00270   g_return_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (self));
00271 
00272   self->unique_bus_name = g_strdup (bus_name);
00273 }
00274 
00275 void
00276 bamf_legacy_window_test_set_dbus_menu_object_path (BamfLegacyWindowTest *self, const char *object_path)
00277 {
00278   g_return_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (self));
00279 
00280   self->dbus_menu_object_path = g_strdup (object_path);
00281 }
00282 
00283 void
00284 bamf_legacy_window_test_dispose (GObject *object)
00285 {
00286   G_OBJECT_CLASS (bamf_legacy_window_test_parent_class)->dispose (object);
00287 }
00288 
00289 void
00290 bamf_legacy_window_test_class_init (BamfLegacyWindowTestClass *klass)
00291 {
00292   BamfLegacyWindowClass *win_class = BAMF_LEGACY_WINDOW_CLASS (klass);
00293   GObjectClass *obj_class = G_OBJECT_CLASS (klass);
00294 
00295   obj_class->dispose          = bamf_legacy_window_test_dispose;
00296   win_class->get_name         = bamf_legacy_window_test_get_name;
00297   win_class->get_class_name   = bamf_legacy_window_test_get_class;
00298   win_class->get_exec_string  = bamf_legacy_window_test_get_exec_string;
00299   win_class->get_xid          = bamf_legacy_window_test_get_xid;
00300   win_class->get_pid          = bamf_legacy_window_test_get_pid;
00301   win_class->needs_attention  = bamf_legacy_window_test_needs_attention;
00302   win_class->is_skip_tasklist = bamf_legacy_window_test_is_skip_tasklist;
00303   win_class->is_desktop       = bamf_legacy_window_test_is_desktop;
00304   win_class->is_active        = bamf_legacy_window_test_is_active;
00305   win_class->get_app_id       = bamf_legacy_window_test_get_app_id;
00306   win_class->get_unique_bus_name = bamf_legacy_window_test_get_unique_bus_name;
00307   win_class->get_menu_object_path = bamf_legacy_window_test_get_menu_object_path;
00308   win_class->get_geometry     = bamf_legacy_window_test_get_geometry;
00309   win_class->maximized        = bamf_legacy_window_test_maximized;
00310 }
00311 
00312 
00313 void
00314 bamf_legacy_window_test_init (BamfLegacyWindowTest *self)
00315 {
00316   self->pid = g_random_int_range (1, 100000);
00317   self->maximized = BAMF_WINDOW_FLOATING;
00318 }
00319 
00320 
00321 BamfLegacyWindowTest *
00322 bamf_legacy_window_test_new (guint32 xid, gchar *name, gchar *klass, gchar *exec)
00323 {
00324   BamfLegacyWindowTest *self;
00325 
00326   self = g_object_new (BAMF_TYPE_LEGACY_WINDOW_TEST, NULL);
00327   self->xid = xid;
00328   self->name = g_strdup (name);
00329   self->klass = g_strdup (klass);
00330   self->exec = g_strdup (exec);
00331 
00332   return self;
00333 }