Exemple #1
0
        static void start_import(Gtk.FileChooserButton widget)
        {
            string type = widget.Title;
            string path = widget.Filename;

            GLib.IFile   old      = GLib.FileFactory.NewForPath(path);
            GLib.IFile   news     = GLib.FileFactory.NewForPath("./gtml" + old.Basename);
            GLib.KeyFile programs = new GLib.KeyFile();
            if (GLib.FileFactory.NewForPath("./data/programs.gkf").Exists)
            {
                programs.LoadFromFile("./data/programs.gkf", gkfflags);
            }
            if (type.Equals("Full"))
            {
                old.Move(news, fcflags, null, null);
                GLib.FileFactory.NewForPath(news.Path + "/profile").MakeDirectoryWithParents(null);
                create_stacks(news.Basename, news.Path);
            }
            else if (type.Equals("Partial"))
            {
                /*
                 * g_file_copy (old, new,cflags,NULL,NULL,NULL,NULL);
                 * GFileEnumerator *ennew = g_file_enumerate_children (old,"*",G_FILE_QUERY_INFO_NONE,NULL,NULL);
                 * while (TRUE) {
                 *      GFile *out;
                 *      GFileInfo *info;
                 *      if (!g_file_enumerator_iterate(ennew,&info,&out,NULL,NULL)) {
                 *              g_object_unref(ennew);
                 *              break;
                 *      } else {
                 *              if (!info) break;
                 *              gchar *name = g_file_info_get_attribute_as_string (info,G_FILE_ATTRIBUTE_STANDARD_NAME);
                 *              if ((g_strcmp0(name,".") && g_strcmp0(name,"..")) && name[0] != '.')	{
                 *                      gchar *path = g_file_get_path (out);
                 *                      GString *n = g_string_new (name);
                 *                      if (g_file_test(path,G_FILE_TEST_IS_DIR)){
                 *
                 *                              if (!gtk_stack_get_child_by_name (GTK_STACK(stack),n->str)) {
                 *                                      g_print("%s\n",n->str);
                 *                                      //gtk_stack_add_titled (GTK_STACK(stack),create_tabs(),n->str,n->str);
                 *                              }
                 *                                              //gtk_stack_set_visible_child_name (GTK_STACK(stack),n->str);
                 *                      }
                 *              }
                 *      }
                 *      if (!info) break;
                 * }
                 * g_file_make_directory_with_parents (g_file_new_for_path(g_strdup_printf("%s/profile",g_file_get_path(new))),NULL,NULL);
                 */
            }
            else if (type.Equals("Link"))
            {
                programs.SetString("Programs", old.Basename, old.Path);
                GLib.FileFactory.NewForPath(news.Path + "/profile").MakeDirectoryWithParents(null);
                create_stacks(old.Basename, old.Path);
            }

            programs.Save("./data/programs.gkf");

            /*
             * GNotification *inotification = g_notification_new ("Import Complete");
             * g_notification_set_priority (inotification,G_NOTIFICATION_PRIORITY_NORMAL);
             *      ... Data was here ...
             * g_notification_set_body (inotification,g_strdup_printf ("The %s import of the file located at %s is now complete.\nReturn to Mozilla Launcher to secure and launch it.", type,path));
             * g_application_send_notification (G_APPLICATION(app),"import-complete",inotification);
             */
        }