在桌面打不开可执行文件 (application/x-executable)的软链

来源:互联网 发布:ibm云计算产品 编辑:程序博客网 时间:2024/06/15 23:09
https://tower.im/projects/1c0cd0c59ef941298c6e6b2ba6833b91/todos/2f15e4af1bf94dacbf95555b5c9f2b32/** (desktop:15361): DEBUG: activate_file: 到 dock 的链接** (desktop:15361): DEBUG: content_type: application/x-executable** (desktop:15361): DEBUG: is_executable && g_content_type_can_be_executable || is_bin** (desktop:15361): DEBUG: run_file** (desktop:15361): DEBUG: activate_file: dock** (desktop:15361): DEBUG: content_type: application/x-executable** (desktop:15361): DEBUG: is_executable && g_content_type_can_be_executable || is_bin** (desktop:15361): DEBUG: run_filegboolean activate_file (GFile* file, const char* content_type, gboolean is_executable, GFile* _file_arg){ char* file_name = g_file_get_basename (file); gboolean is_bin = g_str_has_suffix(file_name, ".bin"); gboolean result = TRUE; g_debug ("activate_file: %s", file_name); g_free (file_name); g_debug ("content_type: %s", content_type); if (is_executable && (g_content_type_can_be_executable (content_type) || is_bin)) { g_debug("is_executable && g_content_type_can_be_executable || is_bin"); //1. an executable text file. or an shell script if (g_content_type_is_a (content_type, "text/plain")) { g_debug("g_content_type_is_a"); GtkWidget* dialog; int response; char* file_name; char* prompt; char* detail; file_name = g_file_get_basename (file); prompt = g_strdup_printf (_("Do you want to run \"%s\", or display its contents?"), file_name); detail = g_strdup_printf (_("\"%s\" is an executable text file."), file_name); g_free (file_name); //create prompt dialog dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, NULL); g_object_set (dialog, "text", prompt, "secondary-text", detail, NULL); g_free (prompt); g_free (detail); gtk_dialog_add_button (GTK_DIALOG(dialog), _("Run in _Terminal"), RESPONSE_RUN_IN_TERMINAL); gtk_dialog_add_button (GTK_DIALOG(dialog), _("_Display"), RESPONSE_DISPLAY); gtk_dialog_add_button (GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); gtk_dialog_add_button (GTK_DIALOG(dialog), _("_Run"), RESPONSE_RUN); gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL); gtk_widget_show (GTK_WIDGET (dialog)); response = gtk_dialog_run (GTK_DIALOG(dialog)); gtk_widget_destroy (GTK_WIDGET (dialog)); g_message("response:%d",response); switch (response) { case RESPONSE_RUN_IN_TERMINAL: run_file_in_terminal (file); break; case RESPONSE_DISPLAY: result = display_file (file, content_type); break; case RESPONSE_RUN: run_file (file, NULL); break; case GTK_RESPONSE_CANCEL: break; default: break; } } //2. an executable binary file else { g_debug("run_file"); run_file (file, _file_arg); } } //for non-executables just open it. else { g_debug("for non-executables just open it."); result = display_file (file, content_type); } return result;}
原创粉丝点击