static GtkWidget *
cc_sharing_panel_new_media_sharing_row (const char     *uri_or_path,
                                        CcSharingPanel *self)
{
  GtkWidget *row, *box, *w;
  GUserDirectory dir = G_USER_N_DIRECTORIES;
  GIcon *icon;
  guint i;
  char *basename, *path;
  GFile *file;

  file = g_file_new_for_commandline_arg (uri_or_path);
  path = g_file_get_path (file);
  g_object_unref (file);

  row = gtk_list_box_row_new ();
  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  gtk_container_set_border_width (GTK_CONTAINER (box), 12);
  gtk_container_add (GTK_CONTAINER (row), box);

  /* Find the icon and create it */
  for (i = 0; i < G_USER_N_DIRECTORIES; i++)
    {
      if (g_strcmp0 (path, g_get_user_special_dir (i)) == 0)
        {
          dir = i;
          break;
        }
    }

  icon = special_directory_get_gicon (dir);
  w = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_MENU);
  gtk_widget_set_margin_end (w, 12);
  gtk_container_add (GTK_CONTAINER (box), w);
  g_object_unref (icon);

  /* Label */
  basename = g_filename_display_basename (path);
  w = gtk_label_new (basename);
  g_free (basename);
  gtk_container_add (GTK_CONTAINER (box), w);

  /* Remove button */
  w = gtk_button_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR);
  gtk_button_set_relief (GTK_BUTTON (w), GTK_RELIEF_NONE);
  gtk_widget_set_margin_top (w, 3);
  gtk_widget_set_margin_bottom (w, 3);
  gtk_widget_set_margin_end (w, 12);
  gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
  gtk_box_pack_end (GTK_BOX (box), w, FALSE, FALSE, 0);
  g_signal_connect (G_OBJECT (w), "clicked",
                    G_CALLBACK (cc_sharing_panel_remove_folder), self);
  g_object_set_data (G_OBJECT (w), "row", row);

  g_object_set_data_full (G_OBJECT (row), "path", g_strdup (path), g_free);

  gtk_widget_show_all (row);

  return row;
}
Exemplo n.º 2
0
/**
 * This is where we initialize the preferences file with the default values.
 * If you add a new preferences key, you /must/ add a default value here.
 */
static void
tr_prefs_init_defaults( tr_benc * d )
{
    const char * str;

    cf_check_older_configs( );

#ifdef HAVE_GIO
    str = NULL;
    if( !str ) str = g_get_user_special_dir( G_USER_DIRECTORY_DOWNLOAD );
    if( !str ) str = g_get_user_special_dir( G_USER_DIRECTORY_DESKTOP );
    if( !str ) str = tr_getDefaultDownloadDir( );
    tr_bencDictAddStr( d, PREF_KEY_DIR_WATCH, str );
    tr_bencDictAddBool( d, PREF_KEY_DIR_WATCH_ENABLED, FALSE );
#endif

    tr_bencDictAddBool( d, PREF_KEY_USER_HAS_GIVEN_INFORMED_CONSENT, FALSE );
    tr_bencDictAddBool( d, PREF_KEY_INHIBIT_HIBERNATION, FALSE );
    tr_bencDictAddBool( d, PREF_KEY_BLOCKLIST_UPDATES_ENABLED, TRUE );

    tr_bencDictAddStr( d, PREF_KEY_OPEN_DIALOG_FOLDER, g_get_home_dir( ) );

    tr_bencDictAddBool( d, PREF_KEY_TOOLBAR, TRUE );
    tr_bencDictAddBool( d, PREF_KEY_FILTERBAR, TRUE );
    tr_bencDictAddBool( d, PREF_KEY_STATUSBAR, TRUE );
    tr_bencDictAddBool( d, PREF_KEY_SHOW_TRAY_ICON, FALSE );
    tr_bencDictAddBool( d, PREF_KEY_PLAY_DOWNLOAD_COMPLETE_SOUND, TRUE );
    tr_bencDictAddBool( d, PREF_KEY_SHOW_DESKTOP_NOTIFICATION, TRUE );
    tr_bencDictAddBool( d, PREF_KEY_SHOW_MORE_TRACKER_INFO, FALSE );
    tr_bencDictAddBool( d, PREF_KEY_SHOW_MORE_PEER_INFO, FALSE );
    tr_bencDictAddBool( d, PREF_KEY_SHOW_BACKUP_TRACKERS, FALSE );
    tr_bencDictAddStr( d, PREF_KEY_STATUSBAR_STATS, "total-ratio" );

    tr_bencDictAddBool( d, PREF_KEY_OPTIONS_PROMPT, TRUE );

    tr_bencDictAddBool( d, PREF_KEY_MAIN_WINDOW_IS_MAXIMIZED, FALSE );
    tr_bencDictAddInt( d, PREF_KEY_MAIN_WINDOW_HEIGHT, 500 );
    tr_bencDictAddInt( d, PREF_KEY_MAIN_WINDOW_WIDTH, 300 );
    tr_bencDictAddInt( d, PREF_KEY_MAIN_WINDOW_X, 50 );
    tr_bencDictAddInt( d, PREF_KEY_MAIN_WINDOW_Y, 50 );
    tr_bencDictAddStr( d, PREF_KEY_MAIN_WINDOW_LAYOUT_ORDER, "menu,toolbar,filter,list,statusbar" );

    str = NULL;
#if GLIB_CHECK_VERSION( 2, 14, 0 )
    if( !str ) str = g_get_user_special_dir( G_USER_DIRECTORY_DOWNLOAD );
#endif
    if( !str ) str = tr_getDefaultDownloadDir( );
    tr_bencDictAddStr( d, TR_PREFS_KEY_DOWNLOAD_DIR, str );

    tr_bencDictAddBool( d, PREF_KEY_ASKQUIT, TRUE );

    tr_bencDictAddStr( d, PREF_KEY_FILTER_MODE, "show-all" );
    tr_bencDictAddStr( d, PREF_KEY_SORT_MODE, "sort-by-name" );
    tr_bencDictAddBool( d, PREF_KEY_SORT_REVERSED, FALSE );
    tr_bencDictAddBool( d, PREF_KEY_MINIMAL_VIEW, FALSE );

    tr_bencDictAddBool( d, PREF_KEY_START, TRUE );
    tr_bencDictAddBool( d, PREF_KEY_TRASH_ORIGINAL, FALSE );
}
Exemplo n.º 3
0
/**
 * This is where we initialize the preferences file with the default values.
 * If you add a new preferences key, you /must/ add a default value here.
 */
