static void
caja_mime_application_chooser_finalize (GObject *object)
{
    CajaMimeApplicationChooser *chooser;

    chooser = CAJA_MIME_APPLICATION_CHOOSER (object);

    if (chooser->details->refresh_timeout)
    {
        g_source_remove (chooser->details->refresh_timeout);
    }

    g_signal_handlers_disconnect_by_func (caja_signaller_get_current (),
                                          G_CALLBACK (mime_type_data_changed_cb),
                                          chooser);


    g_free (chooser->details->uri);
    g_free (chooser->details->content_type);
    g_free (chooser->details->extension);
    g_free (chooser->details->type_description);
    g_free (chooser->details->orig_mime_type);

    g_free (chooser->details);

    G_OBJECT_CLASS (caja_mime_application_chooser_parent_class)->finalize (object);
}
Example #2
0
static gboolean
emit_user_dirs_changed_idle (gpointer data)
{
    g_signal_emit_by_name (caja_signaller_get_current (),
                           "user_dirs_changed");
    user_dirs_changed_tag = 0;
    return FALSE;
}
Example #3
0
static void
caja_emblem_sidebar_init (CajaEmblemSidebar *emblem_sidebar)
{
    GtkWidget *widget;

    emblem_sidebar->details = g_new0 (CajaEmblemSidebarDetails, 1);

    create_popup_menu (emblem_sidebar);

    widget = caja_emblem_sidebar_create_container (emblem_sidebar);
    caja_emblem_sidebar_populate (emblem_sidebar);

    g_signal_connect_object (caja_signaller_get_current (),
                             "emblems_changed",
                             G_CALLBACK (emblems_changed_callback), emblem_sidebar, 0);

    gtk_box_pack_start (GTK_BOX (emblem_sidebar), widget,
                        TRUE, TRUE, 0);
}
/* This will check if the application the user wanted exists will return that
 * application.  If it doesn't exist, it will create one and return that.
 * It also sets the app info as the default for this type.
 */
static GAppInfo *
add_or_find_application (CajaOpenWithDialog *dialog)
{
    GAppInfo *app;
    char *app_name;
    const char *commandline;
    GError *error;
    gboolean success, should_set_default;
    char *message;
    GList *applications;

    error = NULL;
    app = NULL;
    if (dialog->details->selected_app_info)
    {
        app = g_object_ref (dialog->details->selected_app_info);
    }
    else
    {
        commandline = gtk_entry_get_text (GTK_ENTRY (dialog->details->entry));
        app_name = get_app_name (commandline, &error);
        if (app_name != NULL)
        {
            app = g_app_info_create_from_commandline (commandline,
                    app_name,
                    G_APP_INFO_CREATE_NONE,
                    &error);
            g_free (app_name);
        }
    }

    if (app == NULL)
    {
        message = g_strdup_printf (_("Could not add application to the application database: %s"), error->message);
        eel_show_error_dialog (_("Could not add application"),
                               message,
                               GTK_WINDOW (dialog));
        g_free (message);
        g_error_free (error);
        return NULL;
    }

    should_set_default = (dialog->details->add_mode) ||
                         (!dialog->details->add_mode &&
                          gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->details->checkbox)));
    success = TRUE;

    if (should_set_default)
    {
        if (dialog->details->content_type)
        {
            success = g_app_info_set_as_default_for_type (app,
                      dialog->details->content_type,
                      &error);
        }
        else
        {
            success = g_app_info_set_as_default_for_extension (app,
                      dialog->details->extension,
                      &error);
        }
    }
    else
    {
        applications = g_app_info_get_all_for_type (dialog->details->content_type);
        if (dialog->details->content_type && applications != NULL)
        {
            /* we don't care about reporting errors here */
            g_app_info_add_supports_type (app,
                                          dialog->details->content_type,
                                          NULL);
        }

        if (applications != NULL)
        {
            g_list_foreach(applications, (GFunc) g_object_unref, NULL);
            g_list_free(applications);
        }
    }

    if (!success && should_set_default)
    {
        message = g_strdup_printf (_("Could not set application as the default: %s"), error->message);
        eel_show_error_dialog (_("Could not set as default application"),
                               message,
                               GTK_WINDOW (dialog));
        g_free (message);
        g_error_free (error);
    }

    g_signal_emit_by_name (caja_signaller_get_current (),
                           "mime_data_changed");
    return app;
}
Example #5
0
static void
caja_history_sidebar_init (CajaHistorySidebar *sidebar)
{
    GtkTreeView       *tree_view;
    GtkTreeViewColumn *col;
    GtkCellRenderer   *cell;
    GtkListStore      *store;
    GtkTreeSelection  *selection;

    tree_view = GTK_TREE_VIEW (gtk_tree_view_new ());
    gtk_tree_view_set_headers_visible (tree_view, FALSE);
    gtk_widget_show (GTK_WIDGET (tree_view));

    col = GTK_TREE_VIEW_COLUMN (gtk_tree_view_column_new ());

    cell = gtk_cell_renderer_pixbuf_new ();
    gtk_tree_view_column_pack_start (col, cell, FALSE);
    gtk_tree_view_column_set_attributes (col, cell,
                                         "surface", HISTORY_SIDEBAR_COLUMN_ICON,
                                         NULL);

    cell = gtk_cell_renderer_text_new ();
    gtk_tree_view_column_pack_start (col, cell, TRUE);
    gtk_tree_view_column_set_attributes (col, cell,
                                         "text", HISTORY_SIDEBAR_COLUMN_NAME,
                                         NULL);

    gtk_tree_view_column_set_fixed_width (col, CAJA_ICON_SIZE_SMALLER);
    gtk_tree_view_append_column (tree_view, col);

    store = gtk_list_store_new (HISTORY_SIDEBAR_COLUMN_COUNT,
                                CAIRO_GOBJECT_TYPE_SURFACE,
                                G_TYPE_STRING,
                                CAJA_TYPE_BOOKMARK);

    gtk_tree_view_set_model (tree_view, GTK_TREE_MODEL (store));
    g_object_unref (store);

    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sidebar),
                                    GTK_POLICY_AUTOMATIC,
                                    GTK_POLICY_AUTOMATIC);
    gtk_scrolled_window_set_hadjustment (GTK_SCROLLED_WINDOW (sidebar), NULL);
    gtk_scrolled_window_set_vadjustment (GTK_SCROLLED_WINDOW (sidebar), NULL);
    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sidebar), GTK_SHADOW_IN);
    gtk_scrolled_window_set_overlay_scrolling (GTK_SCROLLED_WINDOW (sidebar), FALSE);

    gtk_container_add (GTK_CONTAINER (sidebar), GTK_WIDGET (tree_view));
    gtk_widget_show (GTK_WIDGET (sidebar));

    sidebar->tree_view = tree_view;

    selection = gtk_tree_view_get_selection (tree_view);
    gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);

    g_signal_connect_object
    (tree_view, "row_activated",
     G_CALLBACK (row_activated_callback), sidebar, 0);

    g_signal_connect_object (caja_signaller_get_current (),
                             "history_list_changed",
                             G_CALLBACK (history_changed_callback), sidebar, 0);

    g_signal_connect (tree_view, "button-press-event",
                      G_CALLBACK (button_press_event_callback), sidebar);

    g_signal_connect_swapped (caja_preferences,
                              "changed::" CAJA_PREFERENCES_CLICK_POLICY,
                              G_CALLBACK(click_policy_changed_callback),
                              sidebar);
    update_click_policy (sidebar);
}
static void
send_emblems_changed (void)
{
    g_signal_emit_by_name (caja_signaller_get_current (),
                           "emblems_changed");
}