📄 gemapplication.c.svn-base
字号:
(guint32)window); entry->under = window; tmp->above = entry->window; } } } gem_application_list_windows(app); return;} static voidgem_application_window_hide_cb (GtkWidget *widget, gpointer user_data){ GemApplication * app = gem_application_get_instance(); GemApplicationPriv *priv = GEM_APPLICATION_GET_PRIVATE(app); GemAppWinEntry * entry = (GemAppWinEntry *)user_data; if (TRUE) { GSList *iter = NULL; for (iter = priv->windows; iter; iter = g_slist_next(iter)) { GemAppWinEntry * tmp = (GemAppWinEntry *)iter->data; GtkWidget * window = tmp->window; if (entry->under == tmp->window) { gtk_window_present(GTK_WINDOW(entry->under)); entry->above = NULL; entry->under = NULL; tmp->above = NULL; } } } gem_application_list_windows(app); return;} static voidgem_application_list_windows (GemApplication * app){ GemApplicationPriv *priv = GEM_APPLICATION_GET_PRIVATE(app); GSList *iter; gint i; gint count; count = g_slist_length(priv->windows); g_print("%s(): list (0x%0x), %d elements\n", __FUNCTION__, (guint32)priv->main_window, count); for (i = 0, iter = priv->windows; iter; i++, iter = g_slist_next(iter)) { GemAppWinEntry *entry = (GemAppWinEntry *)iter->data; g_print("%s(): %c- entry [0x%08x]\n", __FUNCTION__, (i == count - 1) ? '`' : '|', (guint32)entry); g_print("%s(): %c |- under : [0x%08x]\n", __FUNCTION__, (i == count - 1) ? ' ' : '|', (guint32)entry->under); g_print("%s(): %c |- window : [0x%08x]\n", __FUNCTION__, (i == count - 1) ? ' ' : '|', (guint32)entry->window); g_print("%s(): %c `- above : [0x%08x]\n", __FUNCTION__, (i == count - 1) ? ' ' : '|', (guint32)entry->above); } g_print("\n"); return;}/** * gem_application_add_window: * * @app: #GemApplication instance for current process * @widget: a #GtkWidget to add in current process windows list. * All #GtkWidget will be free automatically when * cureent #GemApplication instance is destroyed. * * Return value: Returns the #GemApplication for the current process. * The object is created on the first call. **/void gem_application_add_window (GemApplication *app, GtkWidget *widget){ GemApplicationPriv *priv = GEM_APPLICATION_GET_PRIVATE(app); GSList *iter = NULL; g_return_if_fail(app); g_return_if_fail(widget); g_return_if_fail(GTK_WIDGET_TOPLEVEL(widget)); for (iter = priv->windows; iter; iter = g_slist_next(iter)) { GemAppWinEntry * entry = (GemAppWinEntry *)iter->data; if (entry->window == widget) { return; } } if (TRUE) { GemAppWinEntry * entry = NULL; entry = g_new0(GemAppWinEntry, 1); g_return_if_fail(entry); entry->window = widget; entry->under = NULL; entry->above = NULL; priv->windows = g_slist_append(priv->windows, (gpointer)entry);/* g_print("%s(): add window 0x%08x, entry 0x%08x\n", __FUNCTION__, (guint32)widget, (guint32)entry);*/ g_signal_connect(G_OBJECT(widget), "destroy", G_CALLBACK(gem_application_window_destroy_cb), (gpointer)app); g_signal_connect(G_OBJECT(widget), "show", G_CALLBACK(gem_application_window_show_cb), (gpointer)entry); g_signal_connect(G_OBJECT(widget), "hide", G_CALLBACK(gem_application_window_hide_cb), (gpointer)entry); } return;}void gem_application_remove_window (GemApplication *app, GtkWidget *widget){ GemApplicationPriv *priv = GEM_APPLICATION_GET_PRIVATE(app); GemAppWinEntry * entry = NULL; GSList *iter = NULL; g_return_if_fail(app); g_return_if_fail(widget);/* g_print("%s(): remove window 0x%08x\n", __FUNCTION__, (guint32)widget);*/ for (iter = priv->windows; iter; iter = g_slist_next(iter)) { GemAppWinEntry * tmp = (GemAppWinEntry *)iter->data;/* g_print("%s(): entry 0x%08x, window 0x%08x\n", __FUNCTION__, (guint32)tmp, (guint32)tmp->window);*/ if (tmp->window == widget) { entry = tmp; break; } } if (entry) { priv->windows = g_slist_remove(priv->windows, (gconstpointer)entry); g_object_disconnect(G_OBJECT(widget), "any_signal::destroy", G_CALLBACK(gem_application_window_destroy_cb), (gpointer)app, NULL); g_object_disconnect(G_OBJECT(widget), "any_signal::show", G_CALLBACK(gem_application_window_show_cb), (gpointer)entry, NULL); g_object_disconnect(G_OBJECT(widget), "any_signal::hide", G_CALLBACK(gem_application_window_hide_cb), (gpointer)entry, NULL); g_free(entry); } return;}voidgem_application_set_main_window (GemApplication *app, GtkWidget *widget){ GemApplicationPriv *priv = GEM_APPLICATION_GET_PRIVATE(app); if (priv->main_window == widget) { return; } /* * the main should be add to list as other windows, * but its difference from others is that it will * be automaitcally showed when gem_application_run() * is called, and when it is destroyed the main loop * will be terminated. */ gem_application_add_window(app, widget); priv->main_window = widget; return;}voidgem_application_run (GemApplication * app){ GemApplicationPriv *priv = GEM_APPLICATION_GET_PRIVATE(app); /* * if main window is set, show it on screen */ if (priv->main_window) { gtk_widget_show_all(priv->main_window); } gtk_main(); return;}voidgem_application_quit (GemApplication *app){ /* * emit a quit signal */ g_signal_emit(G_OBJECT(app), application_signals[APP_QUIT], 0); /* * quit from main loop */ gtk_main_quit(); return;}voidgem_application_destroy (GemApplication *app){ g_object_unref(G_OBJECT(app)); gem_finalize(); return;}iac_context_t *gem_application_get_iac_context (GemApplication *app){ GemApplicationPriv *priv = GEM_APPLICATION_GET_PRIVATE(app); g_return_if_fail(app); if (priv->iac_context == NULL) { priv->iac_context = iac_initialize(); } return priv->iac_context;}/*vi:ts=2:nowrap:ai:expandtab */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -