gboolean panel_launcher_create_copy (PanelToplevel *toplevel, PanelObjectPackType pack_type, int pack_index, const char *location) { char *new_location; GFile *source; GFile *dest; gboolean copied; const char *filename; new_location = panel_make_unique_desktop_uri (NULL, location); source = panel_launcher_get_gfile (location); dest = g_file_new_for_uri (new_location); copied = g_file_copy (source, dest, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, NULL); if (!copied) { g_free (new_location); return FALSE; } filename = panel_launcher_get_filename (new_location); panel_launcher_create (toplevel, pack_type, pack_index, filename); g_free (new_location); return TRUE; }
static void panel_addto_add_item (PanelAddtoDialog *dialog, PanelAddtoItemInfo *item_info) { g_assert (item_info != NULL); switch (item_info->type) { case PANEL_ADDTO_APPLET: mate_panel_applet_frame_create (dialog->panel_widget->toplevel, dialog->insertion_position, item_info->iid); break; case PANEL_ADDTO_ACTION: panel_action_button_create (dialog->panel_widget->toplevel, dialog->insertion_position, item_info->action_type); break; case PANEL_ADDTO_LAUNCHER_MENU: panel_addto_present_applications (dialog); break; case PANEL_ADDTO_LAUNCHER: panel_launcher_create (dialog->panel_widget->toplevel, dialog->insertion_position, item_info->launcher_path); break; case PANEL_ADDTO_LAUNCHER_NEW: ask_about_launcher (NULL, dialog->panel_widget, dialog->insertion_position, FALSE); break; case PANEL_ADDTO_MENU: panel_menu_button_create (dialog->panel_widget->toplevel, dialog->insertion_position, item_info->menu_filename, item_info->menu_path, item_info->menu_path != NULL, item_info->name); break; case PANEL_ADDTO_MENUBAR: panel_menu_bar_create (dialog->panel_widget->toplevel, dialog->insertion_position); break; case PANEL_ADDTO_SEPARATOR: panel_separator_create (dialog->panel_widget->toplevel, dialog->insertion_position); break; case PANEL_ADDTO_DRAWER: panel_drawer_create (dialog->panel_widget->toplevel, dialog->insertion_position, NULL, FALSE, NULL); break; } }
void panel_launcher_create_from_info (PanelToplevel *toplevel, PanelObjectPackType pack_type, int pack_index, gboolean exec_info, const char *exec_or_uri, const char *name, const char *comment, const char *icon) { GKeyFile *key_file; char *location; GError *error; key_file = panel_key_file_new_desktop (); /* set current language and the "C" locale to this name, * this is kind of evil... */ panel_key_file_set_string (key_file, "Name", name); panel_key_file_set_string (key_file, "Comment", comment); panel_key_file_set_string (key_file, "Icon", icon); panel_key_file_set_locale_string (key_file, "Name", name); panel_key_file_set_locale_string (key_file, "Comment", comment); panel_key_file_set_locale_string (key_file, "Icon", icon); if (exec_info) { panel_key_file_set_string (key_file, "Exec", exec_or_uri); panel_key_file_set_string (key_file, "Type", "Application"); } else { panel_key_file_set_string (key_file, "URL", exec_or_uri); panel_key_file_set_string (key_file, "Type", "Link"); } location = panel_make_unique_desktop_uri (NULL, exec_or_uri); error = NULL; if (panel_key_file_to_file (key_file, location, &error)) { panel_launcher_create (toplevel, pack_type, pack_index, location); } else { panel_error_dialog (GTK_WINDOW (toplevel), gtk_window_get_screen (GTK_WINDOW (toplevel)), "cannot_save_launcher", TRUE, _("Could not save launcher"), error->message); g_error_free (error); } g_key_file_free (key_file); }
static void add_app_to_panel (GtkWidget *item, MateMenuTreeEntry *entry) { PanelWidget *panel_widget; PanelToplevel *toplevel; PanelData *pd; int position; panel_widget = menu_get_panel (item); toplevel = panel_widget->toplevel; pd = g_object_get_data (G_OBJECT (toplevel), "PanelData"); position = pd ? pd->insertion_pos : -1; panel_launcher_create (toplevel, position, matemenu_tree_entry_get_desktop_file_path (entry)); }
static void launcher_new_saved (GtkWidget *dialog, gpointer data) { PanelWidget *panel; PanelObjectPackType pack_type; int pack_index; const char *uri; pack_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dialog), "pack-type")); panel = g_object_get_data (G_OBJECT (dialog), "panel"); pack_index = panel_widget_get_new_pack_index (panel, pack_type); uri = panel_ditem_editor_get_uri (PANEL_DITEM_EDITOR (dialog)); if (panel_launcher_get_filename (uri) != NULL) uri = panel_launcher_get_filename (uri); panel_launcher_create (panel->toplevel, pack_type, pack_index, uri); }
static gboolean drop_urilist (PanelWidget *panel, int pos, char *urilist) { char **uris; gboolean success; int i; uris = g_uri_list_extract_uris (urilist); success = TRUE; for (i = 0; uris[i]; i++) { GFile *file; GFileInfo *info; const char *uri; uri = uris[i]; if (g_ascii_strncasecmp (uri, "http:", strlen ("http:")) == 0 || g_ascii_strncasecmp (uri, "https:", strlen ("https:")) == 0 || g_ascii_strncasecmp (uri, "ftp:", strlen ("ftp:")) == 0 || g_ascii_strncasecmp (uri, "gopher:", strlen ("gopher:")) == 0 || g_ascii_strncasecmp (uri, "ghelp:", strlen ("ghelp:")) == 0 || g_ascii_strncasecmp (uri, "man:", strlen ("man:")) == 0 || g_ascii_strncasecmp (uri, "info:", strlen ("info:")) == 0) { /* FIXME: probably do this only on link, * in fact, on link always set up a link, * on copy do all the other stuff. Or something. */ if ( ! drop_url (panel, pos, uri)) success = FALSE; continue; } if (g_ascii_strncasecmp (uri, "x-caja-desktop:", strlen ("x-caja-desktop:")) == 0) { success = drop_caja_desktop_uri (panel, pos, uri); continue; } file = g_file_new_for_uri (uri); info = g_file_query_info (file, "standard::type," "standard::content-type," "access::can-execute", G_FILE_QUERY_INFO_NONE, NULL, NULL); if (info) { const char *mime; GFileType type; gboolean can_exec; mime = g_file_info_get_content_type (info); type = g_file_info_get_file_type (info); can_exec = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE); if (mime && g_str_has_prefix (mime, "image")) { if (!set_background_image_from_uri (panel->toplevel, uri)) success = FALSE; } else if (mime && (!strcmp (mime, "application/x-mate-app-info") || !strcmp (mime, "application/x-desktop") || !strcmp (mime, "application/x-kde-app-info"))) { if (panel_profile_id_lists_are_writable ()) panel_launcher_create (panel->toplevel, pos, uri); else success = FALSE; } else if (type != G_FILE_TYPE_DIRECTORY && can_exec) { char *filename; filename = g_file_get_path (file); if (panel_profile_id_lists_are_writable ()) /* executable and local, so add a * launcher with it */ ask_about_launcher (filename, panel, pos, TRUE); else success = FALSE; g_free (filename); } else { if (!drop_uri (panel, pos, uri, PANEL_ICON_UNKNOWN)) success = FALSE; } } else { if (!drop_uri (panel, pos, uri, PANEL_ICON_UNKNOWN)) success = FALSE; } g_object_unref (info); g_object_unref (file); } g_strfreev (uris); return success; }