EditBookmarksDialog::EditBookmarksDialog(FmBookmarks* bookmarks, QWidget* parent, Qt::WindowFlags f): QDialog(parent, f), ui(new Ui::EditBookmarksDialog()), bookmarks_(FM_BOOKMARKS(g_object_ref(bookmarks))) { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); // auto delete on close // load bookmarks GList* allBookmarks = fm_bookmarks_get_all(bookmarks_); for(GList* l = allBookmarks; l; l = l->next) { FmBookmarkItem* bookmark = reinterpret_cast<FmBookmarkItem*>(l->data); QTreeWidgetItem* item = new QTreeWidgetItem(); char* path_str = fm_path_display_name(bookmark->path, false); item->setData(0, Qt::DisplayRole, QString::fromUtf8(bookmark->name)); item->setData(1, Qt::DisplayRole, QString::fromUtf8(path_str)); item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsDragEnabled|Qt::ItemIsEnabled); g_free(path_str); ui->treeWidget->addTopLevelItem(item); } g_list_free_full(allBookmarks, (GDestroyNotify)fm_bookmark_item_unref); connect(ui->addItem, &QPushButton::clicked, this, &EditBookmarksDialog::onAddItem); connect(ui->removeItem, &QPushButton::clicked, this, &EditBookmarksDialog::onRemoveItem); }
static void fm_path_entry_paste_and_go(GtkMenuItem *menuitem, GtkEntry *entry) { GtkClipboard* clipboard = gtk_clipboard_get_for_display( gtk_widget_get_display (GTK_WIDGET (menuitem)),GDK_SELECTION_CLIPBOARD); gchar* full_path = gtk_clipboard_wait_for_text(clipboard); if (full_path) { FmPathEntryPrivate *priv = FM_PATH_ENTRY_GET_PRIVATE(entry); if(priv->path) fm_path_unref(priv->path); /* special handling for home dir */ if(full_path[0] == '~' && full_path[1] == G_DIR_SEPARATOR) priv->path = fm_path_new_relative(fm_path_get_home(), full_path + 2); else if(full_path[0] == '~' && full_path[1] == 0) priv->path = fm_path_ref(fm_path_get_home()); else priv->path = fm_path_new_for_str(full_path); gchar * disp_name = fm_path_display_name(priv->path, FALSE); gtk_entry_set_text(entry, disp_name); g_free(disp_name); gtk_editable_set_position(GTK_EDITABLE(entry), -1); g_free(full_path); fm_path_entry_activate(FM_PATH_ENTRY(entry)); } }
static void on_show_history_menu(GtkMenuToolButton* btn, FmMainWin* win) { GtkMenuShell* menu = (GtkMenuShell*)gtk_menu_tool_button_get_menu(btn); GList* l; GList* cur = fm_nav_history_get_cur_link(win->nav_history); /* delete old items */ gtk_container_foreach(GTK_CONTAINER(menu), (GtkCallback)gtk_widget_destroy, NULL); for(l = fm_nav_history_list(win->nav_history); l; l=l->next) { const FmNavHistoryItem* item = (FmNavHistoryItem*)l->data; FmPath* path = item->path; char* str = fm_path_display_name(path, TRUE); GtkMenuItem* mi; if( l == cur ) { mi = gtk_check_menu_item_new_with_label(str); gtk_check_menu_item_set_draw_as_radio(GTK_CHECK_MENU_ITEM(mi), TRUE); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi), TRUE); } else mi = gtk_menu_item_new_with_label(str); g_free(str); g_object_set_qdata_full(G_OBJECT(mi), fm_qdata_id, l, NULL); g_signal_connect(mi, "activate", G_CALLBACK(on_history_item), win); gtk_menu_shell_append(menu, mi); } gtk_widget_show_all( GTK_WIDGET(menu) ); }
static void fm_path_entry_on_activate(GtkEntry *entry, gpointer user_data) { FmPathEntryPrivate *priv = FM_PATH_ENTRY_GET_PRIVATE(entry); const char* full_path; char* disp_name; /* convert current path string to FmPath here */ full_path = gtk_entry_get_text(entry); if(priv->path) fm_path_unref(priv->path); /* special handling for home dir */ if(full_path[0] == '~' && full_path[1] == G_DIR_SEPARATOR) priv->path = fm_path_new_relative(fm_path_get_home(), full_path + 2); else if(full_path[0] == '~' && full_path[1] == 0) priv->path = fm_path_ref(fm_path_get_home()); else priv->path = fm_path_new_for_str(full_path); disp_name = fm_path_display_name(priv->path, FALSE); gtk_entry_set_text(entry, disp_name); g_free(disp_name); gtk_editable_set_position(GTK_EDITABLE(entry), -1); }
void fm_path_entry_set_model(FmPathEntry *entry, FmPath* path, FmFolderModel* model) { FmPathEntryPrivate *priv = FM_PATH_ENTRY_GET_PRIVATE(entry); /* FIXME: should we use UTF-8 encoded display name here? */ gchar *path_str = fm_path_display_name(path, FALSE); if(priv->path) fm_path_unref(priv->path); priv->path = fm_path_ref(path); if( priv->model ) g_object_unref( priv->model ); if( priv->completion_model ) g_object_unref(priv->completion_model); if(model) { priv->model = g_object_ref(model); priv->completion_model = g_object_ref(model); gtk_entry_set_completion(GTK_ENTRY(entry), priv->completion); } else { priv->model = NULL; priv->completion_model = NULL; gtk_entry_set_completion(GTK_ENTRY(entry), NULL); } gtk_entry_completion_set_model( priv->completion, (GtkTreeModel*)priv->completion_model ); priv->in_change = TRUE; gtk_entry_set_text(GTK_ENTRY(entry), path_str); priv->in_change = FALSE; gtk_editable_set_position(GTK_EDITABLE(entry), -1); g_free(path_str); }
static void on_files_added(FmFolder* folder, GSList* files, gpointer user_data) { GSList* l; for(l = files; l; l = l->next) { FmFileInfo* file = FM_FILE_INFO(l->data); FmPath* path = fm_file_info_get_path(file); char* path_str = fm_path_display_name(path, FALSE); g_printf("file found: %s\n", path_str); } }
void fm_path_entry_set_path(FmPathEntry *entry, FmPath* path) { FmPathEntryPrivate *priv = FM_PATH_ENTRY_GET_PRIVATE(entry); char* disp_path; if(priv->path) fm_path_unref(priv->path); priv->path = fm_path_ref(path); disp_path = fm_path_display_name(path, FALSE); /* FIXME: blocks changed signal */ gtk_entry_set_text(entry, disp_path); g_free(disp_path); }
static void fm_tab_page_update_label(FmTabPage* page, FmPath* path) { char * disp_name = fm_path_display_basename(path); /* if (page->pattern && *page->pattern) { char * s = g_strdup_printf(_("[%s] %s"), page->pattern, disp_name); g_free(disp_name); disp_name = s; }*/ fm_tab_label_set_text(page->tab_label, disp_name); g_free(disp_name); char * disp_path = fm_path_display_name(path, FALSE); fm_tab_label_set_tooltip_text(FM_TAB_LABEL(page->tab_label), disp_path); g_free(disp_path); }
static void fm_tab_page_chdir_without_history(FmTabPage* page, FmPath* path) { FmFolderView* folder_view = FM_FOLDER_VIEW(page->folder_view); FmFolder* folder = fm_folder_view_get_folder(folder_view); char * disp_path = fm_path_display_name(path, FALSE); fm_tab_label_set_tooltip_text(FM_TAB_LABEL(page->tab_label), disp_path); g_free(disp_path); char* disp_name = fm_path_display_basename(path); fm_tab_label_set_text(FM_TAB_LABEL(page->tab_label), disp_name); g_free(disp_name); /* disconnect from previous folder */ disconnect_folder(page, folder); /* chdir to a new folder */ fm_folder_view_chdir(folder_view, path); folder = fm_folder_view_get_folder(folder_view); if(folder) { g_signal_connect(folder, "fs-info", G_CALLBACK(on_folder_fs_info), page); // on_folder_fs_info(folder, win); fm_folder_query_filesystem_info(folder); } fm_side_pane_chdir(FM_SIDE_PANE(page->side_pane), path); /* destroy the page when the folder is unmounted or deleted. */ g_signal_connect_swapped(folder, "unmount", G_CALLBACK(gtk_widget_destroy), page); g_signal_connect_swapped(folder, "removed", G_CALLBACK(gtk_widget_destroy), page); g_signal_connect(folder, "content-changed", G_CALLBACK(on_folder_content_changed), page); g_signal_connect(folder, "fs-info", G_CALLBACK(on_folder_fs_info), page); /* tell the world that our current working directory is changed */ g_signal_emit(page, signals[CHDIR], 0, path); }
/** * fm_get_user_input_path * @parent: a window to place dialog over it * @title: title for dialog window * @msg: the message to present to the user * @default_path: the default path * * Presents the message to user and retrieves entered path string. * Returned data should be freed with fm_path_unref() after usage. * * Returns: (transfer full): entered text. * * Since: 0.1.0 * * Deprecated: 1.2.0: */ FmPath* fm_get_user_input_path(GtkWindow* parent, const char* title, const char* msg, FmPath* default_path) { GtkDialog* dlg = _fm_get_user_input_dialog( parent, title, msg); GtkEntry* entry = GTK_ENTRY(gtk_entry_new()); char *str, *path_str = NULL; FmPath* path; gtk_entry_set_activates_default(entry, TRUE); if(default_path) { path_str = fm_path_display_name(default_path, FALSE); gtk_entry_set_text(entry, path_str); } str = _fm_user_input_dialog_run(dlg, entry, NULL); path = fm_path_new_for_str(str); g_free(path_str); g_free(str); return path; }
// FIXME_pcm: maybe we can support different encoding for different mount points? char *fm_path_display_name (FmPath *path, gboolean human_readable) { char *disp; if (human_readable) { if (G_LIKELY (path->parent)) { char *disp_parent = fm_path_display_name (path->parent, TRUE); char *disp_base = fm_path_display_basename (path); disp = g_build_filename (disp_parent, disp_base, NULL); g_free (disp_parent); g_free (disp_base); } else disp = fm_path_display_basename (path); } else { char *str = fm_path_to_str (path); disp = g_filename_display_name (str); g_free (str); } return disp; }
static gboolean on_show_dlg (FmProgressDisplay *data) { GtkBuilder *builder = gtk_builder_new (); GtkWidget *to, *to_label; FmPath *dest; const char *title = NULL; GtkTextTagTable *tag_table = gtk_text_tag_table_new (); gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE); gtk_builder_add_from_string (builder, PROGRESS_DLG, -1, NULL); data->dlg = (GtkWidget*) gtk_builder_get_object (builder, "dlg"); g_signal_connect (data->dlg, "response", (GCallback) on_response, data); to_label = (GtkWidget*) gtk_builder_get_object (builder, "to_label"); to = (GtkWidget*) gtk_builder_get_object (builder, "dest"); data->icon = (GtkWidget*) gtk_builder_get_object (builder, "icon"); data->msg = (GtkWidget*) gtk_builder_get_object (builder, "msg"); data->act = (GtkWidget*) gtk_builder_get_object (builder, "action"); data->src = (GtkWidget*) gtk_builder_get_object (builder, "src"); data->dest = (GtkWidget*) gtk_builder_get_object (builder, "dest"); data->current = (GtkWidget*) gtk_builder_get_object (builder, "current"); data->progress = (GtkWidget*) gtk_builder_get_object (builder, "progress"); data->error_pane = (GtkWidget*) gtk_builder_get_object (builder, "error_pane"); data->error_msg = (GtkWidget*) gtk_builder_get_object (builder, "error_msg"); data->remaining_time = (GtkWidget*) gtk_builder_get_object (builder, "remaining_time"); data->bold_tag = gtk_text_tag_new ("bold"); g_object_set (data->bold_tag, "weight", PANGO_WEIGHT_BOLD, NULL); gtk_text_tag_table_add (tag_table, data->bold_tag); data->error_buf = gtk_text_buffer_new (tag_table); g_object_unref (tag_table); gtk_text_view_set_buffer (GTK_TEXT_VIEW (data->error_msg), data->error_buf); g_object_unref (builder); // set the src label if (data->job->srcs) { GList *l = fm_list_peek_head_link (data->job->srcs); int i; char *disp; FmPath *path; GString *str = g_string_sized_new (512); path = FM_PATH (l->data); disp = fm_path_display_basename (path); g_string_assign (str, disp); g_free (disp); for ( i =1, l=l->next; i < 10 && l; l=l->next, ++i) { path = FM_PATH (l->data); g_string_append (str, _(", ")); disp = fm_path_display_basename (path); g_string_append (str, disp); g_free (disp); } if (l) g_string_append (str, "..."); gtk_label_set_text (GTK_LABEL (data->src), str->str); g_string_free (str, TRUE); } // FIXME_pcm: use accessor functions instead switch (data->job->type) { case FM_FILE_OP_MOVE: title = _("Moving files"); break; case FM_FILE_OP_COPY: title = _("Copying files"); break; case FM_FILE_OP_TRASH: title = _("Trashing files"); break; case FM_FILE_OP_DELETE: title = _("Deleting files"); break; case FM_FILE_OP_LINK: title = _("Creating symlinks"); break; case FM_FILE_OP_CHANGE_ATTR: title = _("Changing file attributes"); break; } if (title) { gtk_window_set_title (GTK_WINDOW (data->dlg), title); gtk_label_set_text (GTK_LABEL (data->act), title); } if (dest = fm_file_ops_job_get_dest (data->job)) { char *dest_str = fm_path_display_name (dest, TRUE); gtk_label_set_text (GTK_LABEL (to), dest_str); g_free (dest_str); } else { gtk_widget_destroy (data->dest); gtk_widget_destroy (to_label); } gtk_window_present (GTK_WINDOW (data->dlg)); data->update_timeout = g_timeout_add (500, (GSourceFunc)on_update_dlg, data); data->delay_timeout = 0; return FALSE; }
static gboolean on_show_dlg(gpointer user_data) { FmProgressDisplay* data = (FmProgressDisplay*)user_data; GtkBuilder* builder; GtkLabel* to; GtkWidget *to_label; FmPath* dest; const char* title = NULL; GtkTextTagTable* tag_table; GDK_THREADS_ENTER(); if(g_source_is_destroyed(g_main_current_source())) goto _end; builder = gtk_builder_new(); tag_table = gtk_text_tag_table_new(); gtk_builder_set_translation_domain(builder, GETTEXT_PACKAGE); gtk_builder_add_from_file(builder, PACKAGE_UI_DIR "/progress.ui", NULL); data->dlg = GTK_DIALOG(gtk_builder_get_object(builder, "dlg")); g_object_weak_ref(G_OBJECT(data->dlg), on_progress_dialog_destroy, data); g_signal_connect(data->dlg, "response", G_CALLBACK(on_response), data); /* FIXME: connect to "close" signal */ to_label = (GtkWidget*)gtk_builder_get_object(builder, "to_label"); to = GTK_LABEL(gtk_builder_get_object(builder, "dest")); data->icon = GTK_IMAGE(gtk_builder_get_object(builder, "icon")); data->msg = GTK_LABEL(gtk_builder_get_object(builder, "msg")); data->act = GTK_LABEL(gtk_builder_get_object(builder, "action")); data->src = GTK_LABEL(gtk_builder_get_object(builder, "src")); data->dest = (GtkWidget*)gtk_builder_get_object(builder, "dest"); data->current = GTK_LABEL(gtk_builder_get_object(builder, "current")); data->progress = GTK_PROGRESS_BAR(gtk_builder_get_object(builder, "progress")); data->error_pane = (GtkWidget*)gtk_builder_get_object(builder, "error_pane"); data->error_msg = GTK_TEXT_VIEW(gtk_builder_get_object(builder, "error_msg")); data->remaining_time = GTK_LABEL(gtk_builder_get_object(builder, "remaining_time")); data->bold_tag = gtk_text_tag_new("bold"); g_object_set(data->bold_tag, "weight", PANGO_WEIGHT_BOLD, NULL); gtk_text_tag_table_add(tag_table, data->bold_tag); data->error_buf = gtk_text_buffer_new(tag_table); g_object_unref(tag_table); gtk_text_view_set_buffer(data->error_msg, data->error_buf); g_object_unref(builder); /* set the src label */ /* FIXME: direct access to job struct! */ if(data->job->srcs) { GList* l = fm_path_list_peek_head_link(data->job->srcs); int i; char* disp; FmPath* path; GString* str = g_string_sized_new(512); path = FM_PATH(l->data); disp = fm_path_display_basename(path); g_string_assign(str, disp); g_free(disp); for( i =1, l=l->next; i < 10 && l; l=l->next, ++i) { path = FM_PATH(l->data); g_string_append(str, _(", ")); disp = fm_path_display_basename(path); g_string_append(str, disp); g_free(disp); } if(l) g_string_append(str, "..."); gtk_label_set_text(data->src, str->str); g_string_free(str, TRUE); } /* FIXME: use accessor functions instead */ /* FIXME: direct access to job struct! */ switch(data->job->type) { case FM_FILE_OP_MOVE: title = _("Moving files"); break; case FM_FILE_OP_COPY: title = _("Copying files"); break; case FM_FILE_OP_TRASH: title = _("Trashing files"); break; case FM_FILE_OP_DELETE: title = _("Deleting files"); break; case FM_FILE_OP_LINK: title = _("Creating symlinks"); break; case FM_FILE_OP_CHANGE_ATTR: title = _("Changing file attributes"); break; case FM_FILE_OP_UNTRASH: break; case FM_FILE_OP_NONE: ; } if(title) { gtk_window_set_title(GTK_WINDOW(data->dlg), title); gtk_label_set_text(data->act, title); } dest = fm_file_ops_job_get_dest(data->job); if(dest) { char* dest_str = fm_path_display_name(dest, TRUE); gtk_label_set_text(to, dest_str); g_free(dest_str); } else { gtk_widget_destroy(data->dest); gtk_widget_destroy(to_label); } gtk_window_set_transient_for(GTK_WINDOW(data->dlg), data->parent); gtk_window_present(GTK_WINDOW(data->dlg)); data->update_timeout = g_timeout_add(500, on_update_dlg, data); data->delay_timeout = 0; _end: GDK_THREADS_LEAVE(); return FALSE; }
void FilePropsDialog::initGeneralPage() { // update UI if(singleType) { // all files are of the same mime-type FmIcon* icon = NULL; // FIXME: handle custom icons for some files // FIXME: display special property pages for special files or // some specified mime-types. if(singleFile) { // only one file is selected. icon = fm_file_info_get_icon(fileInfo); } if(mimeType) { if(!icon) // get an icon from mime type if needed icon = fm_mime_type_get_icon(mimeType); ui->fileType->setText(QString::fromUtf8(fm_mime_type_get_desc(mimeType))); ui->mimeType->setText(QString::fromUtf8(fm_mime_type_get_type(mimeType))); } if(icon) { ui->iconButton->setIcon(IconTheme::icon(icon)); } if(singleFile && fm_file_info_is_symlink(fileInfo)) { ui->target->setText(QString::fromUtf8(fm_file_info_get_target(fileInfo))); } else { ui->target->hide(); ui->targetLabel->hide(); } } // end if(singleType) else { // not singleType, multiple files are selected at the same time ui->fileType->setText(tr("Files of different types")); ui->target->hide(); ui->targetLabel->hide(); } // FIXME: check if all files has the same parent dir, mtime, or atime if(singleFile) { // only one file is selected FmPath* parent_path = fm_path_get_parent(fm_file_info_get_path(fileInfo)); char* parent_str = parent_path ? fm_path_display_name(parent_path, true) : NULL; ui->fileName->setText(QString::fromUtf8(fm_file_info_get_disp_name(fileInfo))); if(parent_str) { ui->location->setText(QString::fromUtf8(parent_str)); g_free(parent_str); } else ui->location->clear(); ui->lastModified->setText(QString::fromUtf8(fm_file_info_get_disp_mtime(fileInfo))); // FIXME: need to encapsulate this in an libfm API. time_t atime; struct tm tm; atime = fm_file_info_get_atime(fileInfo); localtime_r(&atime, &tm); char buf[128]; strftime(buf, sizeof(buf), "%x %R", &tm); ui->lastAccessed->setText(QString::fromUtf8(buf)); } else { ui->fileName->setText(tr("Multiple Files")); ui->fileName->setEnabled(false); } initApplications(); // init applications combo box // calculate total file sizes fileSizeTimer = new QTimer(this); connect(fileSizeTimer, &QTimer::timeout, this, &FilePropsDialog::onFileSizeTimerTimeout); fileSizeTimer->start(600); g_signal_connect(deepCountJob, "finished", G_CALLBACK(onDeepCountJobFinished), this); gboolean ret = fm_job_run_async(FM_JOB(deepCountJob)); }
static void update_ui (FmFilePropData *data) { GtkImage *img = (GtkImage*) data->icon; if ( data->single_type ) // all files are of the same mime-type { GIcon *icon = NULL; // FIXME_pcm: handle custom icons for some files /* FIXME_pcm: display special property pages for special files or * some specified mime-types. */ if ( data->single_file ) // only one file is selected. { FmFileInfo *file_info = (FmFileInfo*)fm_list_peek_head (data->files); icon = fm_file_info_get_gicon (file_info); } if (data->mime_type) { if (!icon) { FmIcon *ficon = fm_mime_type_get_icon (data->mime_type); if (ficon) icon = ficon->gicon; } gtk_label_set_text (GTK_LABEL (data->type), fm_mime_type_get_desc (data->mime_type)); } if (icon) gtk_image_set_from_gicon (img, icon, GTK_ICON_SIZE_DIALOG); if ( data->single_file && fm_file_info_is_symlink (data->file_info) ) { gtk_widget_show (data->target_label); gtk_widget_show (data->target); gtk_label_set_text (GTK_LABEL (data->target), fm_file_info_get_target (data->file_info)); // gtk_label_set_text (data->type, fm_mime_type_get_desc (data->mime_type)); } else { gtk_widget_destroy (data->target_label); gtk_widget_destroy (data->target); } } else { gtk_image_set_from_stock (img, GTK_STOCK_DND_MULTIPLE, GTK_ICON_SIZE_DIALOG); gtk_widget_set_sensitive (data->name, FALSE); gtk_label_set_text (GTK_LABEL (data->type), _("Files of different types")); gtk_widget_destroy (data->target_label); gtk_widget_destroy (data->target); gtk_widget_destroy (data->open_with_label); gtk_widget_destroy (data->open_with); data->open_with = data->open_with_label = NULL; } // FIXME_pcm: check if all files has the same parent dir, mtime, or atime if ( data->single_file ) { char buf[128]; FmPath *parent = fm_path_get_parent (fm_file_info_get_path (data->file_info)); char *parent_str = parent ? fm_path_display_name (parent, TRUE) : NULL; gtk_entry_set_text (GTK_ENTRY (data->name), fm_file_info_get_disp_name (data->file_info)); if (parent_str) { gtk_label_set_text (GTK_LABEL (data->dir), parent_str); g_free (parent_str); } else gtk_label_set_text (GTK_LABEL (data->dir), ""); gtk_label_set_text (GTK_LABEL (data->mtime), fm_file_info_get_disp_mtime (data->file_info)); // FIXME_pcm: need to encapsulate this in an libfm API. strftime ( buf, sizeof ( buf ), "%x %R", localtime ( &data->file_info->atime ) ); gtk_label_set_text (GTK_LABEL (data->atime), buf); } else { gtk_entry_set_text (GTK_ENTRY (data->name), _("Multiple Files")); gtk_widget_set_sensitive (data->name, FALSE); } update_permissions (data); on_timeout (data); }
static gboolean _on_show_dlg(gpointer user_data) { FmProgressDisplay* data = (FmProgressDisplay*)user_data; GtkBuilder* builder; GtkLabel* to; GtkWidget *to_label; FmPath* dest; const char* title = NULL; GtkTextTagTable* tag_table; builder = gtk_builder_new(); tag_table = gtk_text_tag_table_new(); gtk_builder_set_translation_domain(builder, GETTEXT_PACKAGE); gtk_builder_add_from_file(builder, PACKAGE_UI_DIR "/progress.ui", NULL); data->dlg = GTK_DIALOG(gtk_builder_get_object(builder, "dlg")); g_object_weak_ref(G_OBJECT(data->dlg), on_progress_dialog_destroy, data); g_signal_connect(data->dlg, "response", G_CALLBACK(on_response), data); /* FIXME: connect to "close" signal */ to_label = (GtkWidget*)gtk_builder_get_object(builder, "to_label"); to = GTK_LABEL(gtk_builder_get_object(builder, "dest")); data->icon = GTK_IMAGE(gtk_builder_get_object(builder, "icon")); data->msg = GTK_LABEL(gtk_builder_get_object(builder, "msg")); data->act = GTK_LABEL(gtk_builder_get_object(builder, "action")); data->src = GTK_LABEL(gtk_builder_get_object(builder, "src")); data->dest = (GtkWidget*)gtk_builder_get_object(builder, "dest"); data->current = GTK_LABEL(gtk_builder_get_object(builder, "current")); data->progress = GTK_PROGRESS_BAR(gtk_builder_get_object(builder, "progress")); data->error_pane = (GtkWidget*)gtk_builder_get_object(builder, "error_pane"); data->error_msg = GTK_TEXT_VIEW(gtk_builder_get_object(builder, "error_msg")); data->data_transferred = GTK_LABEL(gtk_builder_get_object(builder, "data_transferred")); data->data_transferred_label = GTK_LABEL(gtk_builder_get_object(builder, "data_transferred_label")); data->remaining_time = GTK_LABEL(gtk_builder_get_object(builder, "remaining_time")); data->remaining_time_label = GTK_LABEL(gtk_builder_get_object(builder, "remaining_time_label")); data->cancel = GTK_BUTTON(gtk_builder_get_object(builder, "cancel")); data->suspend = GTK_BUTTON(gtk_dialog_add_button(data->dlg, _("_Pause"), 1)); gtk_button_set_use_stock(data->suspend, FALSE); gtk_button_set_use_underline(data->suspend, TRUE); gtk_button_set_image(data->suspend, gtk_image_new_from_stock(GTK_STOCK_MEDIA_PAUSE, GTK_ICON_SIZE_BUTTON)); gtk_dialog_set_alternative_button_order(data->dlg, 1, GTK_RESPONSE_CANCEL, -1); data->bold_tag = gtk_text_tag_new("bold"); g_object_set(data->bold_tag, "weight", PANGO_WEIGHT_BOLD, NULL); gtk_text_tag_table_add(tag_table, data->bold_tag); data->error_buf = gtk_text_buffer_new(tag_table); g_object_unref(tag_table); gtk_text_view_set_buffer(data->error_msg, data->error_buf); gtk_widget_hide(GTK_WIDGET(data->icon)); g_object_unref(builder); /* set the src label */ /* FIXME: direct access to job struct! */ if(data->job->srcs) { GList* l = fm_path_list_peek_head_link(data->job->srcs); int i; char* disp; FmPath* path; GString* str = g_string_sized_new(512); path = FM_PATH(l->data); disp = fm_path_display_basename(path); g_string_assign(str, disp); g_free(disp); for( i =1, l=l->next; i < 10 && l; l=l->next, ++i) { path = FM_PATH(l->data); g_string_append(str, _(", ")); disp = fm_path_display_basename(path); g_string_append(str, disp); g_free(disp); } if(l) g_string_append(str, "..."); gtk_label_set_text(data->src, str->str); gtk_widget_set_tooltip_text(GTK_WIDGET(data->src), str->str); g_string_free(str, TRUE); } /* FIXME: use accessor functions instead */ /* FIXME: direct access to job struct! */ switch(data->job->type) { /* we set title here if text is complex so may be different from the op_text when is translated to other languages */ case FM_FILE_OP_MOVE: /* translators: it is part of "Moving files:" or "Moving xxx.txt" */ data->op_text = _("Moving"); break; case FM_FILE_OP_COPY: /* translators: it is part of "Copying files:" or "Copying xxx.txt" */ data->op_text = _("Copying"); break; case FM_FILE_OP_TRASH: /* translators: it is part of "Trashing files:" or "Trashing xxx.txt" */ data->op_text = _("Trashing"); break; case FM_FILE_OP_DELETE: /* translators: it is part of "Deleting files:" or "Deleting xxx.txt" */ data->op_text = _("Deleting"); break; case FM_FILE_OP_LINK: /* translators: it is part of "Creating link /path/xxx.txt" */ data->op_text = _("Creating link"); /* translators: 'In:' string is followed by destination folder path */ gtk_label_set_markup(GTK_LABEL(to_label), _("<b>In:</b>")); title = _("Creating links to files"); /* NOTE: on creating single symlink or shortcut all operation is done in single I/O therefore it should fit into 0.5s timeout and progress window will never be shown */ break; case FM_FILE_OP_CHANGE_ATTR: /* translators: it is part of "Changing attributes of xxx.txt" */ data->op_text = _("Changing attributes of"); title = _("Changing attributes of files"); /* NOTE: the same about single symlink is appliable here so there is no need to add never used string for translation */ break; case FM_FILE_OP_UNTRASH: /* translators: it is part of "Restoring files:" or "Restoring xxx.txt" */ data->op_text = _("Restoring"); break; case FM_FILE_OP_NONE: ; } data->str = g_string_sized_new(64); if (title) gtk_window_set_title(GTK_WINDOW(data->dlg), title); else { /* note to translators: resulting string is such as "Deleting files" */ g_string_printf(data->str, _("%s files"), data->op_text); gtk_window_set_title(GTK_WINDOW(data->dlg), data->str->str); } gtk_label_set_markup(data->msg, _("<b>File operation is in progress...</b>")); gtk_widget_show(GTK_WIDGET(data->msg)); if (title) /* we already know the exact string */ g_string_printf(data->str, "<b>%s:</b>", title); else if (fm_path_list_get_length(data->job->srcs) == 1) /* note to translators: resulting string is such as "Deleting file" */ g_string_printf(data->str, _("<b>%s file:</b>"), data->op_text); else /* note to translators: resulting string is such as "Deleting files" */ g_string_printf(data->str, _("<b>%s files:</b>"), data->op_text); gtk_label_set_markup(data->act, data->str->str); dest = fm_file_ops_job_get_dest(data->job); if(dest) { char* dest_str = fm_path_display_name(dest, TRUE); gtk_label_set_text(to, dest_str); gtk_widget_set_tooltip_text(GTK_WIDGET(data->dest), dest_str); g_free(dest_str); } else { gtk_widget_destroy(data->dest); gtk_widget_destroy(to_label); } gtk_window_set_transient_for(GTK_WINDOW(data->dlg), data->parent); gtk_window_present(GTK_WINDOW(data->dlg)); data->delay_timeout = 0; return FALSE; }
QString TabPage::pathName() { char* disp_path = fm_path_display_name(path(), TRUE); QString ret = QString::fromUtf8(disp_path); g_free(disp_path); return ret; }
static gboolean on_show_dlg(FmProgressDisplay* data) { GtkBuilder* builder = gtk_builder_new(); GtkWidget* to, *to_label; FmPath* dest; const char* title = NULL; gtk_builder_set_translation_domain(builder, GETTEXT_PACKAGE); gtk_builder_add_from_file(builder, PACKAGE_UI_DIR "/progress.ui", NULL); data->dlg = (GtkWidget*)gtk_builder_get_object(builder, "dlg"); g_signal_connect(data->dlg, "response", on_response, data); to_label = (GtkWidget*)gtk_builder_get_object(builder, "to_label"); to = (GtkWidget*)gtk_builder_get_object(builder, "dest"); data->act = (GtkWidget*)gtk_builder_get_object(builder, "action"); data->src = (GtkWidget*)gtk_builder_get_object(builder, "src"); data->dest = (GtkWidget*)gtk_builder_get_object(builder, "dest"); data->current = (GtkWidget*)gtk_builder_get_object(builder, "current"); data->progress = (GtkWidget*)gtk_builder_get_object(builder, "progress"); g_object_unref(builder); /* FIXME: use accessor functions instead */ switch(data->job->type) { case FM_FILE_OP_MOVE: title = _("Moving files"); break; case FM_FILE_OP_COPY: title = _("Copying files"); break; case FM_FILE_OP_TRASH: title = _("Trashing files"); break; case FM_FILE_OP_DELETE: title = _("Deleting files"); break; case FM_FILE_OP_LINK: title = _("Creating symlinks"); break; case FM_FILE_OP_CHANGE_ATTR: title = _("Changing file attributes"); break; } if(title) { gtk_window_set_title(GTK_WINDOW(data->dlg), title); gtk_label_set_text(GTK_LABEL(data->act), title); } if(dest = fm_file_ops_job_get_dest(data->job)) { char* dest_str = fm_path_display_name(dest, TRUE); gtk_label_set_text(GTK_LABEL(to), dest_str); g_free(dest_str); } else { gtk_widget_destroy(data->dest); gtk_widget_destroy(to_label); } gtk_window_present(GTK_WINDOW(data->dlg)); data->update_timeout = g_timeout_add(500, (GSourceFunc)on_update_dlg, data); data->delay_timeout = 0; return FALSE; }