示例#1
0
文件: ui.go 项目: 0x27/coyim
func (u *gtkUI) mainWindow() {
	builder := builderForDefinition("Main")

	builder.ConnectSignals(map[string]interface{}{
		"on_close_window_signal":                    u.quit,
		"on_add_contact_window_signal":              u.addContactWindow,
		"on_about_dialog_signal":                    u.aboutDialog,
		"on_feedback_dialog_signal":                 u.feedbackDialog,
		"on_toggled_check_Item_Merge_signal":        u.toggleMergeAccounts,
		"on_toggled_check_Item_Show_Offline_signal": u.toggleShowOffline,
	})

	win, err := builder.GetObject("mainWindow")
	if err != nil {
		panic(err)
	}

	u.window = win.(*gtk.Window)

	u.displaySettings = detectCurrentDisplaySettingsFrom(&u.window.Bin.Container.Widget)

	// This must happen after u.displaySettings is initialized
	// So now, roster depends on displaySettings which depends on mainWindow
	u.initRoster()

	// AccountsMenu
	am, _ := builder.GetObject("AccountsMenu")
	u.accountsMenu = am.(*gtk.MenuItem)
	// ViewMenu
	u.viewMenu = new(viewMenu)
	checkItemMerge, _ := builder.GetObject("CheckItemMerge")
	u.viewMenu.merge = checkItemMerge.(*gtk.CheckMenuItem)
	u.displaySettings.defaultSettingsOn(&u.viewMenu.merge.MenuItem.Bin.Container.Widget)

	checkItemShowOffline, _ := builder.GetObject("CheckItemShowOffline")
	u.viewMenu.offline = checkItemShowOffline.(*gtk.CheckMenuItem)
	u.displaySettings.defaultSettingsOn(&u.viewMenu.offline.MenuItem.Bin.Container.Widget)

	u.initMenuBar()
	vbox, _ := builder.GetObject("Vbox")
	vbox.(*gtk.Box).PackStart(u.roster.widget, true, true, 0)

	obj, _ := builder.GetObject("notification-area")
	u.notificationArea = obj.(*gtk.Box)

	u.config.WhenLoaded(func(a *config.ApplicationConfig) {
		if a.Display.HideFeedbackBar {
			return
		}

		doInUIThread(u.addFeedbackInfoBar)
	})

	u.connectShortcutsMainWindow(u.window)

	u.window.SetIcon(coyimIcon.getPixbuf())
	gtk.WindowSetDefaultIcon(coyimIcon.getPixbuf())

	u.window.ShowAll()
}
示例#2
0
func (*RealGtk) WindowSetDefaultIcon(icon gdki.Pixbuf) {
	gtk.WindowSetDefaultIcon(gdka.UnwrapPixbuf(icon))
}