Exemplo n.º 1
0
        public ItemView(ItemList list)
            : base()
        {
            itemList = list;
            itemList.PropertyChanged += ItemListPropertyChanged;
            this.webView = new WebView ();
            #if ENABLE_FONTS
            this.webSettings = new WebSettings ();
            webView.Settings = webSettings;
            #endif
                        ScrolledWindow sw = new ScrolledWindow ();
                        sw.Add(webView);
            Add(sw);

            Conf.AddNotify (Preference.FONT_PATH,
                                        new NotifyEventHandler (FontNotifyHandler));
            SetFonts ();

            ProxyUpdatedCb ();
            Proxy.Updated += ProxyUpdatedCb;

            webView.NavigationRequested += delegate (object sender, NavigationRequestedArgs args) {
            try {
            /*
             * If last_link is the same as args.Request.Uri, the user clicked on a link
             * (as we know he was hovering). Thus, try to open it on the browser
             */
            if(args.Request.Uri.Equals(last_link)){
                args.RetVal = NavigationResponse.Ignore;
                GtkBeans.Global.ShowUri(null, args.Request.Uri);
            } else {
                /* Otherwise, it's part of the post, so accept it (like the facebook iframe) */
                args.RetVal = NavigationResponse.Accept;
            }
            }
            catch (Exception e) {
            Console.Error.WriteLine("Couldn't show URL: " + args.Request.Uri + e.Message);
            }
            };

            webView.HoveringOverLink += delegate (object sender, HoveringOverLinkArgs args) {
                if (OnUrl != null)
                  OnUrl (args.Link);
                  last_link = args.Link;
            };

            webView.Show ();
            PageLoaded = false;
        }
Exemplo n.º 2
0
        private void PrepareGUI()
        {
            Glade.XML gladeXML = Glade.XML.FromAssembly("blam.glade",
                                                        "mainWindow", null);
            gladeXML.Autoconnect(this);

            channelList = new ChannelList(mCollection);
            ((Container)channelListSw).Child = channelList;

            channelList.ChannelSelectedEvent   += ChannelSelected;
            channelList.EditChannelEvent       += EditChannelActivated;
            channelList.MarkChannelAsReadEvent += MarkChannelAsReadActivated;
            channelList.RemoveChannelEvent     += RemoveChannelActivated;
            channelList.RefreshChannelEvent    += RefreshChannelActivated;

			itemList = new ItemList(itemView, channelList);
			((Container)itemListSw).Child = itemList;

            itemView = new ItemView(itemList);

            Frame f = new Frame ();
            f.Shadow = ShadowType.In;
            f.Add (itemView);
            itemPaned.Add2 (f);
            f.Show ();
            itemView.OnUrl += OnUrl;

			// a bit silly to do it every time, but works
			itemList.PropertyChanged += (sender, e) => printMenuItem.Sensitive = true;

            trayIcon = new TrayIcon (Catalog.GetString ("Blam News Reader"), mCollection);
            trayIcon.ButtonPressEvent += TrayIconButtonPressCb;
            trayIcon.RefreshAllEvent += RefreshAllActivated;
            trayIcon.PreferencesEvent += PreferencesActivated;
            trayIcon.AboutEvent += AboutActivated;
            trayIcon.QuitEvent += QuitActivated;

            channelsLabelText = channelsLabel.Text;
            UpdateTotalNumberOfUnread ();

            printMenuItem.Sensitive = false;
            SensitizeChannelMenuItems(false);

            // Setup drag-n-drop
            Gtk.Drag.DestSet(mainWindow, DestDefaults.All,
                             DragEntries, DragAction.Copy | DragAction.Move);
            mainWindow.DragDataReceived += DragDataReceivedCb;

            RestoreWindowState();

            mainWindow.IconName = "blam";

            mainWindow.ShowAll ();

            bool ShowItemList = Conf.Get(Preference.SHOW_ITEM_LIST, true);
            if(ShowItemList){
                itemPaned.Child1.Visible = true;
            } else {
                itemPaned.Child1.Visible = false;
            }

            channelDialog = new ChannelDialog (this);
            addGroupDialog = new AddGroupDialog (this);
            preferencesDialog = new PreferencesDialog (this.Window);
            opmlDialog = new OpmlDialog (this.Window);
            opmlDialog.ChannelAdded += channel => mCollection.Add(channel, true);
            opmlDialog.ImportFinished += OpmlImportFinished;

        }