Пример #1
0
/**
 * get_drive_parameters - retrieve drive parameters
 * @drive_info:		driveinfo structure to fill
 **/
int get_drive_parameters(struct driveinfo *drive_info)
{
    int return_code;

    if (detect_extensions(drive_info))
	return -1;

    return_code = get_drive_parameters_without_extensions(drive_info);

    /* If geometry isn't valid, no need to try to get more info about the drive */
    /* Looks like in can confuse some optical drives */
    if (drive_info->ebios && drive_info->cbios)
	get_drive_parameters_with_extensions(drive_info);

    return return_code;
}
Пример #2
0
static void
refresh_widget (NemoExtensionConfigWidget *widget)
{
    if (widget->current_extensions != NULL) {
        g_list_free_full (widget->current_extensions, (GDestroyNotify) extension_proxy_free);
        widget->current_extensions = NULL;
    }

    nemo_config_base_widget_clear_list (NEMO_CONFIG_BASE_WIDGET (widget));

    detect_extensions (widget);

    if (widget->current_extensions == NULL) {
        GtkWidget *empty_label = gtk_label_new (NULL);
        gchar *markup = NULL;

        markup = g_strdup_printf ("<i>%s</i>", _("No extensions found"));

        gtk_label_set_markup (GTK_LABEL (empty_label), markup);
        g_free (markup);

        GtkWidget *empty_row = gtk_list_box_row_new ();
        gtk_container_add (GTK_CONTAINER (empty_row), empty_label);

        gtk_widget_show_all (empty_row);
        gtk_container_add (GTK_CONTAINER (NEMO_CONFIG_BASE_WIDGET (widget)->listbox), empty_row);
        gtk_widget_set_sensitive (GTK_WIDGET (NEMO_CONFIG_BASE_WIDGET (widget)->listbox), FALSE);
    } else {
        GtkSizeGroup *row_group, *name_group;
        GList *l;
        gchar **blacklist = g_settings_get_strv (nemo_plugin_preferences,
        		                                 NEMO_PLUGIN_PREFERENCES_DISABLED_EXTENSIONS);

        row_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
        name_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);

        for (l = widget->current_extensions; l != NULL; l=l->next) {
            gchar *markup;
            ExtensionProxy *proxy = l->data;

            gboolean active = TRUE;
            guint i = 0;

            for (i = 0; i < g_strv_length (blacklist); i++) {
                if (g_strcmp0 (blacklist[i], proxy->name) == 0) {
                    active = FALSE;
                    break;
                }
            }

            GtkWidget *w;
            GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);

            GtkWidget *button = gtk_check_button_new ();

            gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), active);
            g_signal_connect (button, "toggled", G_CALLBACK (on_check_toggled), proxy);
            gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 2);

            w = gtk_label_new (NULL);
            markup = NULL;

            if (proxy->display_name == NULL)
                markup = g_strdup_printf ("<b>%s</b>", proxy->name);
            else
                markup = g_strdup_printf ("<b>%s</b>", proxy->display_name);

            gtk_label_set_markup (GTK_LABEL (w), markup);
            gtk_label_set_xalign (GTK_LABEL (w), 0.0);

            g_clear_pointer (&markup, g_free);

            gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0);
            gtk_size_group_add_widget (name_group, w);

            w = gtk_label_new (NULL);

            if (proxy->display_name == NULL)
                markup = g_strdup (_("no information available"));
            else
                markup = g_strdup_printf ("%s", proxy->desc);

            gtk_label_set_markup (GTK_LABEL (w), markup);
            g_clear_pointer (&markup, g_free);

            gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 6);

            if (proxy->config_exec != NULL) {
                button = gtk_link_button_new_with_label ("uri://dummy", _("Configure"));
                g_signal_connect (button, "activate-link", G_CALLBACK (on_config_clicked), proxy);

                gtk_box_pack_end (GTK_BOX (box), button, FALSE, FALSE, 2);

                gtk_widget_set_tooltip_text (button, "");
            }

            GtkWidget *row = gtk_list_box_row_new ();
            gtk_container_add (GTK_CONTAINER (row), box);

            gtk_size_group_add_widget (row_group, row);

            gtk_widget_show_all (row);
            gtk_container_add (GTK_CONTAINER (NEMO_CONFIG_BASE_WIDGET (widget)->listbox), row);
        }

        g_strfreev (blacklist);
    }

    update_restart_visiblity (widget);
    nemo_config_base_widget_set_default_buttons_sensitive (NEMO_CONFIG_BASE_WIDGET (widget), widget->current_extensions != NULL);
}
static void
refresh_widget (NemoExtensionConfigWidget *widget)
{
    if (widget->current_extensions != NULL) {
        g_list_free_full (widget->current_extensions, (GDestroyNotify) extension_proxy_free);
        widget->current_extensions = NULL;
    }

    nemo_config_base_widget_clear_list (NEMO_CONFIG_BASE_WIDGET (widget));

    detect_extensions (widget);

    if (widget->current_extensions == NULL) {
        GtkWidget *empty_label = gtk_label_new (NULL);
        gchar *markup = NULL;

        markup = g_strdup_printf ("<i>%s</i>", _("No extensions found"));

        gtk_label_set_markup (GTK_LABEL (empty_label), markup);
        g_free (markup);

        GtkWidget *empty_row = gtk_list_box_row_new ();
        gtk_container_add (GTK_CONTAINER (empty_row), empty_label);

        gtk_widget_show_all (empty_row);
        gtk_container_add (GTK_CONTAINER (NEMO_CONFIG_BASE_WIDGET (widget)->listbox), empty_row);
    } else {
        GList *l;
        gchar **blacklist = g_settings_get_strv (widget->settings, BLACKLIST_KEY);

        for (l = widget->current_extensions; l != NULL; l=l->next) {
            ExtensionProxy *proxy = l->data;

            gboolean active = TRUE;
            gint i = 0;

            for (i = 0; i < g_strv_length (blacklist); i++) {
                if (g_strcmp0 (blacklist[i], proxy->name) == 0) {
                    active = FALSE;
                    break;
                }
            }

            GtkWidget *w;
            GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

            GtkWidget *button = gtk_check_button_new ();

            gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), active);
            g_signal_connect (button, "toggled", G_CALLBACK (on_check_toggled), proxy);
            gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 2);

            w = gtk_label_new (NULL);
            gchar *markup = NULL;

            if (proxy->display_name == NULL)
                markup = g_strdup_printf ("%s - <i>%s</i>", proxy->name, _("no information available"));
            else
                markup = g_strdup_printf ("%s - <i>%s</i>", proxy->display_name, proxy->desc);

            gtk_label_set_markup (GTK_LABEL (w), markup);
            g_free (markup);

            gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 2);

            GtkWidget *row = gtk_list_box_row_new ();
            gtk_container_add (GTK_CONTAINER (row), box);

            gtk_widget_show_all (row);
            gtk_container_add (GTK_CONTAINER (NEMO_CONFIG_BASE_WIDGET (widget)->listbox), row);
        }

        g_strfreev (blacklist);
    }

    update_restart_visiblity (widget);
    nemo_config_base_widget_set_default_buttons_sensitive (NEMO_CONFIG_BASE_WIDGET (widget), widget->current_extensions != NULL);
}