JNIEXPORT void JNICALL Java_org_gnome_gtk_GtkWindow_gtk_1window_1set_1icon_1list ( JNIEnv* env, jclass cls, jlong _self, jlongArray _list ) { GtkWindow* self; GList* list; // convert parameter self self = (GtkWindow*) _self; // convert parameter list list = (GList*) bindings_java_convert_jarray_to_glist(env, _list); if (list == NULL) { return; // Java Exception already thrown } // call function gtk_window_set_icon_list(self, list); // cleanup parameter self // cleanup parameter list g_list_free(list); }
/** * A callback for when a conversation is being closed * * This is only used to display help, hide conversation menu items, and reset * the window title when the last conversation in the Buddy List window is * being closed. * * @param[in] conv The conversation on its way out the door **/ static void deleting_conversation_cb(PurpleConversation *conv) { PidginBuddyList *gtkblist; /*< The Buddy List associated with conv */ PidginWindow *gtkconvwin; /*< The conversation window that owns conv */ if (conv == NULL) return; gtkconvwin = pidgin_conv_get_window(PIDGIN_CONVERSATION(conv)); gtkblist = pwm_convs_get_blist(gtkconvwin); /* Sanity check: This callback should only continue for merged windows. */ if (gtkblist == NULL) return; /* If the last conv is being deleted, reset help, icons, title, and * menu. */ if (pidgin_conv_window_get_gtkconv_count(gtkconvwin) <= 1) { pwm_show_dummy_conversation(gtkblist); gtk_window_set_icon_list(GTK_WINDOW(gtkblist->window), NULL); gtk_window_set_title(GTK_WINDOW(gtkblist->window), pwm_fetch(gtkblist, "title")); pwm_set_conv_menus_visible(gtkblist, FALSE); } }
void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); wxTopLevelWindowBase::SetIcons( icons ); // Setting icons before window is realized can cause a GTK assertion if // another TLW is realized before this one, and it has this one as it's // transient parent. The life demo exibits this problem. if (!GTK_WIDGET_REALIZED(m_widget)) return; GList *list = NULL; size_t max = icons.m_icons.GetCount(); for (size_t i = 0; i < max; i++) { if (icons.m_icons[i].Ok()) { list = g_list_prepend(list, icons.m_icons[i].GetPixbuf()); } } gtk_window_set_icon_list(GTK_WINDOW(m_widget), list); g_list_free(list); }
static void rsvg_window_set_default_icon (GtkWindow * window, GdkPixbuf * src) { GList *list; GdkPixbuf *icon; gint width, height; width = gdk_pixbuf_get_width (src); height = gdk_pixbuf_get_height (src); if (width > 128 || height > 128) { /* sending images greater than 128x128 has this nasty tendency to cause broken pipe errors X11 Servers */ if (width > height) { width = 0.5 + width * 128. / height; height = 128; } else { height = 0.5 + height * 128. / width; width = 128; } icon = gdk_pixbuf_scale_simple (src, width, height, GDK_INTERP_BILINEAR); } else { icon = g_object_ref (G_OBJECT (src)); } list = g_list_prepend (NULL, icon); gtk_window_set_icon_list (window, list); g_list_free (list); g_object_unref (G_OBJECT (icon)); }
static void set_up_icon_windows (void) { int i; int n_windows; /* Create some windows */ n_windows = 9; i = 0; while (i < n_windows) { GtkWidget *w; GtkWidget *c; GList *icons; GdkPixbuf *pix; w = gtk_window_new (GTK_WINDOW_TOPLEVEL); c = gtk_button_new_with_label ("Icon window"); gtk_container_add (GTK_CONTAINER (w), c); icons = NULL; pix = gtk_widget_render_icon (w, GTK_STOCK_SAVE, GTK_ICON_SIZE_LARGE_TOOLBAR, NULL); icons = g_list_append (icons, pix); if (i % 2) { pix = gtk_widget_render_icon (w, GTK_STOCK_SAVE, GTK_ICON_SIZE_DIALOG, NULL); icons = g_list_append (icons, pix); } if (i % 3) { pix = gtk_widget_render_icon (w, GTK_STOCK_SAVE, GTK_ICON_SIZE_MENU, NULL); icons = g_list_append (icons, pix); } gtk_window_set_icon_list (GTK_WINDOW (w), icons); g_list_foreach (icons, (GFunc) g_object_unref, NULL); g_list_free (icons); gtk_widget_show_all (w); ++i; } }
/** * Restore the Buddy List to its former glory by splitting off conversations * * This effectively will undo everything done by pwm_merge_conversation(). The * Buddy List should be returned to its original state, and any conversations * should be in a separate window. * * @param[in] gtkblist The Buddy List that has had enough of this plugin **/ void pwm_split_conversation(PidginBuddyList *gtkblist) { PidginWindow * gtkconvwin; /*< Conversation window merged into gtkblist */ GtkWidget *paned; /*< The panes on the Buddy List window */ gchar *title; /*< Original title of the Buddy List window */ gtkconvwin = pwm_blist_get_convs(gtkblist); paned = pwm_fetch(gtkblist, "paned"); title = pwm_fetch(gtkblist, "title"); /* Ensure the conversation window's menu items are returned. */ pwm_set_conv_menus_visible(gtkblist, FALSE); /* End the association between the Buddy List and its conversation * window. */ g_object_steal_data(G_OBJECT(gtkblist->notebook), "pwm_convs"); g_object_steal_data(G_OBJECT(gtkconvwin->notebook), "pwm_blist"); /* Point the conversation window's structure back to its original * window. */ gtkconvwin->window = pwm_fetch(gtkblist, "conv_window"); pwm_clear(gtkblist, "conv_window"); /* Stop passing focus events from Buddy List to conversation window. */ g_object_disconnect(G_OBJECT(gtkblist->window), "any_signal", G_CALLBACK(focus_in_event_cb), gtkconvwin->window, NULL); /* Restore the conversation window's notebook. */ pwm_widget_replace(pwm_fetch(gtkblist, "placeholder"), gtkconvwin->notebook, NULL); pwm_clear(gtkblist, "placeholder"); /* Free the dummy conversation, and display the window if it survives. */ pwm_free_dummy_conversation(gtkblist); if (g_list_find(pidgin_conv_windows_get_list(), gtkconvwin) != NULL) pidgin_conv_window_show(gtkconvwin); /* Restore the Buddy List's original structure, and destroy the panes. */ pwm_widget_replace(paned, gtkblist->notebook, NULL); pwm_clear(gtkblist, "paned"); /* Restore the window title and icons from before conversations set * them. */ gtk_window_set_icon_list(GTK_WINDOW(gtkblist->window), NULL); gtk_window_set_title(GTK_WINDOW(gtkblist->window), title); g_free(title); pwm_clear(gtkblist, "title"); }
static void e_contact_editor_im_init (EContactEditorIm *e_contact_editor_im) { GladeXML *gui; GtkWidget *widget; GList *icon_list; char *gladefile; gtk_dialog_add_buttons (GTK_DIALOG (e_contact_editor_im), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_has_separator (GTK_DIALOG (e_contact_editor_im), FALSE); gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (e_contact_editor_im)->action_area), 12); gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (e_contact_editor_im)->vbox), 0); gtk_window_set_resizable(GTK_WINDOW(e_contact_editor_im), TRUE); e_contact_editor_im->service = FIRST_IM_TYPE; e_contact_editor_im->location = g_strdup("HOME"); e_contact_editor_im->username = NULL; gladefile = g_build_filename (EVOLUTION_GLADEDIR, "im.glade", NULL); gui = glade_xml_new (gladefile, NULL, NULL); g_free (gladefile); e_contact_editor_im->gui = gui; widget = glade_xml_get_widget(gui, "dialog-im"); gtk_window_set_title (GTK_WINDOW (e_contact_editor_im), GTK_WINDOW (widget)->title); widget = glade_xml_get_widget(gui, "table-im"); g_object_ref(widget); gtk_container_remove(GTK_CONTAINER(widget->parent), widget); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (e_contact_editor_im)->vbox), widget, TRUE, TRUE, 0); g_object_unref(widget); setup_service_optmenu(e_contact_editor_im); setup_location_optmenu(e_contact_editor_im); gtk_widget_grab_focus(glade_xml_get_widget(gui, "entry-username")); /* set the icon */ icon_list = e_icon_factory_get_icon_list ("contact-new"); if (icon_list) { gtk_window_set_icon_list (GTK_WINDOW (e_contact_editor_im), icon_list); g_list_foreach (icon_list, (GFunc) g_object_unref, NULL); g_list_free (icon_list); } }
/** * gnome_window_icon_set_from_file_list: * @w: window to set icons on * @filenames: NULL terminated string array * * Description: Convenience wrapper around gtk_window_set_icon_list(), * which loads the icons in @filenames. **/ void gnome_window_icon_set_from_file_list (GtkWindow *w, const char **filenames) { GList *list; g_return_if_fail (w != NULL); g_return_if_fail (GTK_IS_WINDOW (w)); g_return_if_fail (filenames != NULL); list = list_from_char_array (filenames); gtk_window_set_icon_list (w, list); free_list (list); }
void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons ) { base_type::SetIcons(icons); // Setting icons before window is realized can cause a GTK assertion if // another TLW is realized before this one, and it has this one as its // transient parent. The life demo exibits this problem. if (m_widget && gtk_widget_get_realized(m_widget)) { GList* list = NULL; for (size_t i = icons.GetIconCount(); i--;) list = g_list_prepend(list, icons.GetIconByIndex(i).GetPixbuf()); gtk_window_set_icon_list(GTK_WINDOW(m_widget), list); g_list_free(list); } }
static void window_set_icons (GtkWidget *window) { GtkIconTheme *theme = gtk_icon_theme_get_default (); gint sizes[] = { 16, 24, 32, 64 }; GList *list = NULL; gint i; for (i = 0; i < G_N_ELEMENTS (sizes); i++) list = g_list_prepend (list, gtk_icon_theme_load_icon (theme, GIMP_STOCK_USER_MANUAL, sizes[i], 0, NULL)); gtk_window_set_icon_list (GTK_WINDOW (window), list); g_list_free_full (list, (GDestroyNotify) g_object_unref); }
void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); wxTopLevelWindowBase::SetIcons( icons ); GList *list = NULL; size_t max = icons.m_icons.GetCount(); for (size_t i = 0; i < max; i++) { if (icons.m_icons[i].Ok()) { list = g_list_prepend(list, icons.m_icons[i].GetPixbuf()); } } gtk_window_set_icon_list(GTK_WINDOW(m_widget), list); g_list_free(list); }
static void window_set_icons (GtkWidget *window) { const GtkIconSize sizes[] = { GTK_ICON_SIZE_MENU, GTK_ICON_SIZE_BUTTON, GTK_ICON_SIZE_DND, GTK_ICON_SIZE_DIALOG }; GList *list = NULL; gint i; for (i = 0; i < G_N_ELEMENTS (sizes); i++) list = g_list_prepend (list, gtk_widget_render_icon (window, GIMP_STOCK_USER_MANUAL, sizes[i], NULL)); gtk_window_set_icon_list (GTK_WINDOW (window), list); g_list_free_full (list, (GDestroyNotify) g_object_unref); }
/** * Initialize the application icons for the program. These icons are * the ones shown by the window manager within title bars and pagers. * The last icon listed in the array will be displayed in the About * dialog. * * @param top Toplevel whose icon to set. All child windows will * inherit these icons. */ static void init_icons(toplevel_t * top) { static const char *icon_names[] = { "sediffx-small.png", "sediffx.png" }; GdkPixbuf *icon; char *path; GList *icon_list = NULL; size_t i; for (i = 0; i < sizeof(icon_names) / sizeof(icon_names[0]); i++) { if ((path = apol_file_find_path(icon_names[i])) == NULL) { continue; } icon = gdk_pixbuf_new_from_file(path, NULL); free(path); if (icon == NULL) { continue; } icon_list = g_list_append(icon_list, icon); } gtk_window_set_default_icon_list(icon_list); gtk_window_set_icon_list(top->w, icon_list); }
static GtkWidget * create_separate_window (void) { GtkWidget *window; gboolean skips_taskbar; gboolean is_transient; gint window_type; g_object_get (G_settings, "wm-secondary-windows-skip-taskbar", &skips_taskbar, "wm-secondary-windows-are-transient", &is_transient, "wm-secondary-windows-type", &window_type, NULL); window = g_object_new (GTK_TYPE_WINDOW, "type", GTK_WINDOW_TOPLEVEL, "skip-taskbar-hint", skips_taskbar, "title", _("Web view"), "deletable", FALSE, "type-hint", window_type, NULL); g_signal_connect (window, "delete-event", G_CALLBACK (on_separate_window_delete_event), NULL); g_signal_connect (window, "destroy", G_CALLBACK (on_separate_window_destroy), NULL); gtk_container_add (GTK_CONTAINER (window), G_browser); if (is_transient) { gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (geany_data->main_widgets->window)); } else { GList *icons; icons = gtk_window_get_icon_list (GTK_WINDOW (geany_data->main_widgets->window)); gtk_window_set_icon_list (GTK_WINDOW (window), icons); g_list_free (icons); } gwh_browser_set_inspector_transient_for (GWH_BROWSER (G_browser), GTK_WINDOW (window)); return window; }
/** * gui_misc_set_icon_for: * sets vqcc-gtk icon (list) for specified window */ void gui_misc_set_icon_for(GtkWindow * window) { GList * icon_list = NULL; /* make icon list */ icon_list = g_list_prepend( icon_list, gdk_pixbuf_new_from_inline(-1, pixbuf_logo_24, FALSE, NULL)); icon_list = g_list_prepend( icon_list, gdk_pixbuf_new_from_inline(-1, pixbuf_logo_32, FALSE, NULL)); icon_list = g_list_prepend( icon_list, gdk_pixbuf_new_from_inline(-1, pixbuf_logo_48, FALSE, NULL)); /* set window icons */ gtk_window_set_icon_list(window, icon_list); /* unref icons & free the list */ while(icon_list) { g_object_unref(G_OBJECT(icon_list->data)); icon_list = g_list_delete_link(icon_list, icon_list); } }
static struct _send_data * build_dialog (EAccountList *accounts, CamelFolder *outbox, const char *destination) { GtkDialog *gd; GtkWidget *table; int row, num_sources; GList *list = NULL; struct _send_data *data; GtkWidget *send_icon; GtkWidget *recv_icon; GtkWidget *scrolled_window; GtkWidget *label; GtkWidget *status_label; GtkWidget *progress_bar; GtkWidget *cancel_button; struct _send_info *info; char *pretty_url; EAccount *account; EIterator *iter; GList *icon_list; EMEventTargetSendReceive *target; gd = (GtkDialog *)(send_recv_dialog = gtk_dialog_new_with_buttons(_("Send & Receive Mail"), NULL, GTK_DIALOG_NO_SEPARATOR, NULL)); gtk_window_set_modal ((GtkWindow *) gd, FALSE); gconf_bridge_bind_window_size ( gconf_bridge_get (), GCONF_KEY_PREFIX, GTK_WINDOW (send_recv_dialog)); gtk_widget_ensure_style ((GtkWidget *)gd); gtk_container_set_border_width ((GtkContainer *)gd->vbox, 0); gtk_container_set_border_width ((GtkContainer *)gd->action_area, 6); cancel_button = gtk_button_new_with_mnemonic (_("Cancel _All")); gtk_button_set_image ( GTK_BUTTON (cancel_button), gtk_image_new_from_stock ( GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); gtk_widget_show (cancel_button); gtk_dialog_add_action_widget (gd, cancel_button, GTK_RESPONSE_CANCEL); icon_list = e_icon_factory_get_icon_list ("mail-send-receive"); if (icon_list) { gtk_window_set_icon_list (GTK_WINDOW (gd), icon_list); g_list_foreach (icon_list, (GFunc) g_object_unref, NULL); g_list_free (icon_list); } num_sources = 0; iter = e_list_get_iterator ((EList *) accounts); while (e_iterator_is_valid (iter)) { account = (EAccount *) e_iterator_get (iter); if (account->source->url) num_sources++; e_iterator_next (iter); } g_object_unref (iter); table = gtk_table_new (num_sources, 4, FALSE); gtk_container_set_border_width (GTK_CONTAINER (table), 6); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_table_set_col_spacings (GTK_TABLE (table), 6); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_container_set_border_width ( GTK_CONTAINER (scrolled_window), 6); gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_add_with_viewport ( GTK_SCROLLED_WINDOW (scrolled_window), table); gtk_box_pack_start ( GTK_BOX (gd->vbox), scrolled_window, TRUE, TRUE, 0); gtk_widget_show (scrolled_window); /* must bet setup after send_recv_dialog as it may re-trigger send-recv button */ data = setup_send_data (); row = 0; iter = e_list_get_iterator ((EList *) accounts); while (e_iterator_is_valid (iter)) { EAccountService *source; account = (EAccount *) e_iterator_get (iter); source = account->source; if (!account->enabled || !source->url) { e_iterator_next (iter); continue; } /* see if we have an outstanding download active */ info = g_hash_table_lookup (data->active, source->url); if (info == NULL) { send_info_t type; type = get_receive_type (source->url); if (type == SEND_INVALID || type == SEND_SEND) { e_iterator_next (iter); continue; } info = g_malloc0 (sizeof (*info)); info->type = type; d(printf("adding source %s\n", source->url)); info->uri = g_strdup (source->url); info->keep = source->keep_on_server; info->cancel = camel_operation_new (operation_status, info); info->state = SEND_ACTIVE; info->timeout_id = g_timeout_add (STATUS_TIMEOUT, operation_status_timeout, info); g_hash_table_insert (data->active, info->uri, info); list = g_list_prepend (list, info); } else if (info->progress_bar != NULL) { /* incase we get the same source pop up again */ e_iterator_next (iter); continue; } else if (info->timeout_id == 0) info->timeout_id = g_timeout_add (STATUS_TIMEOUT, operation_status_timeout, info); recv_icon = e_icon_factory_get_image ( "mail-inbox", E_ICON_SIZE_LARGE_TOOLBAR); pretty_url = format_url (source->url, account->name); label = gtk_label_new (NULL); gtk_label_set_ellipsize ( GTK_LABEL (label), PANGO_ELLIPSIZE_END); gtk_label_set_markup (GTK_LABEL (label), pretty_url); g_free (pretty_url); progress_bar = gtk_progress_bar_new (); cancel_button = gtk_button_new_from_stock (GTK_STOCK_CANCEL); status_label = gtk_label_new ( (info->type == SEND_UPDATE) ? _("Updating...") : _("Waiting...")); gtk_label_set_ellipsize ( GTK_LABEL (status_label), PANGO_ELLIPSIZE_END); /* g_object_set(data->label, "bold", TRUE, NULL); */ gtk_misc_set_alignment (GTK_MISC (label), 0, .5); gtk_misc_set_alignment (GTK_MISC (status_label), 0, .5); gtk_table_attach ( GTK_TABLE (table), recv_icon, 0, 1, row, row+2, 0, 0, 0, 0); gtk_table_attach ( GTK_TABLE (table), label, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_table_attach ( GTK_TABLE (table), progress_bar, 2, 3, row, row+2, 0, 0, 0, 0); gtk_table_attach ( GTK_TABLE (table), cancel_button, 3, 4, row, row+2, 0, 0, 0, 0); gtk_table_attach ( GTK_TABLE (table), status_label, 1, 2, row+1, row+2, GTK_EXPAND | GTK_FILL, 0, 0, 0); info->progress_bar = progress_bar; info->status_label = status_label; info->cancel_button = cancel_button; info->data = data; g_signal_connect ( cancel_button, "clicked", G_CALLBACK (receive_cancel), info); e_iterator_next (iter); row = row + 2; } g_object_unref (iter); /* Hook: If some one wants to hook on to the sendreceive dialog, this is the way to go. */ target = em_event_target_new_send_receive (em_event_peek(), table, data, row, EM_EVENT_SEND_RECEIVE); e_event_emit ((EEvent *)em_event_peek (), "mail.sendreceive", (EEventTarget *) target); if (outbox && destination) { info = g_hash_table_lookup (data->active, SEND_URI_KEY); if (info == NULL) { info = g_malloc0 (sizeof (*info)); info->type = SEND_SEND; d(printf("adding dest %s\n", destination)); info->uri = g_strdup (destination); info->keep = FALSE; info->cancel = camel_operation_new (operation_status, info); info->state = SEND_ACTIVE; info->timeout_id = g_timeout_add (STATUS_TIMEOUT, operation_status_timeout, info); g_hash_table_insert (data->active, SEND_URI_KEY, info); list = g_list_prepend (list, info); } else if (info->timeout_id == 0) info->timeout_id = g_timeout_add (STATUS_TIMEOUT, operation_status_timeout, info); send_icon = e_icon_factory_get_image ( "mail-outbox", E_ICON_SIZE_LARGE_TOOLBAR); pretty_url = format_url (destination, NULL); label = gtk_label_new (NULL); gtk_label_set_ellipsize ( GTK_LABEL (label), PANGO_ELLIPSIZE_END); gtk_label_set_markup (GTK_LABEL (label), pretty_url); g_free (pretty_url); progress_bar = gtk_progress_bar_new (); cancel_button = gtk_button_new_from_stock (GTK_STOCK_CANCEL); status_label = gtk_label_new (_("Waiting...")); gtk_label_set_ellipsize ( GTK_LABEL (status_label), PANGO_ELLIPSIZE_END); gtk_misc_set_alignment (GTK_MISC (label), 0, .5); gtk_misc_set_alignment (GTK_MISC (status_label), 0, .5); gtk_table_attach ( GTK_TABLE (table), send_icon, 0, 1, row, row+2, 0, 0, 0, 0); gtk_table_attach ( GTK_TABLE (table), label, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_table_attach ( GTK_TABLE (table), progress_bar, 2, 3, row, row+2, 0, 0, 0, 0); gtk_table_attach ( GTK_TABLE (table), cancel_button, 3, 4, row, row+2, 0, 0, 0, 0); gtk_table_attach ( GTK_TABLE (table), status_label, 1, 2, row+1, row+2, GTK_EXPAND | GTK_FILL, 0, 0, 0); info->progress_bar = progress_bar; info->cancel_button = cancel_button; info->data = data; info->status_label = status_label; g_signal_connect ( cancel_button, "clicked", G_CALLBACK (receive_cancel), info); gtk_widget_show_all (table); } gtk_widget_show (GTK_WIDGET (gd)); g_signal_connect (gd, "response", G_CALLBACK (dialog_response), data); g_object_weak_ref ((GObject *) gd, (GWeakNotify) dialog_destroy_cb, data); data->infos = list; data->gd = gd; return data; }
gboolean alarm_dialog_run (GtkWidget *parent, ECal *ecal, ECalComponentAlarm *alarm) { Dialog dialog; int response_id; GList *icon_list; char *gladefile; g_return_val_if_fail (alarm != NULL, FALSE); dialog.alarm = alarm; dialog.ecal = ecal; gladefile = g_build_filename (EVOLUTION_GLADEDIR, "alarm-dialog.glade", NULL); dialog.xml = glade_xml_new (gladefile, NULL, NULL); g_free (gladefile); if (!dialog.xml) { g_message (G_STRLOC ": Could not load the Glade XML file!"); return FALSE; } if (!get_widgets (&dialog)) { g_object_unref(dialog.xml); return FALSE; } if (!setup_select_names (&dialog)) { g_object_unref (dialog.xml); return FALSE; } init_widgets (&dialog); alarm_to_dialog (&dialog); gtk_widget_ensure_style (dialog.toplevel); gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog.toplevel)->vbox), 0); gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog.toplevel)->action_area), 12); icon_list = e_icon_factory_get_icon_list ("stock_calendar"); if (icon_list) { gtk_window_set_icon_list (GTK_WINDOW (dialog.toplevel), icon_list); g_list_foreach (icon_list, (GFunc) g_object_unref, NULL); g_list_free (icon_list); } gtk_window_set_transient_for (GTK_WINDOW (dialog.toplevel), GTK_WINDOW (parent)); response_id = gtk_dialog_run (GTK_DIALOG (dialog.toplevel)); if (response_id == GTK_RESPONSE_OK) dialog_to_alarm (&dialog); gtk_widget_destroy (dialog.toplevel); g_object_unref (dialog.xml); return response_id == GTK_RESPONSE_OK ? TRUE : FALSE; }
/** * vlopt_window_show(): Show the VDP Layer Options window. * @param parent Parent window. */ void vlopt_window_show(void *parent) { if (vlopt_window) { // VDP Layer Options window is already visible. // Set focus. gtk_widget_grab_focus(vlopt_window); return; } // Create the VDP Layer Options window. vlopt_window = gtk_dialog_new(); gtk_container_set_border_width(GTK_CONTAINER(vlopt_window), 4); gtk_window_set_title(GTK_WINDOW(vlopt_window), "VDP Layer Options"); gtk_window_set_position(GTK_WINDOW(vlopt_window), GTK_WIN_POS_CENTER); gtk_window_set_resizable(GTK_WINDOW(vlopt_window), FALSE); gtk_window_set_type_hint(GTK_WINDOW(vlopt_window), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_dialog_set_has_separator(GTK_DIALOG(vlopt_window), FALSE); // Add the window icons. GList *icon_list = NULL; GdkPixbuf *icon_pixbuf_16, *icon_pixbuf_32; // Load the 16x16 icon. icon_pixbuf_16 = gdk_pixbuf_new_from_xpm_data(vlopt_icon_xpm_16x16); icon_list = g_list_append(icon_list, icon_pixbuf_16); // Load the 32x32 icon. icon_pixbuf_32 = gdk_pixbuf_new_from_xpm_data(vlopt_icon_xpm_32x32); icon_list = g_list_append(icon_list, icon_pixbuf_32); // Set the icon list. gtk_window_set_icon_list(GTK_WINDOW(vlopt_window), icon_list); // Unreference everything. g_list_free(icon_list); g_object_unref(icon_pixbuf_16); g_object_unref(icon_pixbuf_32); // Callbacks for if the window is closed. g_signal_connect((gpointer)vlopt_window, "delete_event", G_CALLBACK(vlopt_window_callback_close), NULL); g_signal_connect((gpointer)vlopt_window, "destroy_event", G_CALLBACK(vlopt_window_callback_close), NULL); // Dialog response callback. g_signal_connect((gpointer)vlopt_window, "response", G_CALLBACK(vlopt_window_callback_response), NULL); // Get the dialog VBox. GtkWidget *vboxDialog = gtk_bin_get_child(GTK_BIN(vlopt_window)); gtk_widget_show(vboxDialog); // Create the main VBox. GtkWidget *vboxMain = gtk_vbox_new(FALSE, 0); gtk_widget_show(vboxMain); gtk_container_add(GTK_CONTAINER(vboxDialog), vboxMain); // Create the main frame. GtkWidget *fraMain = gtk_frame_new(NULL); gtk_widget_show(fraMain); gtk_box_pack_start(GTK_BOX(vboxMain), fraMain, FALSE, TRUE, 0); gtk_frame_set_shadow_type(GTK_FRAME(fraMain), GTK_SHADOW_ETCHED_IN); // Main frame label. GtkWidget *lblFrameTitle = gtk_label_new("VDP Layer Options"); gtk_label_set_use_markup(GTK_LABEL(lblFrameTitle), TRUE); gtk_widget_show(lblFrameTitle); gtk_frame_set_label_widget(GTK_FRAME(fraMain), lblFrameTitle); // Horizontal padding for the frame VBox. GtkWidget *alignVBoxFrame = gtk_alignment_new(0.0f, 0.0f, 0.0f, 0.0f); gtk_alignment_set_padding(GTK_ALIGNMENT(alignVBoxFrame), 0, 0, 4, 4); gtk_container_add(GTK_CONTAINER(fraMain), alignVBoxFrame); // Create the frame VBox. GtkWidget *vboxFrame = gtk_vbox_new(FALSE, 4); gtk_widget_show(vboxFrame); gtk_container_add(GTK_CONTAINER(alignVBoxFrame), vboxFrame); // Create the outer table layout for the first 9 layer options. GtkWidget *tblOptionsRows = gtk_table_new(4, 2, FALSE); gtk_widget_show(tblOptionsRows); gtk_box_pack_start(GTK_BOX(vboxFrame), tblOptionsRows, FALSE, FALSE, 0); // Create a blank label for the first row. GtkWidget *lblBlankRow = gtk_label_new(NULL); gtk_widget_show(lblBlankRow); gtk_table_attach(GTK_TABLE(tblOptionsRows), lblBlankRow, 0, 1, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0); // Create the inner table layout for the first 9 layer options. GtkWidget *tblOptions = gtk_table_new(4, 3, TRUE); gtk_widget_show(tblOptions); gtk_table_attach(GTK_TABLE(tblOptionsRows), tblOptions, 1, 2, 0, 4, (GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0); // Create column and row labels. for (int i = 0; i < 3; i++) { // Column label. GtkWidget *lblTblColHeader = gtk_label_new(vlopt_options[i].sublayer); gtk_misc_set_alignment(GTK_MISC(lblTblColHeader), 0.5f, 0.5f); gtk_label_set_justify(GTK_LABEL(lblTblColHeader), GTK_JUSTIFY_CENTER); gtk_widget_show(lblTblColHeader); gtk_table_attach(GTK_TABLE(tblOptions), lblTblColHeader, i, i + 1, 0, 1, GTK_FILL, (GtkAttachOptions)0, 2, 2); // Row label. GtkWidget *lblTblRowHeader = gtk_label_new(vlopt_options[i * 3].layer); gtk_misc_set_alignment(GTK_MISC(lblTblRowHeader), 1.0f, 0.5f); gtk_label_set_justify(GTK_LABEL(lblTblRowHeader), GTK_JUSTIFY_RIGHT); gtk_widget_show(lblTblRowHeader); gtk_table_attach(GTK_TABLE(tblOptionsRows), lblTblRowHeader, 0, 1, i + 1, i + 2, GTK_FILL, (GtkAttachOptions)0, 2, 2); } // Create the VDP Layer Options checkboxes. uint8_t row = 1, col = 0; for (unsigned int i = 0; i < 9; i++) { vlopt_window_checkboxes[i] = gtk_check_button_new(); gtk_widget_show(vlopt_window_checkboxes[i]); gtk_table_attach(GTK_TABLE(tblOptions), vlopt_window_checkboxes[i], col, col + 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0); // Next cell. col++; if (col >= 3) { col = 0; row++; } // Set the callback. g_signal_connect((gpointer)vlopt_window_checkboxes[i], "toggled", G_CALLBACK(vlopt_window_callback_checkbox_toggled), GINT_TO_POINTER(i)); } // Create the checkboxes for the remaining VDP Layer Options. for (unsigned int i = 9; i < VLOPT_OPTIONS_COUNT; i++) { vlopt_window_checkboxes[i] = gtk_check_button_new_with_label(vlopt_options[i].layer); gtk_widget_show(vlopt_window_checkboxes[i]); gtk_box_pack_start(GTK_BOX(vboxFrame), vlopt_window_checkboxes[i], FALSE, FALSE, 0); // Set the callback. g_signal_connect((gpointer)vlopt_window_checkboxes[i], "toggled", G_CALLBACK(vlopt_window_callback_checkbox_toggled), GINT_TO_POINTER(i)); } // Create the dialog buttons. // "Reset" button. GtkWidget *btnReset = gtk_dialog_add_button( GTK_DIALOG(vlopt_window), "_Reset", VLOPT_RESPONSE_RESET); // Create the icon for the "Reset" button. GtkWidget *btnReset_icon = gtk_image_new_from_stock(GTK_STOCK_REFRESH, GTK_ICON_SIZE_BUTTON); gtk_widget_show(btnReset_icon); gtk_button_set_image(GTK_BUTTON(btnReset), btnReset_icon); // "Close" button. gtk_dialog_add_button(GTK_DIALOG(vlopt_window), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); // Set the window as modal to the main application window. if (parent) gtk_window_set_transient_for(GTK_WINDOW(vlopt_window), GTK_WINDOW(parent)); // Load the options. vlopt_window_load_options(); // Show the window. gtk_widget_show_all(vlopt_window); // Register the window with MDP Host Services. vlopt_host_srv->window_register(&mdp, vlopt_window); }
/** * changed_component_dialog: * @parent: Parent window for the dialog. * @comp: A calendar component * @deleted: Whether the object is being deleted or updated * @changed: Whether or not the user has made changes * * Pops up a dialog box asking the user whether changes made (if any) * should be thrown away because the item has been updated elsewhere * * Return value: TRUE if the user clicked Yes, FALSE otherwise. **/ gboolean changed_component_dialog (GtkWindow *parent, ECalComponent *comp, gboolean deleted, gboolean changed) { GtkWidget *dialog; ECalComponentVType vtype; char *str; gint response; GList *icon_list; vtype = e_cal_component_get_vtype (comp); if (deleted) { switch (vtype) { case E_CAL_COMPONENT_EVENT: str = _("This event has been deleted."); break; case E_CAL_COMPONENT_TODO: str = _("This task has been deleted."); break; case E_CAL_COMPONENT_JOURNAL: str = _("This memo has been deleted."); break; default: g_message ("changed_component_dialog(): " "Cannot handle object of type %d", vtype); return FALSE; } if (changed) str = g_strdup_printf (_("%s You have made changes. Forget those changes and close the editor?"), str); else str = g_strdup_printf (_("%s You have made no changes, close the editor?"), str); } else { switch (vtype) { case E_CAL_COMPONENT_EVENT: str = _("This event has been changed."); break; case E_CAL_COMPONENT_TODO: str = _("This task has been changed."); break; case E_CAL_COMPONENT_JOURNAL: str = _("This memo has been changed."); break; default: g_message ("changed_component_dialog(): " "Cannot handle object of type %d", vtype); return FALSE; } if (changed) str = g_strdup_printf (_("%s You have made changes. Forget those changes and update the editor?"), str); else str = g_strdup_printf (_("%s You have made no changes, update the editor?"), str); } dialog = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "%s", str); icon_list = e_icon_factory_get_icon_list ("stock_calendar"); if (icon_list) { gtk_window_set_icon_list (GTK_WINDOW (dialog), icon_list); g_list_foreach (icon_list, (GFunc) g_object_unref, NULL); g_list_free (icon_list); } response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); if (response == GTK_RESPONSE_YES) return TRUE; else return FALSE; }
/** * delete_error_dialog: * * Shows any applicable error messages as the result of deleting and object * **/ void delete_error_dialog (GError *error, ECalComponentVType vtype) { GList *icon_list = NULL; GtkWidget *dialog; const char *str; if (!error) return; switch (error->code) { case E_CALENDAR_STATUS_CORBA_EXCEPTION: switch (vtype) { case E_CAL_COMPONENT_EVENT: str = _("The event could not be deleted due to a corba error"); break; case E_CAL_COMPONENT_TODO: str = _("The task could not be deleted due to a corba error"); break; case E_CAL_COMPONENT_JOURNAL: str = _("The memo could not be deleted due to a corba error"); break; default: str = _("The item could not be deleted due to a corba error"); break; } break; case E_CALENDAR_STATUS_PERMISSION_DENIED: switch (vtype) { case E_CAL_COMPONENT_EVENT: str = _("The event could not be deleted because permission was denied"); break; case E_CAL_COMPONENT_TODO: str = _("The task could not be deleted because permission was denied"); break; case E_CAL_COMPONENT_JOURNAL: str = _("The memo could not be deleted because permission was denied"); break; default: str = _("The item could not be deleted because permission was denied"); break; } break; case E_CALENDAR_STATUS_OTHER_ERROR: switch (vtype) { case E_CAL_COMPONENT_EVENT: str = _("The event could not be deleted due to an error"); break; case E_CAL_COMPONENT_TODO: str = _("The task could not be deleted due to an error"); break; case E_CAL_COMPONENT_JOURNAL: str = _("The memo could not be deleted due to an error"); break; default: str = _("The item could not be deleted due to an error"); break; } break; case E_CALENDAR_STATUS_OK: case E_CALENDAR_STATUS_OBJECT_NOT_FOUND: default: /* If not found, we don't care - its gone anyhow */ return; } dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", str); if (vtype == E_CAL_COMPONENT_EVENT) icon_list = e_icon_factory_get_icon_list ("stock_calendar"); else if (vtype == E_CAL_COMPONENT_TODO) icon_list = e_icon_factory_get_icon_list ("stock_todo"); if (icon_list) { gtk_window_set_icon_list (GTK_WINDOW (dialog), icon_list); g_list_foreach (icon_list, (GFunc) g_object_unref, NULL); g_list_free (icon_list); } gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); }
int main(int argc, char** argv) { //start gnome_init initGUI(argc, argv); cellsWide = DEFAULT_WIDTH / PIX_PER_CELL; //GUI components GtkWidget *window; GtkWidget *imageEventBox, *mainHBox, *sideBox, *quitButton, *settingFrame, *resetButton, *sideVBox, *widthFrame, *saveButton, *hSep, *label, *lowerSideVBox, *checkButton, *rulesFrame, *rulesClearButton, *rulesSetButton, *rulesHBox, *rulesVBox; GdkPixbuf *icon_buf_16, *icon_buf_32, *icon_buf_48, *icon_buf_64, *icon_buf_128, *bg; GList *icons = NULL; window = gtk_window_new(GTK_WINDOW_TOPLEVEL); //load icons from files icon_buf_16 = gdk_pixbuf_new_from_file(ICON_16, NULL); icon_buf_32 = gdk_pixbuf_new_from_file(ICON_32, NULL); icon_buf_48 = gdk_pixbuf_new_from_file(ICON_48, NULL); icon_buf_64 = gdk_pixbuf_new_from_file(ICON_64, NULL); icon_buf_128 = gdk_pixbuf_new_from_file(ICON_128, NULL); //tell gnome to use these icons icons = g_list_append(icons, icon_buf_16); icons = g_list_append(icons, icon_buf_32); icons = g_list_append(icons, icon_buf_48); icons = g_list_append(icons, icon_buf_64); icons = g_list_append(icons, icon_buf_128); gtk_window_set_icon_list(GTK_WINDOW(window), icons); //connect the delete_event signal to the delete_event function g_signal_connect (G_OBJECT(window), "delete_event", G_CALLBACK(delete_event), NULL); //here follows formatting, packing, etc of gtk widgets gtk_container_set_border_width(GTK_CONTAINER(window), 10); gtk_window_set_title(GTK_WINDOW(window), "Cellular Automata"); widthAdjust = gtk_spin_button_new_with_range(WIDTH_LOWER, WIDTH_UPPER, 1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(widthAdjust), DEFAULT_WIDTH); widthFrame = gtk_frame_new("Set Width"); gtk_container_add(GTK_CONTAINER(widthFrame), widthAdjust); gtk_container_set_border_width(GTK_CONTAINER(widthFrame), 10); ruleAdjust = gtk_spin_button_new_with_range(0, 255, 1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(ruleAdjust), 30); settingFrame = gtk_frame_new("Set Rule #"); gtk_container_add(GTK_CONTAINER(settingFrame), ruleAdjust); gtk_container_set_border_width (GTK_CONTAINER(settingFrame), 10); bg = gdk_pixbuf_new_from_file("./data/cellular_automata.png", NULL); imagebuf = gdk_pixbuf_scale_simple(bg, WIDTH, HEIGHT, GDK_INTERP_BILINEAR); mainImage = gtk_image_new_from_pixbuf(imagebuf); imageEventBox = gtk_event_box_new(); gtk_container_add(GTK_CONTAINER(imageEventBox), mainImage); mainHBox = gtk_hbox_new(FALSE, 0); sideVBox = gtk_vbox_new(FALSE, 0); lowerSideVBox = gtk_vbox_new(TRUE, 0); sideBox = gtk_vbox_new(TRUE, 0); checkButton = gtk_check_button_new_with_mnemonic("_Autosave Images"); quitButton = gtk_button_new_from_stock (GTK_STOCK_QUIT); startButton = gtk_button_new_with_mnemonic("_Start"); stopButton = gtk_button_new_with_mnemonic ("_Stop"); saveButton = gtk_button_new_from_stock(GTK_STOCK_SAVE); gtk_widget_set_sensitive(GTK_WIDGET(stopButton), FALSE); resetButton = gtk_button_new_with_mnemonic("_Reset"); //connect the proper callback functions to the proper signals g_signal_connect_swapped (G_OBJECT(quitButton), "clicked", G_CALLBACK(gtk_main_quit), G_OBJECT (window)); g_signal_connect_swapped (G_OBJECT(startButton),"clicked", G_CALLBACK(getLoopy), G_OBJECT(ruleAdjust)); g_signal_connect_swapped (G_OBJECT(stopButton),"clicked", G_CALLBACK(stopLoopy), G_OBJECT(ruleAdjust)); g_signal_connect_swapped (G_OBJECT(resetButton),"clicked", G_CALLBACK(resetImage), G_OBJECT(resetButton)); g_signal_connect_swapped(G_OBJECT(ruleAdjust),"value-changed", G_CALLBACK(updateRule), GTK_WIDGET(ruleAdjust)); g_signal_connect_swapped(G_OBJECT(widthAdjust),"value-changed", G_CALLBACK(initCA), GTK_WIDGET(widthAdjust)); g_signal_connect_swapped(G_OBJECT(saveButton),"clicked", G_CALLBACK(getPic), GTK_WIDGET(saveButton)); g_signal_connect_swapped(G_OBJECT(checkButton),"toggled", G_CALLBACK(toggleSave), GTK_WIDGET(checkButton)); hSep = gtk_hseparator_new(); label = gtk_label_new("Save Image"); //load the meta-rule file names std::vector<std::string> rulesList; std::string rulesDir("./"), suff(".rules"); getRulesList(rulesDir, rulesList, suff); rulesComboBox = gtk_combo_box_new_text(); gtk_combo_box_append_text(GTK_COMBO_BOX(rulesComboBox), "Rule Set"); for (uint i = 0; i < rulesList.size(); i++) { gtk_combo_box_append_text(GTK_COMBO_BOX(rulesComboBox), rulesList[i].c_str()); } if (rulesList.size()) { gtk_combo_box_set_active(GTK_COMBO_BOX(rulesComboBox), 0); } rulesFrame = gtk_frame_new("Rule Change Controls"); rulesHBox = gtk_hbox_new(FALSE, 0); rulesVBox = gtk_vbox_new(TRUE, 0); rulesClearButton = gtk_button_new_with_mnemonic("_Clear Rules Rule"); rulesSetButton = gtk_button_new_with_mnemonic("Set _Rules Rule"); g_signal_connect(G_OBJECT(rulesComboBox), "changed", G_CALLBACK(combo_selected), rulesFrame); g_signal_connect_swapped(G_OBJECT(rulesClearButton), "clicked", G_CALLBACK(clearRules), G_OBJECT(rulesClearButton)); autoResetButton = gtk_check_button_new_with_mnemonic("_Auto Reset on Dead Lines"); randomizeLengthButton = gtk_check_button_new_with_mnemonic("Randomize _Time Between Rule Changes"); g_signal_connect_swapped(G_OBJECT(autoResetButton), "toggled", G_CALLBACK(autoResetFunction), G_OBJECT(autoResetButton)); g_signal_connect_swapped(G_OBJECT(randomizeLengthButton), "toggled", G_CALLBACK(randomizeLengthFunction), G_OBJECT(randomizeLengthButton)); //pack the widgets into their proper containers gtk_box_pack_start(GTK_BOX(rulesHBox), rulesClearButton, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(rulesVBox), rulesComboBox, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(rulesVBox), rulesHBox, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(rulesVBox), autoResetButton, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(rulesVBox), randomizeLengthButton, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(rulesFrame), rulesVBox); gtk_box_pack_start(GTK_BOX(sideVBox), settingFrame, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(sideVBox), stopButton, FALSE, FALSE,0); gtk_box_pack_start(GTK_BOX(sideVBox), startButton, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(sideVBox), resetButton, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(sideBox), sideVBox, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(sideVBox), rulesFrame, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(lowerSideVBox), label, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(lowerSideVBox), saveButton, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(lowerSideVBox), checkButton, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(lowerSideVBox), hSep, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(lowerSideVBox), quitButton, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(sideBox), lowerSideVBox, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(mainHBox), sideBox, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(mainHBox), imageEventBox, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(window), mainHBox); gtk_widget_show_all(window); //load black and white pixels into buffers blackb = gdk_pixbuf_new_subpixbuf(imagebuf, 0, 0, PIX_PER_CELL, PIX_PER_CELL); black = gdk_pixbuf_copy(blackb); gdk_pixbuf_fill(black, 0x000000ff); whiteb = gdk_pixbuf_new_subpixbuf(imagebuf, 0, 0, PIX_PER_CELL, PIX_PER_CELL); white = gdk_pixbuf_copy(whiteb); gdk_pixbuf_fill(white, 0xffffffff); //setup the cellular automaton========================================= initCA(); //run the main loop of the program gtk_main(); exit(0); }
int main(int argc, char* argv[]) { CefMainArgs main_args(argc, argv); g_appStartupTime = time(NULL); gtk_init(&argc, &argv); CefRefPtr<ClientApp> app(new ClientApp); // Execute the secondary process, if any. int exit_code = CefExecuteProcess(main_args, app.get(), NULL); if (exit_code >= 0) return exit_code; //Retrieve the current working directory if (!getcwd(szWorkingDir, sizeof (szWorkingDir))) return -1; GtkWidget* window; // Parse command line arguments. AppInitCommandLine(argc, argv); CefSettings settings; // Populate the settings based on command line arguments. AppGetSettings(settings, app); settings.no_sandbox = TRUE; // Check cache_path setting if (CefString(&settings.cache_path).length() == 0) { CefString(&settings.cache_path) = AppGetCachePath(); } CefRefPtr<CefCommandLine> cmdLine = AppGetCommandLine(); if (cmdLine->HasSwitch(client::switches::kStartupPath)) { szInitialUrl = cmdLine->GetSwitchValue(client::switches::kStartupPath); } else { szInitialUrl = AppGetRunningDirectory(); szInitialUrl.append("/dev/src/index.html"); if (!FileExists(szInitialUrl)) { szInitialUrl = AppGetRunningDirectory(); szInitialUrl.append("/www/index.html"); if (!FileExists(szInitialUrl)) { if (GetInitialUrl() < 0) return 0; } } } // Initialize CEF. CefInitialize(main_args, settings, app.get(), NULL); // Set window icon std::vector<std::string> icons(APPICONS, APPICONS + sizeof(APPICONS) / sizeof(APPICONS[0]) ); GList *list = NULL; for (int i = 0; i < icons.size(); ++i) { std::string path = icons[i]; GdkPixbuf *icon = gdk_pixbuf_new_from_file(path.c_str(), NULL); if (!icon) continue; list = g_list_append(list, icon); } window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW(window), 800, 600); gtk_window_set_icon_list(GTK_WINDOW(window), list); // Free icon list g_list_foreach(list, (GFunc) g_object_unref, NULL); g_list_free(list); GtkWidget* vbox = gtk_vbox_new(FALSE, 0); GtkWidget* menuBar = gtk_menu_bar_new(); // GtkWidget* debug_menu = CreateMenu(menuBar, "Tests"); // AddMenuEntry(debug_menu, "Hello World Menu", // G_CALLBACK(GetSourceActivated)); gtk_box_pack_start(GTK_BOX(vbox), menuBar, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(HandleQuit), NULL); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_widget_destroyed), &window); add_handler_id = g_signal_connect(G_OBJECT(window), "add", G_CALLBACK(HandleAdd), NULL); // g_signal_connect(G_OBJECT(window), "destroy", // G_CALLBACK(destroy), NULL); // Create the handler. g_handler = new ClientHandler(); g_handler->SetMainHwnd(vbox); // Create the browser view. CefWindowInfo window_info; CefBrowserSettings browserSettings; browserSettings.web_security = STATE_DISABLED; window_info.SetAsChild(vbox); CefBrowserHost::CreateBrowser( window_info, static_cast<CefRefPtr<CefClient> >(g_handler), "file://"+szInitialUrl, browserSettings, NULL); gtk_container_add(GTK_CONTAINER(window), vbox); gtk_widget_show_all(GTK_WIDGET(window)); // Install an signal handler so we clean up after ourselves. signal(SIGINT, TerminationSignalHandler); signal(SIGTERM, TerminationSignalHandler); // Start the node server process startNodeProcess(); CefRunMessageLoop(); CefShutdown(); return 0; }