gboolean panel_show_uri_force_mime_type (GdkScreen *screen, const gchar *uri, const gchar *mime_type, guint32 timestamp, GError **error) { GFile *file; GAppInfo *app; gboolean ret; g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE); g_return_val_if_fail (uri != NULL, FALSE); g_return_val_if_fail (mime_type != NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); file = g_file_new_for_uri (uri); app = g_app_info_get_default_for_type (mime_type, !g_file_is_native (file)); g_object_unref (file); if (app == NULL) { /* no application for the mime type, so let's fallback on * automatic detection */ return panel_show_uri (screen, uri, timestamp, error); } ret = panel_app_info_launch_uri (app, uri, screen, timestamp, error); g_object_unref (app); return ret; }
static void launch_url (Launcher *launcher) { char *url; GdkScreen *screen; g_return_if_fail (launcher != NULL); g_return_if_fail (launcher->key_file != NULL); /* FIXME panel_ditem_launch() should be enough for this! */ url = panel_key_file_get_string (launcher->key_file, "URL"); screen = launcher_get_screen (launcher); if (!url || *url == 0) { GtkWidget *error_dialog; error_dialog = panel_error_dialog (NULL, screen, "no_url_dialog", TRUE, _("Could not show this URL"), _("No URL was specified.")); launcher_register_error_dialog (launcher, error_dialog); g_free (url); return; } panel_show_uri (screen, url, gtk_get_current_event_time (), NULL); g_free (url); }
gboolean panel_show_uri_force_mime_type (GdkScreen *screen, const gchar *uri, const gchar *mime_type, guint32 timestamp, GError **error) { GFile *file; GAppInfo *appinfo; gboolean ret; GdkDisplay *display; GdkAppLaunchContext *context; GList *uris; g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE); g_return_val_if_fail (uri != NULL, FALSE); g_return_val_if_fail (mime_type != NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); file = g_file_new_for_uri (uri); appinfo = g_app_info_get_default_for_type (mime_type, !g_file_is_native (file)); g_object_unref (file); if (appinfo == NULL) { /* no application for the mime type, so let's fallback on * automatic detection */ return panel_show_uri (screen, uri, timestamp, error); } uris = g_list_append (NULL, (gpointer)uri); display = gdk_screen_get_display (screen); context = gdk_display_get_app_launch_context (display); ret = g_app_info_launch_uris (appinfo, uris, G_APP_LAUNCH_CONTEXT(context), error); g_object_unref (context); g_list_free (uris); g_object_unref (appinfo); return ret; }
static void _panel_show_mount_async_callback (GObject *source_object, GAsyncResult *result, gpointer user_data) { GError *error = NULL; GFile *file; PanelShowMountOperationHandle *handle = user_data; file = G_FILE (source_object); error = NULL; if (g_file_mount_enclosing_volume_finish (file, result, &error)) { char *uri = g_file_get_uri (file); panel_show_uri (handle->screen, uri, gtk_get_current_event_time (), NULL); g_free (uri); } else { if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED) && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_FAILED_HANDLED)) { char *uri; uri = g_file_get_uri (file); _panel_show_error_dialog (uri, handle->screen, error->message); g_free (uri); } g_error_free (error); } if (handle->mount_op) g_object_unref (handle->mount_op); g_slice_free (PanelShowMountOperationHandle, handle); }
static void activate_uri_on_screen(const char* uri, GdkScreen* screen) { panel_show_uri(screen, uri, gtk_get_current_event_time(), NULL); }
static void panel_run_dialog_execute (PanelRunDialog *dialog) { GError *error; gboolean result; char *command; char *disk; char *scheme; command = g_strdup (panel_run_dialog_get_combo_text (dialog)); command = g_strchug (command); if (!command || !command [0]) { g_free (command); return; } /* evil eggies, do not translate! */ #if !GTK_CHECK_VERSION (3, 0, 0) /* FIXME re-add once GTK3 support is fixed */ if (!strcmp (command, "free the fish")) { start_screen_check (); g_free (command); gtk_widget_destroy (dialog->run_dialog); return; } else if (!strcmp (command, "gegls from outer space")) { start_geginv (); g_free (command); gtk_widget_destroy (dialog->run_dialog); return; } #endif error = NULL; disk = g_locale_from_utf8 (command, -1, NULL, NULL, &error); if (!disk || error) { char *primary; primary = g_strdup_printf (_("Could not convert '%s' from UTF-8"), command); panel_error_dialog (GTK_WINDOW (dialog->run_dialog), NULL, "cannot_convert_command_from_utf8", TRUE, primary, error->message); g_free (primary); g_error_free (error); return; } result = FALSE; scheme = g_uri_parse_scheme (disk); /* if it's an absolute path or not a URI, it's possibly an executable, * so try it before displaying it */ if (g_path_is_absolute (disk) || !scheme) result = panel_run_dialog_launch_command (dialog, command, disk); if (!result) { GFile *file; char *uri; GdkScreen *screen; file = panel_util_get_file_optional_homedir (command); uri = g_file_get_uri (file); g_object_unref (file); screen = gtk_window_get_screen (GTK_WINDOW (dialog->run_dialog)); result = panel_show_uri (screen, uri, gtk_get_current_event_time (), NULL); g_free (uri); } if (result) { /* only save working commands in history */ _panel_run_save_recent_programs_list (dialog, GTK_COMBO_BOX (dialog->combobox), command); /* only close the dialog if we successfully showed or launched * something */ gtk_widget_destroy (dialog->run_dialog); } g_free (command); g_free (disk); g_free (scheme); }