예제 #1
0
static void save_rc_clicked(GtkWidget *widget, gpointer user_data)
{
    gchar *filename = NULL;
    CtkConfig *ctk_config = CTK_CONFIG(user_data);
    CtkWindow *ctk_window =
        CTK_WINDOW(ctk_get_parent_window(GTK_WIDGET(ctk_config)));

    filename =
        ctk_get_filename_from_dialog("Please select a file to save to.",
                                     GTK_WINDOW(ctk_window),
                                     ctk_config->rc_filename ?
                                         ctk_config->rc_filename :
                                         DEFAULT_RC_FILE);

    if (!filename) {
        return;
    }

    g_free(ctk_config->rc_filename);
    ctk_config->rc_filename = filename;

    /* write the configuration file */
    add_special_config_file_attributes(ctk_window);
    nv_write_config_file(ctk_config->rc_filename, ctk_config->pCtrlSystem,
                         ctk_window->attribute_list, ctk_config->conf);
}
예제 #2
0
static void reset_defaults(GtkButton *button, gpointer user_data)
{
    CtkXVideo *ctk_xvideo = CTK_XVIDEO(user_data);
    
    /*
     * XXX should we expose separate buttons for each adaptor's
     * defaults?
     */
    
    NvCtrlSetAttribute(ctk_xvideo->handle,
                       NV_CTRL_ATTR_XV_OVERLAY_SET_DEFAULTS, 1);

    NvCtrlSetAttribute(ctk_xvideo->handle,
                       NV_CTRL_ATTR_XV_TEXTURE_SET_DEFAULTS, 1);
    
    NvCtrlSetAttribute(ctk_xvideo->handle,
                       NV_CTRL_ATTR_XV_BLITTER_SET_DEFAULTS, 1);
    

    reset_slider(ctk_xvideo, ctk_xvideo->overlay_saturation,
                 NV_CTRL_ATTR_XV_OVERLAY_SATURATION);
    
    reset_slider(ctk_xvideo, ctk_xvideo->overlay_contrast,
                 NV_CTRL_ATTR_XV_OVERLAY_CONTRAST);
    
    reset_slider(ctk_xvideo, ctk_xvideo->overlay_brightness,
                 NV_CTRL_ATTR_XV_OVERLAY_BRIGHTNESS);
    
    reset_slider(ctk_xvideo, ctk_xvideo->overlay_hue,
                 NV_CTRL_ATTR_XV_OVERLAY_HUE);

    reset_check_button(ctk_xvideo, ctk_xvideo->texture_sync_to_blank,
                       NV_CTRL_ATTR_XV_TEXTURE_SYNC_TO_VBLANK);
    
    reset_slider(ctk_xvideo, ctk_xvideo->texture_contrast,
                 NV_CTRL_ATTR_XV_TEXTURE_CONTRAST);
    
    reset_slider(ctk_xvideo, ctk_xvideo->texture_brightness,
                 NV_CTRL_ATTR_XV_TEXTURE_BRIGHTNESS);

    reset_slider(ctk_xvideo, ctk_xvideo->texture_hue,
                 NV_CTRL_ATTR_XV_TEXTURE_HUE);

    reset_slider(ctk_xvideo, ctk_xvideo->texture_saturation,
                 NV_CTRL_ATTR_XV_TEXTURE_SATURATION);


    reset_check_button(ctk_xvideo, ctk_xvideo->blitter_sync_to_blank,
                       NV_CTRL_ATTR_XV_BLITTER_SYNC_TO_VBLANK);
    

    gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);

    ctk_config_statusbar_message
        (CTK_CONFIG(ctk_xvideo->ctk_config),
         "Reset XVideo hardware defaults.");
}
예제 #3
0
static void time_interval_edited(GtkCellRendererText *cell,
                                 const gchar         *path_string,
                                 const gchar         *new_text,
                                 gpointer             user_data)
{
    CtkConfig *ctk_config = CTK_CONFIG(user_data);
    GtkTreeModel *model = GTK_TREE_MODEL(ctk_config->list_store);
    GtkTreePath *path;
    GtkTreeIter iter;
    guint handle;
    GSourceFunc function;
    gpointer data;
    guint interval;
    TimerConfigProperty *timer_config;
    gboolean owner_enabled;

    interval = strtol(new_text, (char **)NULL, 10);
    
    if ((interval == 0) ||
        (interval == UINT_MAX)) return;

    if (interval > MAX_TIME_INTERVAL) interval = MAX_TIME_INTERVAL;
    if (interval < MIN_TIME_INTERVAL) interval = MIN_TIME_INTERVAL;

    path = gtk_tree_path_new_from_string(path_string);
    gtk_tree_model_get_iter(model, &iter, path);
    gtk_tree_path_free(path);

    gtk_tree_model_get(model, &iter,
                       TIMER_CONFIG_COLUMN, &timer_config,
                       OWNER_ENABLE_COLUMN, &owner_enabled,
                       HANDLE_COLUMN, &handle,
                       FUNCTION_COLUMN, &function,
                       DATA_COLUMN, &data,
                       -1);

    timer_config->interval = interval;
    
    /* Restart the timer if it is already running */

    if (timer_config->user_enabled && owner_enabled) {
        
        g_source_remove(handle);
        
        handle = g_timeout_add(interval, function, data);
        
        gtk_list_store_set(ctk_config->list_store, &iter,
                           HANDLE_COLUMN, handle, -1);
    }
}
예제 #4
0
static void show_quit_dialog_toggled(GtkWidget *widget, gpointer user_data)
{
    CtkConfig *ctk_config = CTK_CONFIG(user_data);
    gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));

    if (active) {
        ctk_config->conf->booleans |= CONFIG_PROPERTIES_SHOW_QUIT_DIALOG;
    } else {
        ctk_config->conf->booleans &= ~CONFIG_PROPERTIES_SHOW_QUIT_DIALOG;
    }

    ctk_config_statusbar_message(ctk_config, 
                                 "Quit confirmation dialog %s.",
                                 active ? "enabled" : "disabled");
}
예제 #5
0
static void tooltips_toggled(GtkWidget *widget, gpointer user_data)
{
    CtkConfig *ctk_config = CTK_CONFIG(user_data);
    gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));

    if (active) {
        gtk_tooltips_enable(ctk_config->tooltips.object);
        ctk_config->conf->booleans |= CONFIG_PROPERTIES_TOOLTIPS;
    } else {
        gtk_tooltips_disable(ctk_config->tooltips.object);
        ctk_config->conf->booleans &= ~CONFIG_PROPERTIES_TOOLTIPS;
    }

    ctk_config_statusbar_message(ctk_config, "Tooltips %s.", 
                                 active ? "enabled" : "disabled");
}
예제 #6
0
static void display_name_toggled(GtkWidget *widget, gpointer user_data)
{
    CtkConfig *ctk_config = CTK_CONFIG(user_data);
    gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));

    if (active) {
        ctk_config->conf->booleans |=
            CONFIG_PROPERTIES_INCLUDE_DISPLAY_NAME_IN_CONFIG_FILE;
    } else {
        ctk_config->conf->booleans &=
            ~CONFIG_PROPERTIES_INCLUDE_DISPLAY_NAME_IN_CONFIG_FILE;
    }

    ctk_config_statusbar_message(ctk_config, 
                                 "Including X Display Names in Config File %s.",
                                 active ? "enabled" : "disabled");
}
예제 #7
0
static void slider_text_entries_toggled(GtkWidget *widget, gpointer user_data)
{
    CtkConfig *ctk_config = CTK_CONFIG(user_data);
    gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));

    if (active) {
        ctk_config->conf->booleans |= CONFIG_PROPERTIES_SLIDER_TEXT_ENTRIES;
    } else {
        ctk_config->conf->booleans &= ~CONFIG_PROPERTIES_SLIDER_TEXT_ENTRIES;
    }

    ctk_config_statusbar_message(ctk_config, 
                                 "Slider text entries %s.",
                                 active ? "enabled" : "disabled");
    
    g_signal_emit(ctk_config, signals[0], 0);
}
예제 #8
0
static void timer_enable_toggled(GtkCellRendererToggle *cell,
                                 gchar                 *path_string,
                                 gpointer               user_data)
{
    CtkConfig *ctk_config = CTK_CONFIG(user_data);
    GtkTreeModel *model = GTK_TREE_MODEL(ctk_config->list_store);
    GtkTreePath *path;
    GtkTreeIter iter;
    guint handle;
    GSourceFunc function;
    gpointer data;
    TimerConfigProperty *timer_config;
    gboolean owner_enabled;
    
    path = gtk_tree_path_new_from_string(path_string);
    gtk_tree_model_get_iter(model, &iter, path);
    gtk_tree_path_free(path);

    gtk_tree_model_get(model, &iter,
                       TIMER_CONFIG_COLUMN, &timer_config,
                       OWNER_ENABLE_COLUMN, &owner_enabled,
                       HANDLE_COLUMN, &handle,
                       FUNCTION_COLUMN, &function,
                       DATA_COLUMN, &data,
                       -1);

    timer_config->user_enabled ^= 1;

    /* Start/stop the timer only when the owner widget has enabled it */

    if (owner_enabled) {
        if (timer_config->user_enabled) {
            handle = g_timeout_add(timer_config->interval, function, data);
            gtk_list_store_set(ctk_config->list_store, &iter,
                               HANDLE_COLUMN, handle, -1);
        } else {
            g_source_remove(handle);
        }
    }

    ctk_config_statusbar_message(ctk_config, "Timer \"%s\" %s.",
                                 timer_config->description,
                                 timer_config->user_enabled ? 
                                     "enabled" : "disabled");
}
예제 #9
0
static void update_rules_on_profile_name_change_toggled(GtkWidget *widget,
                                                        gpointer user_data)
{
    CtkConfig *ctk_config = CTK_CONFIG(user_data);
    gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));

    if (active) {
        ctk_config->conf->booleans |=
            CONFIG_PROPERTIES_UPDATE_RULES_ON_PROFILE_NAME_CHANGE;
    } else {
        ctk_config->conf->booleans &=
            ~CONFIG_PROPERTIES_UPDATE_RULES_ON_PROFILE_NAME_CHANGE;
    }

    ctk_config_statusbar_message(ctk_config,
                                 "Updating rules when an application profile "
                                 "name changes is %s.",
                                 active ? "enabled" : "disabled");
}
예제 #10
0
static void display_status_bar_toggled(
    GtkWidget *widget,
    gpointer user_data
)
{
    CtkConfig *ctk_config = CTK_CONFIG(user_data);

    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
        gtk_widget_show(ctk_config->status_bar.widget);
        ctk_config->conf->booleans |= CONFIG_PROPERTIES_DISPLAY_STATUS_BAR;
        ctk_config_statusbar_message(ctk_config, "Status bar enabled.");
    } else {
        gtk_widget_hide(ctk_config->status_bar.widget);

        if (ctk_config->status_bar.prev_message_id) {
            gtk_statusbar_remove(GTK_STATUSBAR(ctk_config->status_bar.widget),
                                 1, ctk_config->status_bar.prev_message_id);
        }
    
        ctk_config->status_bar.prev_message_id = 0;

        ctk_config->conf->booleans &= ~CONFIG_PROPERTIES_DISPLAY_STATUS_BAR;
    }
}
예제 #11
0
GtkWidget* ctk_config_new(ConfigProperties *conf, CtrlSystem *pCtrlSystem)
{
    gint i;
    GObject *object;
    CtkConfig *ctk_config;
    GtkWidget *hbox;
    GtkWidget *vbox;
    GtkWidget *banner;
    GtkWidget *label;
    GtkWidget *hseparator;
    GtkWidget *check_button;
    GtkWidget *alignment;
    gboolean b;

    struct {
        const char *label;
        unsigned int mask;
        GCallback toggled_callback;
        const char *help_text;
    } config_check_button_entries[] =
    {
        {
            "Display Status Bar",
            CONFIG_PROPERTIES_DISPLAY_STATUS_BAR,
            G_CALLBACK(display_status_bar_toggled),
            __status_bar_help
        },
        {
            "Slider Text Entries",
            CONFIG_PROPERTIES_SLIDER_TEXT_ENTRIES,
            G_CALLBACK(slider_text_entries_toggled),
            __slider_text_entries_help
        },
        {
            "Include X Display Names in the Config File",
            CONFIG_PROPERTIES_INCLUDE_DISPLAY_NAME_IN_CONFIG_FILE,
            G_CALLBACK(display_name_toggled),
            __x_display_names_help
        },
        {
            "Show \"Really Quit?\" Dialog",
            CONFIG_PROPERTIES_SHOW_QUIT_DIALOG,
            G_CALLBACK(show_quit_dialog_toggled),
            __show_quit_dialog_help
        },
        {
            "Update Rules when an Application Profile Name changes",
            CONFIG_PROPERTIES_UPDATE_RULES_ON_PROFILE_NAME_CHANGE,
            G_CALLBACK(update_rules_on_profile_name_change_toggled),
            __update_rules_on_profile_name_change_help
        },

    };

    object = g_object_new(CTK_TYPE_CONFIG, NULL);

    ctk_config = CTK_CONFIG(object);

    ctk_config->conf = conf;
    ctk_config->pCtrlSystem = pCtrlSystem;

    gtk_box_set_spacing(GTK_BOX(ctk_config), 10);
    

    /* initialize the statusbar widget */
    ctk_statusbar_init(&ctk_config->status_bar);

#ifndef CTK_GTK3
    /* initialize the tooltips widget */

    ctk_config->tooltips.object = gtk_tooltips_new();
#endif

    /* banner */

    banner = ctk_banner_image_new(BANNER_ARTWORK_CONFIG);
    gtk_box_pack_start(GTK_BOX(ctk_config), banner, FALSE, FALSE, 0);
    
    /* "nvidia-settings Configuration" */

    hbox = gtk_hbox_new (FALSE, 5);
    gtk_box_pack_start(GTK_BOX(ctk_config), hbox, FALSE, FALSE, 0);

    label = gtk_label_new("nvidia-settings Configuration");
    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);

    hseparator = gtk_hseparator_new();
    gtk_box_pack_start(GTK_BOX(hbox), hseparator, TRUE, TRUE, 0);
    
    /* check buttons: Enable tooltips, Display statusbar, and Display
       slider text entries */

    vbox = gtk_vbox_new(FALSE, 2);
    gtk_box_pack_start(GTK_BOX(ctk_config), vbox, FALSE, FALSE, 0);

    ctk_config->help_data = NULL;

    for (i = 0; i < ARRAY_LEN(config_check_button_entries); i++) {
        label = gtk_label_new(config_check_button_entries[i].label);

        check_button = gtk_check_button_new();
        gtk_container_add(GTK_CONTAINER(check_button), label);

        b = !!(ctk_config->conf->booleans & config_check_button_entries[i].mask);

        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button), b);
        gtk_box_pack_start(GTK_BOX(vbox), check_button, FALSE, FALSE, 0);
        g_signal_connect(G_OBJECT(check_button), "toggled",
                         config_check_button_entries[i].toggled_callback,
                         ctk_config);
        ctk_config_set_tooltip_and_add_help_data(ctk_config,
                                                 check_button,
                                                 &ctk_config->help_data,
                                                 config_check_button_entries[i].label,
                                                 config_check_button_entries[i].help_text,
                                                 NULL);
    }

    ctk_config->help_data = g_list_reverse(ctk_config->help_data);
    
    /* timer list */
    
    ctk_config->timer_list_box = gtk_hbox_new(FALSE, 0);
    ctk_config->timer_list = create_timer_list(ctk_config);
    g_object_ref(ctk_config->timer_list);
    ctk_config->timer_list_visible = FALSE;

    gtk_box_pack_start(GTK_BOX(ctk_config), ctk_config->timer_list_box,
                       TRUE, TRUE, 0); 


    /* "Save Current Configuration" button */

    label = gtk_label_new("Save Current Configuration");
    hbox  = gtk_hbox_new(FALSE, 0);
    ctk_config->button_save_rc = gtk_button_new();
    alignment = gtk_alignment_new(1, 1, 0, 0);

    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 15);
    gtk_container_add(GTK_CONTAINER(ctk_config->button_save_rc), hbox);
    gtk_container_add(GTK_CONTAINER(alignment), ctk_config->button_save_rc);
    gtk_box_pack_start(GTK_BOX(ctk_config), alignment, TRUE, TRUE, 0);

    /* Create the file selector for rc file */
    g_signal_connect(G_OBJECT(ctk_config->button_save_rc), "clicked",
                     G_CALLBACK(save_rc_clicked),
                     (gpointer) ctk_config);

    ctk_config_set_tooltip(ctk_config, ctk_config->button_save_rc,
                           __save_current_config_help);

    ctk_config->rc_filename = NULL;

    gtk_widget_show_all(GTK_WIDGET(ctk_config));

    return GTK_WIDGET(ctk_config);
}
예제 #12
0
static void config_finalize(GObject *object)
{
    CtkConfig *ctk_config = CTK_CONFIG(object);
    ctk_help_data_list_free_full(ctk_config->help_data);
}