IterNChildren() public method

public IterNChildren ( ) : int
return int
Beispiel #1
0
        public int GetChildrenCount(TreePosition pos)
        {
            if (pos == null)
            {
                return(Tree.IterNChildren());
            }

            IterPos tpos = GetIterPos(pos);

            if (tpos.ChildrenCount != -1)
            {
                return(tpos.ChildrenCount);
            }

            return(tpos.ChildrenCount = Tree.IterNChildren(tpos.Iter));
        }
Beispiel #2
0
        static void RowsReorderedSignalCallback(IntPtr arg0, IntPtr arg1, IntPtr arg2, IntPtr arg3, IntPtr gch)
        {
            Gtk.RowsReorderedArgs args = new Gtk.RowsReorderedArgs();
            try {
                GLib.Signal sig = ((GCHandle)gch).Target as GLib.Signal;
                if (sig == null)
                {
                    throw new Exception("Unknown signal GC handle received " + gch);
                }

                TreeStore sender = GLib.Object.GetObject(arg0) as TreeStore;
                args.Args    = new object[3];
                args.Args[0] = arg1 == IntPtr.Zero ? null : (Gtk.TreePath)GLib.Opaque.GetOpaque(arg1, typeof(Gtk.TreePath), false);
                args.Args[1] = Gtk.TreeIter.New(arg2);
                int   child_cnt = arg2 == IntPtr.Zero ? sender.IterNChildren() : sender.IterNChildren((TreeIter)args.Args[1]);
                int[] new_order = new int [child_cnt];
                Marshal.Copy(arg3, new_order, 0, child_cnt);
                args.Args[2] = new_order;
                Gtk.RowsReorderedHandler handler = (Gtk.RowsReorderedHandler)sig.Handler;
                handler(sender, args);
            } catch (Exception e) {
                GLib.ExceptionManager.RaiseUnhandledException(e, false);
            }
        }
Beispiel #3
0
 static void rowsreordered_cb(IntPtr tree_model, IntPtr path_ptr, IntPtr iter_ptr, IntPtr new_order)
 {
     try {
         TreeStore store       = GLib.Object.GetObject(tree_model, false) as TreeStore;
         TreePath  path        = GLib.Opaque.GetOpaque(path_ptr, typeof(TreePath), false) as TreePath;
         TreeIter  iter        = TreeIter.New(iter_ptr);
         int       child_cnt   = store.IterNChildren(iter);
         int[]     child_order = new int [child_cnt];
         Marshal.Copy(new_order, child_order, 0, child_cnt);
         store.OnRowsReordered(path, iter, child_order);
     } catch (Exception e) {
         GLib.ExceptionManager.RaiseUnhandledException(e, true);
         // NOTREACHED: above call doesn't return
         throw e;
     }
 }
Beispiel #4
0
 public static int CountRows(Gtk.TreeStore ts)
 {
     return(ts.IterNChildren());
 }
Beispiel #5
0
        public void SyncStateChanged(SyncState state)
        {
            // This event handler will be called by the synchronization thread
            // so we have to use the delegate here to manipulate the GUI.
            Gtk.Application.Invoke(delegate {
                // FIXME: Change these strings to be user-friendly
                switch (state)
                {
                case SyncState.AcquiringLock:
                    ProgressText = Catalog.GetString("Acquiring sync lock...");
                    break;

                case SyncState.CommittingChanges:
                    ProgressText = Catalog.GetString("Committing changes...");
                    break;

                case SyncState.Connecting:
                    Title       = Catalog.GetString("Synchronizing Notes");
                    HeaderText  = Catalog.GetString("Synchronizing your notes...");
                    MessageText = Catalog.GetString("This may take a while, kick back and enjoy!");
                    model.Clear();
                    ProgressText         = Catalog.GetString("Connecting to the server...");
                    progressBar.Fraction = 0;
                    progressBar.Show();
                    progressLabel.Show();
                    break;

                case SyncState.DeleteServerNotes:
                    ProgressText = Catalog.GetString("Deleting notes off of the server...");
                    progressBar.Pulse();
                    break;

                case SyncState.Downloading:
                    ProgressText = Catalog.GetString("Downloading new/updated notes...");
                    progressBar.Pulse();
                    break;

                case SyncState.Idle:
                    GLib.Source.Remove(progressBarTimeoutId);
                    progressBarTimeoutId = 0;
                    progressBar.Fraction = 0;
                    progressBar.Hide();
                    progressLabel.Hide();
                    closeButton.Sensitive = true;
                    break;

                case SyncState.Locked:
                    Title        = Catalog.GetString("Server Locked");
                    HeaderText   = Catalog.GetString("Server is locked");
                    MessageText  = Catalog.GetString("One of your other computers is currently synchronizing.  Please wait 2 minutes and try again.");
                    ProgressText = string.Empty;
                    break;

                case SyncState.PrepareDownload:
                    ProgressText = Catalog.GetString("Preparing to download updates from server...");
                    break;

                case SyncState.PrepareUpload:
                    ProgressText = Catalog.GetString("Preparing to upload updates to server...");
                    break;

                case SyncState.Uploading:
                    ProgressText = Catalog.GetString("Uploading notes to server...");
                    break;

                case SyncState.Failed:
                    Title        = Catalog.GetString("Synchronization Failed");
                    HeaderText   = Catalog.GetString("Failed to synchronize");
                    MessageText  = Catalog.GetString("Could not synchronize notes.  Check the details below and try again.");
                    ProgressText = string.Empty;
                    break;

                case SyncState.Succeeded:
                    int count              = 0;
                    count                 += model.IterNChildren();
                    Title                  = Catalog.GetString("Synchronization Complete");
                    HeaderText             = Catalog.GetString("Synchronization is complete");
                    string numNotesUpdated =
                        string.Format(Catalog.GetPluralString("{0} note updated.",
                                                              "{0} notes updated.",
                                                              count),
                                      count);
                    MessageText = numNotesUpdated + "  " +
                                  Catalog.GetString("Your notes are now up to date.");
                    ProgressText = string.Empty;
                    break;

                case SyncState.UserCancelled:
                    Title        = Catalog.GetString("Synchronization Canceled");
                    HeaderText   = Catalog.GetString("Synchronization was canceled");
                    MessageText  = Catalog.GetString("You canceled the synchronization.  You may close the window now.");
                    ProgressText = string.Empty;
                    break;

                case SyncState.NoConfiguredSyncService:
                    Title        = Catalog.GetString("Synchronization Not Configured");
                    HeaderText   = Catalog.GetString("Synchronization is not configured");
                    MessageText  = Catalog.GetString("Please configure synchronization in the preferences dialog.");
                    ProgressText = string.Empty;
                    break;

                case SyncState.SyncServerCreationFailed:
                    Title        = Catalog.GetString("Synchronization Service Error");
                    HeaderText   = Catalog.GetString("Service error");
                    MessageText  = Catalog.GetString("Error connecting to the synchronization service.  Please try again.");
                    ProgressText = string.Empty;
                    break;
                }
            });
        }