Example #1
0
/* Callback when the configuration dialog has recorded a configuration change. */
static gboolean dirmenu_apply_configuration(gpointer user_data)
{
    GtkWidget * p = user_data;
    DirMenuPlugin * dm = lxpanel_plugin_get_data(p);
    char * path = dm->path;

    /* Normalize path */
    if (path == NULL)
        dm->path = g_strdup(fm_get_home_dir());
    else if (path[0] == '~')
    {
        dm->path = expand_tilda(path);
        g_free(path);
    }

    /* Save configuration */
    config_group_set_string(dm->settings, "path", dm->path);
    config_group_set_string(dm->settings, "name", dm->name);
    config_group_set_string(dm->settings, "image", dm->image);

    lxpanel_button_set_icon(p, ((dm->image != NULL) ? dm->image : "file-manager"), -1);
    lxpanel_button_set_label(p, dm->name);

    gtk_widget_set_tooltip_text(p, dm->path);
    return FALSE;
}
Example #2
0
/* Callback when the configuration dialog has recorded a configuration change. */
static gboolean wincmd_apply_configuration(gpointer user_data)
{
    GtkWidget * p = user_data;
    WinCmdPlugin * wc = lxpanel_plugin_get_data(p);

    /* Just save settings */
    config_group_set_string(wc->settings, "image", wc->image);
    config_group_set_string(wc->settings, "Button1",
                            wincmd_names[wc->button_1_command]);
    config_group_set_string(wc->settings, "Button2",
                            wincmd_names[wc->button_2_command]);
    config_group_set_int(wc->settings, "Toggle", wc->toggle_preference);
    return FALSE;
}
Example #3
0
static gboolean applyConfig(gpointer p)
{
    thermal *th = lxpanel_plugin_get_data(p);
    int critical;
    ENTER;

    if (th->str_cl_normal) gdk_color_parse(th->str_cl_normal, &th->cl_normal);
    if (th->str_cl_warning1) gdk_color_parse(th->str_cl_warning1, &th->cl_warning1);
    if (th->str_cl_warning2) gdk_color_parse(th->str_cl_warning2, &th->cl_warning2);

    remove_all_sensors(th);
    if(th->sensor == NULL) th->auto_sensor = TRUE;
    if(th->auto_sensor) check_sensors(th);
    else if (strncmp(th->sensor, "/sys/", 5) != 0)
        add_sensor(th, th->sensor, th->sensor, proc_get_temperature, proc_get_critical);
    else if (strncmp(th->sensor, "/sys/class/hwmon/", 17) != 0)
        add_sensor(th, th->sensor, th->sensor, sysfs_get_temperature, sysfs_get_critical);
    else
        add_sensor(th, th->sensor, th->sensor, hwmon_get_temperature, hwmon_get_critical);

    critical = get_critical(th);

    if(th->not_custom_levels){
        th->warning1 = critical - 10;
        th->warning2 = critical - 5;
    }

    config_group_set_string(th->settings, "NormalColor", th->str_cl_normal);
    config_group_set_string(th->settings, "Warning1Color", th->str_cl_warning1);
    config_group_set_string(th->settings, "Warning2Color", th->str_cl_warning2);
    config_group_set_int(th->settings, "AutomaticLevels", th->not_custom_levels);
    /* TODO: clean obsolete setting
    config_setting_remove(th->settings, "CustomLevels"); */
    config_group_set_int(th->settings, "Warning1Temp", th->warning1);
    config_group_set_int(th->settings, "Warning2Temp", th->warning2);
    config_group_set_int(th->settings, "AutomaticSensor", th->auto_sensor);
    config_group_set_string(th->settings, "Sensor", th->sensor);
    RET(FALSE);
}
Example #4
0
static gboolean
monitors_apply_config (gpointer user_data)
{
    ENTER;
    GtkWidget *p = user_data;
    MonitorsPlugin *mp;
    mp = lxpanel_plugin_get_data(p);

    int i;
    int current_n_monitors = 0;

start:
    for (i = 0; i < N_MONITORS; i++)
    {
        if (mp->displayed_monitors[i])
            current_n_monitors++;

        if (mp->displayed_monitors[i] && !mp->monitors[i])
        {
            /* We've just activated monitor<i> */
            mp->monitors[i] = monitors_add_monitor(p, mp,
                                                   update_functions[i],
                                                   tooltip_update[i],
                                                   colors[i]);
            /*
             * It is probably best for users if their monitors are always
             * displayed in the same order : the CPU monitor always on the left,
             * the RAM monitor always on the right of the CPU monitor (if the
             * CPU monitor is displayed), etc. That's why we do not just use
             * gtk_box_pack_start/gtk_box_pack_end, and use
             * gtk_box_reorder_child.
             */
            gtk_box_reorder_child(GTK_BOX(p),
                                  mp->monitors[i]->da,current_n_monitors-1);
        }
        else if (!mp->displayed_monitors[i] && mp->monitors[i])
        {
            /* We've just removed monitor<i> */
            gtk_widget_destroy(mp->monitors[i]->da);
            monitor_free(mp->monitors[i]);
            mp->monitors[i] = NULL;
        }
        if (mp->monitors[i] &&
            strncmp(mp->monitors[i]->color, colors[i], COLOR_SIZE) != 0)
        {
            /* We've changed the color */
            monitor_set_foreground_color(mp, mp->monitors[i], colors[i]);
        }
    }

    /* Workaround meant to prevent users to display no monitor at all.
     * FIXME : write something clean. When there is only one monitor displayed,
     * its toggle button should not be clickable in the prefs. */
    if (current_n_monitors == 0)
    {
        mp->displayed_monitors[0] = 1;
        goto start;
    }
    config_group_set_int(mp->settings, "DisplayCPU", mp->displayed_monitors[CPU_POSITION]);
    config_group_set_int(mp->settings, "DisplayRAM", mp->displayed_monitors[MEM_POSITION]);
    config_group_set_string(mp->settings, "Action", mp->action);
    config_group_set_string(mp->settings, "CPUColor",
                            mp->monitors[CPU_POSITION] ? colors[CPU_POSITION] : NULL);
    config_group_set_string(mp->settings, "RAMColor",
                            mp->monitors[MEM_POSITION] ? colors[MEM_POSITION] : NULL);

    RET(FALSE);
}