00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00030 #include <string.h>
00031 #include "interface.h"
00032 #include "window.h"
00033 #include "perr.h"
00034
00035 struct DuiGtkTop_s
00036 {
00037 GList *window_list;
00038 };
00039
00040
00041
00042 DuiGtkTop *
00043 dui_gtk_top_new (void)
00044 {
00045 DuiGtkTop *top;
00046
00047 top = g_new0 (DuiGtkTop, 1);
00048 top->window_list = NULL;
00049 return top;
00050 }
00051
00052 void
00053 dui_gtk_top_destroy (DuiGtkTop *top)
00054 {
00055 GList *node;
00056 if (!top) return;
00057 for (node=top->window_list; node; node=node->next)
00058 {
00059 DuiWindow *win = node->data;
00060 dui_window_destroy (win);
00061 }
00062 g_list_free (top->window_list);
00063 g_free (top);
00064 }
00065
00066
00067
00068 void
00069 dui_gtk_top_add_window (DuiGtkTop *top, DuiWindow *win)
00070 {
00071 if (!win) return;
00072 top->window_list = g_list_append (top->window_list, win);
00073 }
00074
00075
00076
00077 DuiWindow *
00078 dui_gtk_top_find_window_by_name (DuiGtkTop *top, const char * name)
00079 {
00080 GList *node;
00081
00082 if (!name) return NULL;
00083
00084 for (node=top->window_list; node; node=node->next)
00085 {
00086 DuiWindow *win = node->data;
00087 const char *winname = dui_window_get_name (win);
00088 if (winname && !strcmp(winname, name))
00089 {
00090 return win;
00091 }
00092 }
00093 return NULL;
00094 }
00095
00096
00097
00098 static void
00099 dui_gtk_top_realize (gpointer self, gboolean fatal_if_no_main)
00100 {
00101 DuiGtkTop *top = self;
00102 GList *node;
00103 gboolean found_app_window = 0;
00104
00105 for (node=top->window_list; node; node=node->next)
00106 {
00107 DuiWindow *win = node->data;
00108 dui_window_resolve (win);
00109 }
00110
00111 for (node=top->window_list; node; node=node->next)
00112 {
00113 DuiWindow *win = node->data;
00114 gboolean is_app_window = dui_window_is_app_main_window(win);
00115 if (is_app_window)
00116 {
00117 dui_window_realize (win);
00118 found_app_window = 1;
00119 }
00120 }
00121
00122
00123
00124
00125
00126 if (fatal_if_no_main && 0 == found_app_window)
00127 {
00128 FATAL ("could not find an application main window!");
00129 }
00130 }
00131
00132
00133
00134 DuiInterfacePlugin *
00135 dui_gtk_top_plugin_new (DuiGtkTop *top)
00136 {
00137 DuiInterfacePlugin *dip;
00138
00139 dip = g_new0 (DuiInterfacePlugin, 1);
00140 dip->plugin_name = "dui_gtk_top";
00141 dip->self = top;
00142 dip->realize = dui_gtk_top_realize;
00143
00144 return dip;
00145 }
00146
00147