static void
tr_prefs_init_defaults( tr_benc * d )
{
    const char * str;

    cf_check_older_configs( );

#ifdef HAVE_GIO
    str = NULL;
    if( !str ) str = g_get_user_special_dir( G_USER_DIRECTORY_DOWNLOAD );
    if( !str ) str = g_get_user_special_dir( G_USER_DIRECTORY_DESKTOP );
    if( !str ) str = tr_getDefaultDownloadDir( );
    tr_bencDictAddStr( d, PREF_KEY_DIR_WATCH, str );
    tr_bencDictAddInt( d, PREF_KEY_DIR_WATCH_ENABLED, FALSE );
#endif

    tr_bencDictAddInt( d, PREF_KEY_INHIBIT_HIBERNATION, FALSE );
    tr_bencDictAddInt( d, PREF_KEY_BLOCKLIST_UPDATES_ENABLED, TRUE );

    tr_bencDictAddStr( d, PREF_KEY_OPEN_DIALOG_FOLDER, g_get_home_dir( ) );

    tr_bencDictAddInt( d, PREF_KEY_TOOLBAR, TRUE );
    tr_bencDictAddInt( d, PREF_KEY_FILTERBAR, TRUE );
    tr_bencDictAddInt( d, PREF_KEY_STATUSBAR, TRUE );
    tr_bencDictAddInt( d, PREF_KEY_SHOW_TRAY_ICON, FALSE );
    tr_bencDictAddInt( d, PREF_KEY_SHOW_DESKTOP_NOTIFICATION, TRUE );
    tr_bencDictAddStr( d, PREF_KEY_STATUSBAR_STATS, "total-ratio" );

    tr_bencDictAddInt( d, PREF_KEY_SCHED_LIMIT_ENABLED, FALSE );
    tr_bencDictAddInt( d, PREF_KEY_SCHED_BEGIN,    60 * 23 ); /* 11pm */
    tr_bencDictAddInt( d, PREF_KEY_SCHED_END,      60 * 7 );  /* 7am */
    tr_bencDictAddInt( d, PREF_KEY_SCHED_DL_LIMIT, 200 );   /* 2x the other limit */
    tr_bencDictAddInt( d, PREF_KEY_SCHED_UL_LIMIT, 100 );   /* 2x the other limit */

    tr_bencDictAddInt( d, PREF_KEY_OPTIONS_PROMPT, TRUE );

    tr_bencDictAddInt( d, PREF_KEY_MAIN_WINDOW_HEIGHT, 500 );
    tr_bencDictAddInt( d, PREF_KEY_MAIN_WINDOW_WIDTH, 300 );
    tr_bencDictAddInt( d, PREF_KEY_MAIN_WINDOW_X, 50 );
    tr_bencDictAddInt( d, PREF_KEY_MAIN_WINDOW_Y, 50 );
    tr_bencDictAddStr( d, PREF_KEY_MAIN_WINDOW_LAYOUT_ORDER, "menu,toolbar,filter,list,statusbar" );

    str = NULL;
#if GLIB_CHECK_VERSION( 2, 14, 0 )
    if( !str ) str = g_get_user_special_dir( G_USER_DIRECTORY_DOWNLOAD );
#endif
    if( !str ) str = tr_getDefaultDownloadDir( );
    tr_bencDictAddStr( d, TR_PREFS_KEY_DOWNLOAD_DIR, str );

    tr_bencDictAddInt( d, PREF_KEY_ASKQUIT, TRUE );

    tr_bencDictAddStr( d, PREF_KEY_SORT_MODE, "sort-by-name" );
    tr_bencDictAddInt( d, PREF_KEY_SORT_REVERSED, FALSE );
    tr_bencDictAddInt( d, PREF_KEY_MINIMAL_VIEW, FALSE );

    tr_bencDictAddInt( d, PREF_KEY_START, TRUE );
    tr_bencDictAddInt( d, PREF_KEY_TRASH_ORIGINAL, FALSE );
}
Exemplo n.º 4
0
/**
 * This is where we initialize the preferences file with the default values.
 * If you add a new preferences key, you /must/ add a default value here.
 */
