示例#1
0
 private bool RetryBackend()
 {
     try {
         if (backend != null && !backend.Configured)
         {
             backend.Cleanup();
             backend.Initialize(preferences);
         }
     } catch (Exception e) {
         Logger.Error("{0}", e.Message);
     }
     if (backend == null || !backend.Configured)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#2
0
        private void OnBackendComboBoxChanged(object sender, EventArgs args)
        {
            if (selectedBackend >= 0)
            {
                // TODO: Prompt the user and make sure they really want to change
                // which backend they are using.

                // Remove the existing backend's preference page
                if (backendPageId >= 0)
                {
                    notebook.RemovePage(backendPageId);
                    backendPageId = -1;
                    backendPage   = null;
                }

                // if yes (replace backend)
                if (backendComboMap.ContainsKey(selectedBackend))
                {
                    // Cleanup old backend
                    IBackend oldBackend = backendComboMap [selectedBackend];
                    Logger.Info("Cleaning up '{0}'...", oldBackend.Name);
                    try {
                        oldBackend.Cleanup();
                    } catch (Exception e) {
                        Logger.Warn("Exception cleaning up '{0}': {2}",
                                    oldBackend.Name,
                                    e.Message);
                    }

                    selectedBackend = -1;
                }
            }

            IBackend newBackend = null;

            if (backendComboMap.ContainsKey(backendComboBox.Active))
            {
                newBackend = backendComboMap [backendComboBox.Active];
            }

            // TODO: Set the new backend
            Application.Backend = newBackend;

            if (newBackend == null)
            {
                return;
            }

            selectedBackend = backendComboBox.Active;

            // Add a backend prefs page if one exists
            backendPage = newBackend.GetPreferencesWidget();
            if (backendPage != null)
            {
                backendPage.Show();
                Label l = new Label(GLib.Markup.EscapeText(newBackend.Name));
                l.UseMarkup    = false;
                l.UseUnderline = false;
                l.Show();
                backendPageId =
                    notebook.AppendPage(backendPage, l);

                // If the new backend is not configured, automatically switch
                // to the backend's preferences page
                if (!newBackend.Configured)
                {
                    notebook.Page = backendPageId;
                }
            }

            // Save the user preference
            Application.Preferences.Set(Preferences.CurrentBackend,
                                        newBackend.GetType().ToString());

            //categoriesToHide = BuildNewCategoryList ();
            //Application.Preferences.SetStringList (Preferences.HideInAllCategory,
            //									   categoriesToHide);
            RebuildCategoryTree();
        }