static void
thumbnail_problem_bar_response_cb (GtkInfoBar *infobar,
                                          gint  response_id,
                                      gpointer  user_data)
{
    NemoThumbnailProblemBar *bar;

    bar = NEMO_THUMBNAIL_PROBLEM_BAR (infobar);

    switch (response_id) {
        case FIX_CACHE:
            g_spawn_command_line_sync ("sh -c \"pkexec nemo --fix-cache\"", NULL, NULL, NULL, NULL);
            nemo_application_check_thumbnail_cache (nemo_application_get_singleton ());
            nemo_window_slot_queue_reload (nemo_view_get_nemo_window_slot (bar->priv->view), FALSE);
            nemo_window_slot_check_bad_cache_bar (nemo_view_get_nemo_window_slot (bar->priv->view));
            break;
        case DISMISS:
            nemo_application_clear_cache_flag (nemo_application_get_singleton ());
            nemo_application_ignore_cache_problem (nemo_application_get_singleton ());
            gtk_widget_hide (GTK_WIDGET (infobar));
            break;
        default:
            break;
    }
}
Example #2
0
static void
create_new_desktop_window (NemoDesktopManager *manager,
                                         gint  monitor,
                                     gboolean  primary,
                                     gboolean  show_desktop)
{
    FETCH_PRIV (manager);
    GtkWidget *window;

    DesktopInfo *info = g_slice_new0 (DesktopInfo);

    info->monitor_num = monitor;
    info->shows_desktop = show_desktop;
    info->is_primary = primary;

    if (show_desktop) {
        window = GTK_WIDGET (nemo_desktop_window_new (monitor));
    } else {
        window = GTK_WIDGET (nemo_blank_desktop_window_new (monitor));
    }

    info->window = window;

    if (priv->scale_factor_changed_id == 0) {
        priv->scale_factor_changed_id = g_signal_connect (window,
                                                          "notify::scale-factor",
                                                          G_CALLBACK (on_window_scale_changed),
                                                          manager);
    }

    gtk_application_add_window (GTK_APPLICATION (nemo_application_get_singleton ()),
                                GTK_WINDOW (window));

    priv->desktops = g_list_append (priv->desktops, info);
}
Example #3
0
static void
create_new_desktop_window (NemoDesktopManager *manager,
                                         gint  monitor,
                                     gboolean  primary,
                                     gboolean  show_desktop)
{
    GtkWidget *window;

    DesktopInfo *info = g_slice_new0 (DesktopInfo);

    info->monitor_num = monitor;
    info->shows_desktop = show_desktop;
    info->is_primary = primary;

    if (show_desktop) {
        window = GTK_WIDGET (nemo_desktop_window_new (monitor));
    } else {
        window = GTK_WIDGET (nemo_blank_desktop_window_new (monitor));
    }

    info->window = window;

    /* We realize it immediately so that the NEMO_DESKTOP_WINDOW_ID
       property is set so gnome-settings-daemon doesn't try to set the
       background. And we do a gdk_flush() to be sure X gets it. */

    gtk_widget_realize (GTK_WIDGET (window));
    gdk_flush ();

    gtk_application_add_window (GTK_APPLICATION (nemo_application_get_singleton ()),
                                GTK_WINDOW (window));

    manager->desktops = g_list_append (manager->desktops, info);
}
Example #4
0
static void
action_undo_callback (GtkAction *action, 
		      gpointer user_data) 
{
	NemoApplication *app;

	app = nemo_application_get_singleton ();
	nemo_undo_manager_undo (app->undo_manager);
}
Example #5
0
static void
release_application (NemoProgressInfo *info,
		     NemoProgressUIHandler *self)
{
	NemoApplication *app;

	/* release the GApplication hold we acquired */
	app = nemo_application_get_singleton ();
	g_application_release (G_APPLICATION (app));
}
Example #6
0
static void
on_open_folder_clicked (GtkWidget *button, NemoActionConfigWidget *widget)
{
    gchar *path = NULL;
    path = g_build_filename (g_get_user_data_dir (), "nemo", "actions", NULL);
    GFile *location = g_file_new_for_path (path);

    nemo_application_open_location (nemo_application_get_singleton (),
                                    location,
                                    NULL,
                                    "nemo");

    g_free (path);
    g_object_unref (location);
}
Example #7
0
static void
action_new_window_callback (GtkAction *action,
			    gpointer user_data)
{
	NemoApplication *application;
	NemoWindow *current_window, *new_window;

	current_window = NEMO_WINDOW (user_data);
	application = nemo_application_get_singleton ();

	new_window = nemo_application_create_window (
				application,
				gtk_window_get_screen (GTK_WINDOW (current_window)));
	nemo_window_slot_go_home (nemo_window_get_active_slot (new_window), FALSE);
}
static void
on_open_folder_clicked (GtkWidget *button, NemoScriptConfigWidget *widget)
{
    gchar *path = NULL;
    path = nemo_get_scripts_directory_path ();
    GFile *location = g_file_new_for_path (path);

    nemo_application_open_location (nemo_application_get_singleton (),
                                    location,
                                    NULL,
                                    "nemo");

    g_free (path);
    g_object_unref (location);
}
Example #9
0
static void
on_run_state_changed (NemoDesktopManager *manager)
{
    g_return_if_fail (NEMO_IS_DESKTOP_MANAGER (manager));

    FETCH_PRIV (manager);
    RunState new_state;

    DEBUG ("New run state...");

    /* If we're already running (showing icons,) there's no
     * change in behavior, we just keep showing. */
    if (priv->current_run_state == RUN_STATE_RUNNING) {
        return;
    }

    new_state = get_run_state (manager);

    /* If our state is INIT, we're waiting for the proxy to
     * get picked up (cinnamon starting) and still within our
     * failsafe timeout, so we just return */
    if (new_state == RUN_STATE_INIT) {
        priv->current_run_state = new_state;
        return;
    }

    /* If our state is STARTUP, RUNNING, or FAILSAFE, we can
     * cancel our failsafe timer.  We've either gotten a proxy
     * owner, given up waiting, or are now running */
    if (new_state > RUN_STATE_INIT) {
        if (priv->failsafe_timeout_id > 0) {
            g_source_remove (priv->failsafe_timeout_id);
            priv->failsafe_timeout_id = 0;
        }
    }

    /* RUNNING or FALLBACK is the final endpoint of the desktop startup
     * sequence.  Either way we trigger the desktop to start and release
     * our hold on the GApplication (the windows created in layout_changed
     * will keep the application alive from here on out.) */
    if (new_state == RUN_STATE_RUNNING || new_state == RUN_STATE_FALLBACK) {
        priv->current_run_state = new_state;
        layout_changed (manager);
        g_application_release (G_APPLICATION (nemo_application_get_singleton ()));
    }
}
Example #10
0
static void
activate_bookmark_by_quicklist (DbusmenuMenuitem *menu,
								guint timestamp,
								NemoBookmark *bookmark)
{
	g_assert (NEMO_IS_BOOKMARK (bookmark));

	GFile *location;
	NemoApplication *application;
	NemoWindow *new_window;

	location = nemo_bookmark_get_location (bookmark);

	application = nemo_application_get_singleton ();
	new_window = nemo_application_create_window (application, gdk_screen_get_default ());
	nemo_window_slot_go_to (nemo_window_get_active_slot (new_window), location, FALSE);

	g_object_unref (location);
}
Example #11
0
static void
progress_info_queued_cb (NemoProgressInfo *info,
			  NemoProgressUIHandler *self)
{
	NemoApplication *app;
	TimeoutData *data;

	/* hold GApplication so we never quit while there's an operation pending */
	app = nemo_application_get_singleton ();
	g_application_hold (G_APPLICATION (app));

	g_signal_connect (info, "finished",
			  G_CALLBACK (release_application), self);

	data = timeout_data_new (self, info);

	/* timeout for the progress window to appear */
	g_timeout_add_seconds (2,
			       (GSourceFunc) new_op_queued_timeout,
			       data);
}
Example #12
0
static void
nemo_desktop_manager_init (NemoDesktopManager *manager)
{
    NemoDesktopManagerPrivate *priv;

    manager->priv = G_TYPE_INSTANCE_GET_PRIVATE (manager, NEMO_TYPE_DESKTOP_MANAGER, NemoDesktopManagerPrivate);

    DEBUG ("Desktop Manager Initialization");

    priv = manager->priv;

    priv->scale_factor_changed_id = 0;
    priv->desktops = NULL;
    priv->desktop_on_primary_only = FALSE;

    priv->action_manager = nemo_action_manager_new ();

    priv->update_layout_idle_id = 0;

    g_signal_connect_swapped (nemo_desktop_preferences, 
                              "changed::" NEMO_PREFERENCES_SHOW_DESKTOP,
                              G_CALLBACK (queue_update_layout),
                              manager);

    g_signal_connect_swapped (nemo_desktop_preferences,
                              "changed::" NEMO_PREFERENCES_DESKTOP_LAYOUT,
                              G_CALLBACK (queue_update_layout),
                              manager);

    g_signal_connect_swapped (nemo_desktop_preferences,
                              "changed::" NEMO_PREFERENCES_USE_DESKTOP_GRID,
                              G_CALLBACK (queue_update_layout),
                              manager);

    /* Monitor the preference to have the desktop */
    /* point to the Unix home folder */

    g_signal_connect_swapped (nemo_preferences,
                              "changed::" NEMO_PREFERENCES_DESKTOP_IS_HOME_DIR,
                              G_CALLBACK (queue_update_layout),
                              manager);

    g_signal_connect_swapped (nemo_preferences,
                              "changed::" NEMO_PREFERENCES_SHOW_ORPHANED_DESKTOP_ICONS,
                              G_CALLBACK (queue_update_layout),
                              manager);

    /* If we're a cinnamon session, increase the use count temporarily for the application,
     * and establish a proxy for org.Cinnamon.  The hold prevents the GApplication from simply
     * exiting while waiting for the GAsyncReadyCallback.
     * 
     * If we're not running cinnamon,  */

    g_application_hold (G_APPLICATION (nemo_application_get_singleton ()));

    if (is_cinnamon_desktop ()) {
         g_message ("nemo-desktop: session is cinnamon, establishing proxy");

        nemo_cinnamon_proxy_new_for_bus (G_BUS_TYPE_SESSION,
                                         G_DBUS_PROXY_FLAGS_NONE,
                                         "org.Cinnamon",
                                         "/org/Cinnamon",
                                         NULL,
                                         (GAsyncReadyCallback) on_proxy_created,
                                         manager);
    } else {
        g_message ("nemo-desktop: session is not cinnamon (checked XDG_SESSION_DESKTOP,"
                   "DESKTOP_SESSION environment variables.) Applying default behavior");

        priv->other_desktop = TRUE;
        connect_fallback_signals (manager);

        /* Even though we start immediately when we can't do a proxy, we need to get out
         * of the desktop manager's init first, or else we have recursion problems. */
        g_idle_add ((GSourceFunc) fallback_startup_idle_cb, manager);
    }
}
Example #13
0
static void
drag_data_received_callback (GtkWidget *widget,
		       	     GdkDragContext *context,
		       	     int x,
		       	     int y,
		       	     GtkSelectionData *data,
		             guint info,
		             guint32 time,
			     gpointer callback_data)
{
	char **names;
	NemoApplication *application;
	int name_count;
	NemoWindow *new_window, *window;
	GdkScreen      *screen;
	gboolean new_windows_for_extras;
	char *prompt;
	char *detail;
	GFile *location;
	NemoLocationBar *self = NEMO_LOCATION_BAR (widget);

	g_assert (data != NULL);
	g_assert (callback_data == NULL);

	names = g_uri_list_extract_uris ((const gchar *) gtk_selection_data_get_data (data));

	if (names == NULL || *names == NULL) {
		g_warning ("No D&D URI's");
		g_strfreev (names);
		gtk_drag_finish (context, FALSE, FALSE, time);
		return;
	}

	window = nemo_location_bar_get_window (widget);
	new_windows_for_extras = FALSE;
	/* Ask user if they really want to open multiple windows
	 * for multiple dropped URIs. This is likely to have been
	 * a mistake.
	 */
	name_count = g_strv_length (names);
	if (name_count > 1) {
		prompt = g_strdup_printf (ngettext("Do you want to view %d location?",
						   "Do you want to view %d locations?",
						   name_count),
					  name_count);
		detail = g_strdup_printf (ngettext("This will open %d separate window.",
						   "This will open %d separate windows.",
						   name_count),
					  name_count);
		/* eel_run_simple_dialog should really take in pairs
		 * like gtk_dialog_new_with_buttons() does. */
		new_windows_for_extras = eel_run_simple_dialog
			(GTK_WIDGET (window),
			 TRUE,
			 GTK_MESSAGE_QUESTION,
			 prompt,
			 detail,
			 GTK_STOCK_CANCEL, GTK_STOCK_OK,
			 NULL) != 0 /* GNOME_OK */;

		g_free (prompt);
		g_free (detail);

		if (!new_windows_for_extras) {
			g_strfreev (names);
			gtk_drag_finish (context, FALSE, FALSE, time);
			return;
		}
	}

	nemo_location_bar_set_location (self, names[0]);
	emit_location_changed (self);

	if (new_windows_for_extras) {
		int i;

		application = nemo_application_get_singleton ();
		screen = gtk_window_get_screen (GTK_WINDOW (window));

		for (i = 1; names[i] != NULL; ++i) {
			new_window = nemo_application_create_window (application, screen);
			location = g_file_new_for_uri (names[i]);
			nemo_window_go_to (new_window, location);
			g_object_unref (location);
		}
	}

	g_strfreev (names);

	gtk_drag_finish (context, TRUE, FALSE, time);
}
Example #14
0
static void
action_close_all_windows_callback (GtkAction *action, 
				   gpointer user_data)
{
	nemo_application_close_all_windows (nemo_application_get_singleton ());
}