static void
tr_prefs_init_defaults( tr_benc * d )
{
    const char * str;

    cf_check_older_configs( );

    str = NULL;
    if( !str ) str = g_get_user_special_dir( G_USER_DIRECTORY_DOWNLOAD );
    if( !str ) str = g_get_user_special_dir( G_USER_DIRECTORY_DESKTOP );
    if( !str ) str = tr_getDefaultDownloadDir( );
    tr_bencDictAddStr ( d, PREF_KEY_DIR_WATCH, str );
    tr_bencDictAddBool( d, PREF_KEY_DIR_WATCH_ENABLED, FALSE );

    tr_bencDictAddBool( d, PREF_KEY_USER_HAS_GIVEN_INFORMED_CONSENT, FALSE );
    tr_bencDictAddBool( d, PREF_KEY_INHIBIT_HIBERNATION, FALSE );
    tr_bencDictAddBool( d, PREF_KEY_BLOCKLIST_UPDATES_ENABLED, TRUE );

    tr_bencDictAddStr ( d, PREF_KEY_OPEN_DIALOG_FOLDER, g_get_home_dir( ) );

    tr_bencDictAddBool( d, PREF_KEY_TOOLBAR, TRUE );
    tr_bencDictAddBool( d, PREF_KEY_FILTERBAR, TRUE );
    tr_bencDictAddBool( d, PREF_KEY_STATUSBAR, TRUE );
    tr_bencDictAddBool( d, PREF_KEY_TRASH_CAN_ENABLED, TRUE );
    tr_bencDictAddBool( d, PREF_KEY_SHOW_TRAY_ICON, FALSE );
    tr_bencDictAddBool( d, PREF_KEY_SHOW_MORE_TRACKER_INFO, FALSE );
    tr_bencDictAddBool( d, PREF_KEY_SHOW_MORE_PEER_INFO, FALSE );
    tr_bencDictAddBool( d, PREF_KEY_SHOW_BACKUP_TRACKERS, FALSE );
    tr_bencDictAddStr ( d, PREF_KEY_STATUSBAR_STATS, "total-ratio" );

    tr_bencDictAddStr ( d, PREF_KEY_TORRENT_ADDED_NOTIFICATION_COMMAND, "notify-send -c transfer -i transmission '%s' '%s'" );
    tr_bencDictAddBool( d, PREF_KEY_TORRENT_ADDED_NOTIFICATION_ENABLED, true );
    tr_bencDictAddStr ( d, PREF_KEY_TORRENT_COMPLETE_NOTIFICATION_COMMAND, "notify-send -c transfer.complete -i transmission '%s' '%s'" );
    tr_bencDictAddBool( d, PREF_KEY_TORRENT_COMPLETE_NOTIFICATION_ENABLED, true );
    tr_bencDictAddStr ( d, PREF_KEY_TORRENT_COMPLETE_SOUND_COMMAND, "canberra-gtk-play -i complete-download -d 'transmission torrent downloaded'" );
    tr_bencDictAddBool( d, PREF_KEY_TORRENT_COMPLETE_SOUND_ENABLED, true );

    tr_bencDictAddBool( d, PREF_KEY_OPTIONS_PROMPT, TRUE );

    tr_bencDictAddBool( d, PREF_KEY_MAIN_WINDOW_IS_MAXIMIZED, FALSE );
    tr_bencDictAddInt( d, PREF_KEY_MAIN_WINDOW_HEIGHT, 500 );
    tr_bencDictAddInt( d, PREF_KEY_MAIN_WINDOW_WIDTH, 300 );
    tr_bencDictAddInt( d, PREF_KEY_MAIN_WINDOW_X, 50 );
    tr_bencDictAddInt( d, PREF_KEY_MAIN_WINDOW_Y, 50 );

    str = g_get_user_special_dir( G_USER_DIRECTORY_DOWNLOAD );
    tr_bencDictAddStr( d, TR_PREFS_KEY_DOWNLOAD_DIR, str );

    tr_bencDictAddStr( d, PREF_KEY_SORT_MODE, "sort-by-name" );
    tr_bencDictAddBool( d, PREF_KEY_SORT_REVERSED, FALSE );
    tr_bencDictAddBool( d, PREF_KEY_COMPACT_VIEW, FALSE );
}
Exemplo n.º 5
0
static void
cheese_fileutil_init (CheeseFileUtil *fileutil)
{
  CheeseFileUtilPrivate *priv = fileutil->priv = CHEESE_FILEUTIL_GET_PRIVATE (fileutil);

  GSettings *settings;

  priv->burst_count    = 0;
  priv->burst_raw_name = "";

  settings = g_settings_new ("org.gnome.Cheese");

  priv->video_path = g_settings_get_string (settings, "video-path");
  priv->photo_path = g_settings_get_string (settings, "photo-path");

  /* get the video path from gsettings, xdg or hardcoded */
  if (!priv->video_path || (*priv->video_path == '\0'))
  {
    g_free (priv->video_path);

    /* get xdg */
    priv->video_path = g_build_filename (g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS), "Webcam", NULL);
    if (priv->video_path == '\0')
    {
      g_free (priv->video_path);

      /* get "~/.gnome2/cheese/media" */
      priv->video_path = cheese_fileutil_get_path_before_224 (fileutil);
    }
  }

  /* get the photo path from gsettings, xdg or hardcoded */
  if (!priv->photo_path || (*priv->photo_path == '\0'))
  {
    g_free (priv->photo_path);

    /* get xdg */
    priv->photo_path = g_build_filename (g_get_user_special_dir (G_USER_DIRECTORY_PICTURES), "Webcam", NULL);
    if (priv->photo_path == '\0')
    {
      /* get "~/.gnome2/cheese/media" */
      g_free (priv->photo_path);
      priv->photo_path = cheese_fileutil_get_path_before_224 (fileutil);
    }
  }

  g_object_unref (settings);
}
Exemplo n.º 6
0
void saa_main_window_charger_xml_clicked		(SaaMainWindow * w) {
	GtkWidget * warning;
	const gchar * path = g_get_user_special_dir(G_USER_DIRECTORY_DOCUMENTS);
	GtkWidget * dialog = gtk_file_chooser_dialog_new(_("Load a solid"), GTK_WINDOW(w),
												GTK_FILE_CHOOSER_ACTION_OPEN,
												GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
												GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
												NULL);

	gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), path);
	if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
	    char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));

	    if(!saa_visuel_construire(w->visuel, SAA_FILENAME, filename, 0)) {
	    	warning = gtk_message_dialog_new (GTK_WINDOW(w),
                    GTK_DIALOG_DESTROY_WITH_PARENT,
                    GTK_MESSAGE_WARNING,
                    GTK_BUTTONS_CLOSE,
                    _("Unable to load the file %s"),
                    filename);
			gtk_dialog_run(GTK_DIALOG(warning));
			gtk_widget_destroy (warning);
	    } else {
	    	saa_tree_view_update(SAA_TREE_VIEW(w->explorer));
	    	saa_solid_manager_set_filename(SAA_SOLID_MANAGER(w->manager), filename);
	    	gtk_widget_queue_draw(w->area);
	    }
	    g_free (filename);
	  }
	gtk_widget_destroy (dialog);
}
Exemplo n.º 7
0
static const char *
shell_util_get_icon_for_uri_known_folders (const char *uri)
{
  const char *icon;
  char *path;
  int len;

  icon = NULL;

  if (!g_str_has_prefix (uri, "file:"))
    return NULL;

  path = g_filename_from_uri (uri, NULL, NULL);

  len = strlen (path);
  if (path[len] == '/')
    path[len] = '\0';

  if (strcmp (path, "/") == 0)
    icon = "drive-harddisk";
  else if (strcmp (path, g_get_home_dir ()) == 0)
    icon = "user-home";
  else if (strcmp (path, g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP))
      == 0)
    icon = "user-desktop";

  g_free (path);

  return icon;
}
Exemplo n.º 8
0
Arquivo: main.c Projeto: andrewrk/mpd
static bool
glue_mapper_init(GError **error_r)
{
	GError *error = NULL;
	char *music_dir = config_dup_path(CONF_MUSIC_DIR, &error);
	if (music_dir == NULL && error != NULL) {
		g_propagate_error(error_r, error);
		return false;
	}

	char *playlist_dir = config_dup_path(CONF_PLAYLIST_DIR, &error);
	if (playlist_dir == NULL && error != NULL) {
		g_propagate_error(error_r, error);
		return false;
	}

#if GLIB_CHECK_VERSION(2,14,0)
	if (music_dir == NULL)
		music_dir = g_strdup(g_get_user_special_dir(G_USER_DIRECTORY_MUSIC));
#endif

	mapper_init(music_dir, playlist_dir);

	g_free(music_dir);
	g_free(playlist_dir);
	return true;
}
Exemplo n.º 9
0
GtkWidget * create_info_bar_import_music(struct con_win *cwin)
{
	const gchar *dir = g_get_user_special_dir(G_USER_DIRECTORY_MUSIC);

	GtkWidget *info_bar = gtk_info_bar_new();
	GtkWidget *action_area = gtk_info_bar_get_action_area(GTK_INFO_BAR (info_bar));
	GtkWidget *content_area = gtk_info_bar_get_content_area(GTK_INFO_BAR(info_bar));

	gtk_orientable_set_orientation(GTK_ORIENTABLE(action_area), GTK_ORIENTATION_HORIZONTAL);

	//GtkInfoBar has undocumented behavior for GTK_RESPONSE_CANCEL
	gtk_info_bar_add_button(GTK_INFO_BAR(info_bar), GTK_STOCK_NO, GTK_RESPONSE_CANCEL);
	gtk_info_bar_add_button(GTK_INFO_BAR(info_bar), GTK_STOCK_YES, GTK_RESPONSE_YES);

	gchar *content = g_strdup_printf(_("Would you like to import %s to library?"), dir);

	GtkWidget *label = gtk_label_new(content);
	gtk_box_pack_start(GTK_BOX(content_area), label, FALSE, FALSE, 0);

	g_signal_connect(info_bar, "response", G_CALLBACK(info_bar_response_cb), cwin);

	gtk_widget_show_all(info_bar);

	g_free(content);

	return info_bar;
}
Exemplo n.º 10
0
JNIEXPORT jstring JNICALL
Java_org_gnome_glib_GlibMisc_g_1get_1user_1special_1dir
(
	JNIEnv* env,
	jclass cls,
	jint _directory
)
{
	const gchar* result;
	jstring _result;
	GUserDirectory directory;

	// convert parameter directory
	directory = (GUserDirectory) _directory;

	// call function
	result = g_get_user_special_dir(directory);

	// cleanup parameter directory

	// translate return value to JNI type
	_result = (jstring) bindings_java_newString(env, result);

	// and finally
	return _result;
}
Exemplo n.º 11
0
static void
updater_subscribe_config (updater_t *updater)
{
	xmmsc_result_t *res;
	const gchar *default_directory;

	g_return_if_fail (updater);
	g_return_if_fail (updater->conn);

	default_directory = g_get_user_special_dir (G_USER_DIRECTORY_MUSIC);

	if (!default_directory) {
		default_directory = "";
	}

	res = xmmsc_config_register_value (updater->conn,
	                                   "mlibupdater.watch_dirs",
	                                   default_directory);

	xmmsc_result_notifier_set (res, updater_config_register, updater);
	xmmsc_result_unref (res);

	res = xmmsc_broadcast_config_value_changed (updater->conn);
	xmmsc_result_notifier_set (res, updater_config_changed, updater);
	xmmsc_result_unref (res);
}
Exemplo n.º 12
0
static void
add_file_button_clicked_cb (GtkButton *button,
			    gpointer   user_data)
{
	GthSlideshowPreferences *self = user_data;
	GtkWidget               *dialog;
	GtkFileFilter           *filter;

	dialog = gtk_file_chooser_dialog_new (_("Choose the files to play"),
					      GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))),
					      GTK_FILE_CHOOSER_ACTION_OPEN,
					      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
					      GTK_STOCK_OK, GTK_RESPONSE_OK,
					      NULL);
	gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
	gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), g_get_user_special_dir (G_USER_DIRECTORY_MUSIC));
	filter = gtk_file_filter_new ();
	gtk_file_filter_set_name (filter, _("Audio files"));
	gtk_file_filter_add_mime_type (filter, "audio/*");
	gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
	g_signal_connect (dialog,
			  "delete-event",
			  G_CALLBACK (gtk_true),
			  NULL);
	g_signal_connect (dialog,
			  "response",
			  G_CALLBACK (file_chooser_dialog_response_cb),
			  self);
	gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
	gtk_widget_show (dialog);
}
Exemplo n.º 13
0
static gchar *
get_desktop_dir (void)
{
    gboolean desktop_is_home_dir = FALSE;
    gchar *desktop_dir;
    const char * const *schemas;
    gboolean schema_exists = FALSE;
    gint i;

    /* Check if caja schema is installed before trying to read settings */
    schemas = g_settings_list_schemas ();
    for (i = 0; schemas[i] != NULL; i++) {
        if (g_strcmp0 (schemas[i], CAJA_PREFERENCES_SCHEMA) == 0) {
            schema_exists = TRUE;
            break;
        }
    }

    if (schema_exists) {
        GSettings *caja_prefs;

        caja_prefs = g_settings_new (CAJA_PREFERENCES_SCHEMA);
        desktop_is_home_dir = g_settings_get_boolean (caja_prefs, "desktop-is-home-dir");

        g_object_unref (caja_prefs);
    }

    if (desktop_is_home_dir)
        desktop_dir = g_strconcat ("file://", g_get_home_dir (), NULL);
    else
        desktop_dir = g_strconcat ("file://", g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP), NULL);

    return desktop_dir;
}
Exemplo n.º 14
0
static void
activate_desktop_uri (GtkWidget *menuitem,
		      gpointer   data)
{
	activate_path (menuitem,
		       g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP));
}
Exemplo n.º 15
0
static gchar *
get_desktop_dir (void)
{
  gboolean desktop_is_home_dir = FALSE;
  gchar *desktop_dir;
  gboolean schema_exists = FALSE;

  /* Check if caja schema is installed before trying to read settings */
  GSettingsSchema *schema = g_settings_schema_source_lookup (g_settings_schema_source_get_default (),
                                                             CAJA_PREFERENCES_SCHEMA,
                                                             FALSE);

  if (schema != NULL) {
    GSettings *caja_prefs;

    caja_prefs = g_settings_new (CAJA_PREFERENCES_SCHEMA);
    desktop_is_home_dir = g_settings_get_boolean (caja_prefs, "desktop-is-home-dir");

    g_object_unref (caja_prefs);
    g_settings_schema_unref (schema);
  }

  if (desktop_is_home_dir)
    desktop_dir = g_strconcat ("file://", g_get_home_dir (), NULL);
  else
    desktop_dir = g_strconcat ("file://", g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP), NULL);

  return desktop_dir;
}
Exemplo n.º 16
0
/* {{{ proto string Glib::userSpecialDir(int user_dir_type)
	   Returns the full path of a special directory using its logical id.
	   One of Glib::USER_DIRECTORY_* constants is supposed to be used as parameter
*/
PHP_METHOD(Glib, userSpecialDir)
{
	long dir_type;

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &dir_type) == FAILURE) {
		return;
	}

	if (dir_type < 0 || dir_type >= G_USER_N_DIRECTORIES) {
		zval *exception;

		MAKE_STD_ZVAL(exception);
		object_init_ex(exception, glib_ce_exception);
		zend_update_property_string(glib_ce_exception, exception, "message", sizeof("message")-1, "invalid user-directory type" TSRMLS_CC);
		zend_throw_exception_object(exception TSRMLS_CC);

		return;
	}

	const char *retval = g_get_user_special_dir(dir_type);

	if (NULL == retval) {
		RETURN_NULL();
	}

	RETURN_STRING(retval, 1);
}
Exemplo n.º 17
0
static void info_bar_response_cb(GtkInfoBar *info_bar, gint response_id, gpointer user_data)
{
	GSList *library_dir = NULL;

	struct con_win *cwin = user_data;
	const gchar *dir = g_get_user_special_dir(G_USER_DIRECTORY_MUSIC);

	gtk_widget_destroy(GTK_WIDGET(info_bar));

	switch (response_id)
	{
		case GTK_RESPONSE_CANCEL:
			break;
		case GTK_RESPONSE_YES:
			library_dir = g_slist_append(library_dir, g_strdup(dir));
			pragha_preferences_set_filename_list(cwin->preferences,
				                             GROUP_LIBRARY,
				                             KEY_LIBRARY_DIR,
				                             library_dir);
			free_str_list(library_dir);

			pragha_scanner_scan_library(cwin->scanner);
			break;
		default:
			g_warn_if_reached();
	}
}
static void
um_photo_dialog_select_file (UmPhotoDialog *um)
{
        GtkWidget *chooser;
        const gchar *folder;
        GtkWidget *preview;

        chooser = gtk_file_chooser_dialog_new (_("Browse for more pictures"),
                                               GTK_WINDOW (gtk_widget_get_toplevel (um->popup_button)),
                                               GTK_FILE_CHOOSER_ACTION_OPEN,
                                               GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                               GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
                                               NULL);

        gtk_window_set_modal (GTK_WINDOW (chooser), TRUE);

        preview = gtk_image_new ();
        gtk_widget_set_size_request (preview, 128, -1);
        gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (chooser), preview);
        gtk_file_chooser_set_use_preview_label (GTK_FILE_CHOOSER (chooser), FALSE);
        gtk_widget_show (preview);
        g_signal_connect (chooser, "update-preview",
                          G_CALLBACK (update_preview), um->thumb_factory);

        folder = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
        if (folder)
                gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser),
                                                     folder);

        g_signal_connect (chooser, "response",
                          G_CALLBACK (file_chooser_response), um);

        gtk_window_present (GTK_WINDOW (chooser));
}
gboolean
nautilus_bookmark_get_xdg_type (NautilusBookmark *bookmark,
				GUserDirectory   *directory)
{
	gboolean match;
	GFile *location;
	const gchar *path;
	GUserDirectory dir;

	match = FALSE;

	for (dir = 0; dir < G_USER_N_DIRECTORIES; dir++) {
		path = g_get_user_special_dir (dir);
		if (!path) {
			continue;
		}

		location = g_file_new_for_path (path);
		match = g_file_equal (location, bookmark->details->location);
		g_object_unref (location);

		if (match) {
			break;
		}
	}

	if (match && directory != NULL) {
		*directory = dir;
	}

	return match;
}
Exemplo n.º 20
0
/* TODO: convert this to a simple call to g_file_query_info? */
static const char *
panel_util_get_icon_for_uri_known_folders (const char *uri)
{
	const char *icon;
	char       *path;
	int         len;

	icon = NULL;
	
	if (!g_str_has_prefix (uri, "file:"))
		return NULL;

	path = g_filename_from_uri (uri, NULL, NULL);

	/* Sanity check. We may be given a broken URI. */
	if (path == NULL)
		return NULL;

	len = strlen (path);
	if (path[len] == '/')
		path[len] = '\0';

	if (strcmp (path, "/") == 0)
		icon = PANEL_ICON_FILESYSTEM;
	else if (strcmp (path, g_get_home_dir ()) == 0)
		icon = PANEL_ICON_HOME;
	else if (strcmp (path,
			 g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP)) == 0)
		icon = PANEL_ICON_DESKTOP;
	else if (g_strcmp0 (path,
			    g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS)) == 0)
		icon = PANEL_ICON_FOLDER_DOCUMENTS;
	else if (g_strcmp0 (path,
			    g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD)) == 0)
		icon = PANEL_ICON_FOLDER_DOWNLOAD;
	else if (g_strcmp0 (path,
			    g_get_user_special_dir (G_USER_DIRECTORY_MUSIC)) == 0)
		icon = PANEL_ICON_FOLDER_MUSIC;
	else if (g_strcmp0 (path,
			    g_get_user_special_dir (G_USER_DIRECTORY_PICTURES)) == 0)
		icon = PANEL_ICON_FOLDER_PICTURES;
	else if (g_strcmp0 (path,
			    g_get_user_special_dir (G_USER_DIRECTORY_PUBLIC_SHARE)) == 0)
		icon = PANEL_ICON_FOLDER_PUBLIC_SHARE;
	else if (g_strcmp0 (path,
			    g_get_user_special_dir (G_USER_DIRECTORY_TEMPLATES)) == 0)
		icon = PANEL_ICON_FOLDER_TEMPLATES;
	else if (g_strcmp0 (path,
			    g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS)) == 0)
		icon = PANEL_ICON_FOLDER_VIDEOS;

	g_free (path);

	return icon;
}
Exemplo n.º 21
0
QString defaultDownloadDir() {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
    static QStringList list = QStandardPaths::standardLocations(QStandardPaths::DownloadLocation);
    if (!list.empty())
        return list.front();
#endif
    // qt4 don't have QStandardPaths, use glib's as fallback
    return QString::fromUtf8(g_get_user_special_dir(G_USER_DIRECTORY_DOWNLOAD));
}
Exemplo n.º 22
0
CefString ClientApp::AppGetDocumentsDirectory()
{
    const char *dir = g_get_user_special_dir(G_USER_DIRECTORY_DOCUMENTS);
    if (dir == NULL)  {
        return AppGetSupportDirectory();
    } else {
        return CefString(dir);
    }
}
static void
place_query_info_ready (GObject *source,
                        GAsyncResult *res,
                        gpointer user_data)
{
  GtkWidget *row, *box, *w;
  Place *place;
  GFileInfo *info;
  const gchar *desktop_path;
  gchar *path;

  info = g_file_query_info_finish (G_FILE (source), res, NULL);
  if (!info)
    return;

  row = user_data;
  place = g_object_get_data (G_OBJECT (row), "place");
  g_clear_object (&place->cancellable);

  box = gtk_bin_get_child (GTK_BIN (row));

  /* FIXME: GLib is currently buggy and returns a non-existent icon name
   * when asked for the desktop symbolic icon.
   */
  desktop_path = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
  path = g_file_get_path (G_FILE (source));

  if (g_strcmp0 (path, desktop_path) == 0)
    place->icon = g_themed_icon_new ("folder-symbolic");
  else
    place->icon = g_object_ref (g_file_info_get_symbolic_icon (info));

  if (g_strcmp0 (path, g_get_home_dir ()) == 0)
    place->settings_key = TRACKER_KEY_SINGLE_DIRECTORIES;
  else
    place->settings_key = TRACKER_KEY_RECURSIVE_DIRECTORIES;

  g_free (path);

  w = gtk_image_new_from_gicon (place->icon, GTK_ICON_SIZE_MENU);
  gtk_container_add (GTK_CONTAINER (box), w);

  w = gtk_label_new (place->display_name);
  gtk_container_add (GTK_CONTAINER (box), w);

  w = gtk_switch_new ();
  gtk_box_pack_end (GTK_BOX (box), w, FALSE, FALSE, 0);
  g_settings_bind_with_mapping (tracker_preferences, place->settings_key,
                                w, "active",
                                G_SETTINGS_BIND_DEFAULT,
                                switch_tracker_get_mapping,
                                switch_tracker_set_mapping,
                                place, NULL);

  gtk_widget_show_all (row);
  g_object_unref (info);
}
Exemplo n.º 24
0
static void menu_init ()
{
	Menu = gtk_menu_new ();

	gchar *xdg_music_path = (gchar*)g_get_user_special_dir (G_USER_DIRECTORY_MUSIC);
	if (!xdg_music_path)
		return;

	GtkWidget* item = path_to_menu (xdg_music_path);
	gtk_menu_append (Menu, item);

	gtk_widget_show_all (item);

	/* Line */
	item = gtk_separator_menu_item_new ();
	gtk_menu_append (Menu, item);
	gtk_widget_show_all (item);

	/* Shuffle */
	item = gtk_check_menu_item_new_with_label ("Shuffle");
	gtk_menu_append (Menu, item);
	g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (call_shuffle), NULL);
	gtk_widget_show_all (item);
	
	/* Play/pause */
	item = gtk_menu_item_new_with_label ("Play/Pause");
	gtk_menu_append (Menu, item);
	g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (play_or_pause), NULL);
	gtk_widget_show_all (item);

	/* Stop */
	item = gtk_menu_item_new_with_label ("Stop");
	gtk_menu_append (Menu, item);
	g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (stop), NULL);
	gtk_widget_show_all (item);

	/* Previous */
	item = gtk_menu_item_new_with_label ("Prev track");
	gtk_menu_append (Menu, item);
	g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (prev_track), NULL);
	gtk_widget_show_all (item);

	/* Next */
	item = gtk_menu_item_new_with_label ("Next track");
	gtk_menu_append (Menu, item);
	g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (next_track), NULL);
	gtk_widget_show_all (item);

	/* Quit */
	item = gtk_menu_item_new_with_label ("Quit");
	gtk_menu_append (Menu, item);
	g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (quit), NULL);
	gtk_widget_show_all (item);

	app_indicator_set_menu (Indicator, GTK_MENU (Menu));
}
Exemplo n.º 25
0
void
sj_add_default_dirs (GtkFileChooser *dialog)
{
	const char *dir;

	dir = g_get_user_special_dir (G_USER_DIRECTORY_MUSIC);
	if (dir) {
		gtk_file_chooser_add_shortcut_folder (dialog, dir, NULL);
	}
}
Exemplo n.º 26
0
/*
 * Get the documents directory.
 */
const gchar *
get_documents_dir  (void)
{
  const gchar *documents_dir = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
  if (documents_dir == NULL)
    {
       documents_dir = get_home_dir ();
    }
  return documents_dir;
}
gboolean
nautilus_should_use_templates_directory (void)
{
	const char *dir;
	gboolean res;

	dir = g_get_user_special_dir (G_USER_DIRECTORY_TEMPLATES);
	res = dir && (g_strcmp0 (dir, g_get_home_dir ()) != 0);
	return res;
}
static const gchar *
get_user_special_dir_if_not_home (GUserDirectory idx)
{
  const gchar *path;
  path = g_get_user_special_dir (idx);
  if (g_strcmp0 (path, g_get_home_dir ()) == 0)
    return NULL;

  return path;
}
Exemplo n.º 29
0
static char *
uri_from_special_dir (GUserDirectory directory)
{
  char const *path;

  path = g_get_user_special_dir (directory);
  g_return_val_if_fail (path, NULL);

  return g_strdup_printf ("file://%s", path);
}
Exemplo n.º 30
0
char *
totem_pictures_dir (void)
{
	const char *dir;

	dir = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
	if (dir == NULL)
		return NULL;
	return g_strdup (dir);
}