Exemplo n.º 1
0
void filebrowser_backend_create_dir(FilebrowserBackend *filebackend, gchar *filename, gchar *name, gboolean isdir){
  FilebrowserBackendDetails *directory = FILEBROWSER_BACKEND_GET_PRIVATE(filebackend);
  GFile *config;
  GError *error=NULL;
  gchar *filename_int;
  if (isdir){
      gchar *parent=filename_parent_uri(filename);
      filename_int= g_strdup_printf("%s/%s",parent,name);
      g_free(parent);
      config= g_file_new_for_commandline_arg(filename_int);
  } else {
      gchar *parent;
      if (filename) {
        parent=filename_parent_uri(filename);
      } else {
        parent=g_strdup(directory->current_folder);
      }
      filename_int= g_build_path (G_DIR_SEPARATOR_S, parent, name, NULL);
      g_free(parent);
      config=g_file_new_for_commandline_arg(filename_int);
  }
  gphpedit_debug_message(DEBUG_FILEBROWSER, "New directory:%s",filename_int);

  g_free(filename_int);
  if (!g_file_make_directory (config, directory->cancellable, &error)){
     g_print(_("Error creating folder. GIO error:%s\n"), error->message);
     g_error_free (error);
  }
  g_object_unref(config);
	filebrowser_backend_refresh_folder (filebackend);
}
Exemplo n.º 2
0
void on_open1_activate(GtkWidget *widget)
{
    GtkWidget *file_selection_box;
    gchar *folder;
    const gchar *last_opened_folder;
    // Create the selector widget
    file_selection_box = gtk_file_chooser_dialog_new("Please select files for editing", GTK_WINDOW(main_window.window),
                         GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);

    gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER(file_selection_box), FALSE);
    gtk_dialog_set_default_response (GTK_DIALOG(file_selection_box), GTK_RESPONSE_ACCEPT);
    //Add filters to the open dialog
    add_file_filters(GTK_FILE_CHOOSER(file_selection_box));
    last_opened_folder = get_preferences_manager_last_opened_folder(main_window.prefmg);
    gphpedit_debug_message(DEBUG_MAIN_WINDOW,"last_opened_folder: %s", last_opened_folder);
    /* opening of multiple files at once */
    gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(file_selection_box), TRUE);
    gchar *filename = (gchar *)document_get_filename(document_manager_get_current_document(main_window.docmg));
    if (filename && !document_get_untitled(document_manager_get_current_document(main_window.docmg))) {
        folder = filename_parent_uri(filename);
        gphpedit_debug_message(DEBUG_MAIN_WINDOW,"folder: %s", folder);
        gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER(file_selection_box),  folder);
        g_free(folder);
    }
    else if (last_opened_folder) {
        gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER(file_selection_box),  last_opened_folder);
    }

    if (gtk_dialog_run(GTK_DIALOG(file_selection_box)) == GTK_RESPONSE_ACCEPT) {
        open_file_ok(GTK_FILE_CHOOSER(file_selection_box));
    }
    gtk_widget_destroy(file_selection_box);
}
Exemplo n.º 3
0
void register_file_opened(gchar *filename)
{
  gphpedit_debug_message(DEBUG_DOC_MANAGER,"filename: %s\n", filename);
  gchar *folder = filename_parent_uri(filename);
  g_object_set (main_window.prefmg, "last_opened_folder", folder, NULL);
  g_free(folder);
}
Exemplo n.º 4
0
void filebrowser_backend_go_folder_up (FilebrowserBackend *fbback){
  FilebrowserBackendDetails *directory = FILEBROWSER_BACKEND_GET_PRIVATE(fbback);

  gchar *fullfolderpath=filename_parent_uri(directory->current_folder);
  gphpedit_debug_message(DEBUG_FILEBROWSER, "Up dir:%s\n",fullfolderpath);
  filebrowser_backend_update_folder (fbback,fullfolderpath); /*update with new uri */
  if (fullfolderpath) g_free(fullfolderpath);
}
Exemplo n.º 5
0
void filebrowser_backend_go_folder_home (FilebrowserBackend *fbback, gchar *filename){
//  FilebrowserBackendDetails *directory = FILEBROWSER_BACKEND_GET_PRIVATE(fbback);
  gchar *folderpath=NULL;
  if (filename_is_native(filename)){
    folderpath=filename_parent_uri(filename);
    gphpedit_debug_message(DEBUG_FILEBROWSER, "HOME dir:%s\n",folderpath);
  }
  filebrowser_backend_update_folder (fbback,folderpath);
  if (folderpath) g_free(folderpath);
}
Exemplo n.º 6
0
void document_manager_open_selected(DocumentManager *docmg)
{
  gphpedit_debug(DEBUG_DOC_MANAGER);
  if (!docmg) return ;
  DocumentManagerDetails *docmgdet = DOCUMENT_MANAGER_GET_PRIVATE(docmg);
  GSList *li;
  Document *document;
  gchar *ac_buffer;
  gchar *file;

  ac_buffer = documentable_get_current_selected_text(DOCUMENTABLE(docmgdet->current_document));
  if (!ac_buffer){
    for(li = docmgdet->editors; li!= NULL; li = g_slist_next(li)) {
      document = li->data;
      if (document) {
         gchar *filename = documentable_get_filename(DOCUMENTABLE(document));
         file = filename_parent_uri(filename);
         g_free(filename);
         gphpedit_debug_message(DEBUG_MAIN_WINDOW,"file: %s", filename);
         if (!strstr(ac_buffer, "://") && file) {
          gchar *filetemp= g_strdup_printf("%s/%s",file, ac_buffer);
          g_free(file);
          file=g_strdup(filetemp);
          g_free(filetemp);
        }
        else if (strstr(ac_buffer, "://")) {
            if (file) g_free(file);
            file = g_strdup(ac_buffer);
        }
        if(filename_file_exist(file)) document_manager_switch_to_file_or_open(docmg, file,0);
        if (file) g_free(file);
      }
    }
  }
  g_free(ac_buffer);
}