void widget_hscale_refresh(variable *var) { GList *element; gchar *act; gint initialised = FALSE; #ifdef DEBUG_TRANSITS fprintf(stderr, "%s(): Entering.\n", __func__); #endif /* Get initialised state of widget */ if (g_object_get_data(G_OBJECT(var->Widget), "_initialised") != NULL) initialised = (gint)g_object_get_data(G_OBJECT(var->Widget), "_initialised"); /* The <input> tag... */ act = attributeset_get_first(&element, var->Attributes, ATTR_INPUT); while (act) { if (input_is_shell_command(act)) widget_hscale_input_by_command(var, act + 8); /* input file stock = "File:", input file = "File:/path/to/file" */ if (strncasecmp(act, "file:", 5) == 0 && strlen(act) > 5) { if (!initialised) { /* Check for file-monitor and create if requested */ widget_file_monitor_try_create(var, act + 5); } widget_hscale_input_by_file(var, act + 5); } act = attributeset_get_next(&element, var->Attributes, ATTR_INPUT); } /* The <item> tags... */ if (attributeset_is_avail(var->Attributes, ATTR_ITEM)) { #if GTK_CHECK_VERSION(2,16,0) gtk_scale_clear_marks(GTK_SCALE(var->Widget)); #endif widget_hscale_input_by_items(var); } /* Initialise these only once at start-up */ if (!initialised) { /* Apply directives */ if (attributeset_is_avail(var->Attributes, ATTR_LABEL)) fprintf(stderr, "%s(): <label> not implemented for this widget.\n", __func__); if (attributeset_is_avail(var->Attributes, ATTR_DEFAULT)) { gtk_range_set_value(GTK_RANGE(var->Widget), atof(attributeset_get_first(&element, var->Attributes, ATTR_DEFAULT))); } if (attributeset_is_avail(var->Attributes, ATTR_HEIGHT)) fprintf(stderr, "%s(): <height> not implemented for this widget.\n", __func__); if (attributeset_is_avail(var->Attributes, ATTR_WIDTH)) fprintf(stderr, "%s(): <width> not implemented for this widget.\n", __func__); if ((attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "false")) || (attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "disabled")) || /* Deprecated */ (attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "no")) || (attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "0"))) gtk_widget_set_sensitive(var->Widget, FALSE); /* Connect signals */ g_signal_connect(G_OBJECT(var->Widget), "value-changed", G_CALLBACK(on_any_widget_value_changed_event), (gpointer)var->Attributes); } #ifdef DEBUG_TRANSITS fprintf(stderr, "%s(): Exiting.\n", __func__); #endif }
/*********************************************************************** * Refresh * ***********************************************************************/ void widget_timer_refresh(variable *var) { GList *element; gchar *act; gchar text[256]; gchar *value; gint initialised = FALSE; gint milliseconds = FALSE; guint interval = 1; guint timer_id; #ifdef DEBUG_TRANSITS fprintf(stderr, "%s(): Entering.\n", __func__); #endif /* Get initialised state of widget */ if (g_object_get_data(G_OBJECT(var->Widget), "_initialised") != NULL) initialised = (gint)g_object_get_data(G_OBJECT(var->Widget), "_initialised"); /* The <input> tag... */ act = attributeset_get_first(&element, var->Attributes, ATTR_INPUT); while (act) { if (input_is_shell_command(act)) widget_timer_input_by_command(var, act + 8); /* input file stock = "File:", input file = "File:/path/to/file" */ if (strncasecmp(act, "file:", 5) == 0 && strlen(act) > 5) { if (!initialised) { /* Check for file-monitor and create if requested */ widget_file_monitor_try_create(var, act + 5); } widget_timer_input_by_file(var, act + 5); } act = attributeset_get_next(&element, var->Attributes, ATTR_INPUT); } /* The <item> tags... */ if (attributeset_is_avail(var->Attributes, ATTR_ITEM)) widget_timer_input_by_items(var); /* Initialise these only once at start-up */ if (!initialised) { /* Create the timer */ if (var->widget_tag_attr && (value = get_tag_attribute(var->widget_tag_attr, "milliseconds")) && ((strcasecmp(value, "true") == 0) || (strcasecmp(value, "yes") == 0) || (atoi(value) == 1))) { milliseconds = TRUE; interval = 1000; /* Set default of 1000ms */ } if (var->widget_tag_attr && (value = get_tag_attribute(var->widget_tag_attr, "interval"))) { interval = atoi(value); } if (milliseconds) { /* Precision in milliseconds */ timer_id = g_timeout_add( interval, widget_timer_timer_callback, (gpointer)var); } else { /* Precision in seconds (default) */ timer_id = g_timeout_add_seconds( interval, widget_timer_timer_callback, (gpointer)var); } /* Store the timer_id as a piece of widget data */ g_object_set_data(G_OBJECT(var->Widget), "_timer-id", (gpointer)timer_id); /* Set the text of the label to its variable name */ sprintf(text, "<span fgcolor='white' bgcolor='darkred'> %s </span>", attributeset_get_first(&element, var->Attributes, ATTR_VARIABLE)); gtk_label_set_markup(GTK_LABEL(var->Widget), text); /* Apply directives */ if (attributeset_is_avail(var->Attributes, ATTR_LABEL)) fprintf(stderr, "%s(): <label> not implemented for this widget.\n", __func__); if (attributeset_is_avail(var->Attributes, ATTR_DEFAULT)) fprintf(stderr, "%s(): <default> not implemented for this widget.\n", __func__); if (attributeset_is_avail(var->Attributes, ATTR_HEIGHT)) fprintf(stderr, "%s(): <height> not implemented for this widget.\n", __func__); if (attributeset_is_avail(var->Attributes, ATTR_WIDTH)) fprintf(stderr, "%s(): <width> not implemented for this widget.\n", __func__); if ((attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "false")) || (attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "disabled")) || /* Deprecated */ (attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "no")) || (attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "0"))) gtk_widget_set_sensitive(var->Widget, FALSE); /* Connect signals */ } #ifdef DEBUG_TRANSITS fprintf(stderr, "%s(): Exiting.\n", __func__); #endif }
/*********************************************************************** * Refresh * ***********************************************************************/ void widget_table_refresh(variable *var) { GList *element; gchar *act; gchar *value; gint freeze_thaw = FALSE; gint initialised = FALSE; gint selected_row; #ifdef DEBUG_TRANSITS fprintf(stderr, "%s(): Entering.\n", __func__); #endif #if !GTK_CHECK_VERSION(3,0,0) /* gtk3: Deprecated in gtk2 and now gone */ /* Get initialised state of widget */ if (g_object_get_data(G_OBJECT(var->Widget), "_initialised") != NULL) initialised = (gint)g_object_get_data(G_OBJECT(var->Widget), "_initialised"); if (var->widget_tag_attr) { /* Get freeze-thaw (custom) */ if ((value = get_tag_attribute(var->widget_tag_attr, "freeze-thaw")) && ((strcasecmp(value, "true") == 0) || (strcasecmp(value, "yes") == 0) || (atoi(value) == 1))) { freeze_thaw = TRUE; gtk_clist_freeze(GTK_CLIST(var->Widget)); } } /* The <input> tag... */ act = attributeset_get_first(&element, var->Attributes, ATTR_INPUT); while (act) { if (input_is_shell_command(act)) widget_table_input_by_command(var, act + 8, TRUE); /* input file stock = "File:", input file = "File:/path/to/file" */ if (strncasecmp(act, "file:", 5) == 0 && strlen(act) > 5) { if (!initialised) { /* Check for file-monitor and create if requested */ widget_file_monitor_try_create(var, act + 5); } widget_table_input_by_file(var, act + 5); } act = attributeset_get_next(&element, var->Attributes, ATTR_INPUT); } /* The <item> tags... */ if (attributeset_is_avail(var->Attributes, ATTR_ITEM)) widget_table_input_by_items(var); /* Initialise these only once at start-up */ if (!initialised) { /* Apply directives */ if (attributeset_is_avail(var->Attributes, ATTR_DEFAULT)) fprintf(stderr, "%s(): <default> not implemented for this widget.\n", __func__); if ((attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "false")) || (attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "disabled")) || /* Deprecated */ (attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "no")) || (attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "0"))) gtk_widget_set_sensitive(var->Widget, FALSE); /* Connect signals */ g_signal_connect(G_OBJECT(var->Widget), "select-row", G_CALLBACK(on_any_widget_select_row_event), (gpointer)var->Attributes); g_signal_connect(G_OBJECT(var->Widget), "click-column", G_CALLBACK(widget_table_click_column_callback), (gpointer)var); } /* Thaw a freeze? */ if (freeze_thaw) gtk_clist_thaw(GTK_CLIST(var->Widget)); if (var->widget_tag_attr) { /* Get columns-autosize (custom) Redundant: Works weirdly on initialisation. if ((value = get_tag_attribute(var->widget_tag_attr, "columns-autosize")) && ((strcasecmp(value, "true") == 0) || (strcasecmp(value, "yes") == 0) || (atoi(value) == 1))) { gtk_clist_columns_autosize(GTK_CLIST(var->Widget)); } */ /* Get selected-row (custom) */ if ((value = get_tag_attribute(var->widget_tag_attr, "selected-row"))) { selected_row = atoi(value); if (selected_row >= 0) gtk_clist_select_row(GTK_CLIST(var->Widget), selected_row, 0); } } #endif #ifdef DEBUG_TRANSITS fprintf(stderr, "%s(): Exiting.\n", __func__); #endif }
void widget_entry_refresh(variable *var) { GList *element; gchar *act; gint initialised = FALSE; #ifdef DEBUG_TRANSITS fprintf(stderr, "%s(): Entering.\n", __func__); #endif /* Get initialised state of widget */ if (g_object_get_data(G_OBJECT(var->Widget), "_initialised") != NULL) initialised = (gint)g_object_get_data(G_OBJECT(var->Widget), "_initialised"); /* The <input> tag... */ act = attributeset_get_first(&element, var->Attributes, ATTR_INPUT); while (act) { if (input_is_shell_command(act)) widget_entry_input_by_command(var, act + 8); /* input file stock = "File:", input file = "File:/path/to/file" */ if (strncasecmp(act, "file:", 5) == 0 && strlen(act) > 5) { if (!initialised) { /* Check for file-monitor and create if requested */ widget_file_monitor_try_create(var, act + 5); } widget_entry_input_by_file(var, act + 5); } act = attributeset_get_next(&element, var->Attributes, ATTR_INPUT); } /* The <item> tags... */ if (attributeset_is_avail(var->Attributes, ATTR_ITEM)) widget_entry_input_by_items(var); /* Initialise these only once at start-up */ if (!initialised) { /* Apply directives */ if (attributeset_is_avail(var->Attributes, ATTR_LABEL)) fprintf(stderr, "%s(): <label> not implemented for this widget.\n", __func__); if (attributeset_is_avail(var->Attributes, ATTR_DEFAULT)) { /* Thunor: This is all original code moved across when refactoring */ gtk_entry_set_text(GTK_ENTRY(var->Widget), attributeset_get_first( &element, var->Attributes, ATTR_DEFAULT)); } if (attributeset_is_avail(var->Attributes, ATTR_HEIGHT) && attributeset_is_avail(var->Attributes, ATTR_WIDTH)) { /* Thunor: This is all original code moved across when refactoring */ gtk_widget_set_usize(var->Widget, atoi(attributeset_get_first(&element, var->Attributes, ATTR_WIDTH)), atoi(attributeset_get_first(&element, var->Attributes, ATTR_HEIGHT))); } if ((attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "false")) || (attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "disabled")) || /* Deprecated */ (attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "no")) || (attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "0"))) gtk_widget_set_sensitive(var->Widget, FALSE); if (attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "password")) { /* Thunor: This is all original code moved across when refactoring */ gtk_entry_set_visibility(GTK_ENTRY(var->Widget), FALSE); } /* Connect signals */ /* Thunor: This is all original code moved across when refactoring */ g_signal_connect(G_OBJECT(var->Widget), "changed", G_CALLBACK(on_any_widget_changed_event), (gpointer)var->Attributes); g_signal_connect(G_OBJECT(var->Widget), "activate", G_CALLBACK(on_any_widget_activate_event), (gpointer)var->Attributes); #if GTK_CHECK_VERSION(2,16,0) /* Despite what the GTK+ 2 Reference Manual says, I found * these to be activatable by default. They will actually * be prefixed with either primary- or secondary- for use * within action directives */ g_signal_connect(G_OBJECT(var->Widget), "icon-press", G_CALLBACK(on_any_widget_icon_press_event), (gpointer)var->Attributes); g_signal_connect(G_OBJECT(var->Widget), "icon-release", G_CALLBACK(on_any_widget_icon_release_event), (gpointer)var->Attributes); #endif } #ifdef DEBUG_TRANSITS fprintf(stderr, "%s(): Exiting.\n", __func__); #endif }
/*********************************************************************** * Refresh * ***********************************************************************/ void widget_colorbutton_refresh(variable *var) { GdkColor color; GList *element; gchar *act; gint initialised = FALSE; guint alpha; list_t *values = NULL; #ifdef DEBUG_TRANSITS fprintf(stderr, "%s(): Entering.\n", __func__); #endif /* Get initialised state of widget */ if (g_object_get_data(G_OBJECT(var->Widget), "_initialised") != NULL) initialised = (gint)g_object_get_data(G_OBJECT(var->Widget), "_initialised"); /* The <input> tag... */ act = attributeset_get_first(&element, var->Attributes, ATTR_INPUT); while (act) { if (input_is_shell_command(act)) widget_colorbutton_input_by_command(var, act + 8); /* input file stock = "File:", input file = "File:/path/to/file" */ if (strncasecmp(act, "file:", 5) == 0 && strlen(act) > 5) { if (!initialised) { /* Check for file-monitor and create if requested */ widget_file_monitor_try_create(var, act + 5); } widget_colorbutton_input_by_file(var, act + 5); } act = attributeset_get_next(&element, var->Attributes, ATTR_INPUT); } /* The <item> tags... */ if (attributeset_is_avail(var->Attributes, ATTR_ITEM)) widget_colorbutton_input_by_items(var); /* Initialise these only once at start-up */ if (!initialised) { /* Apply directives */ if (attributeset_is_avail(var->Attributes, ATTR_LABEL)) fprintf(stderr, "%s(): <label> not implemented for this widget.\n", __func__); if (attributeset_is_avail(var->Attributes, ATTR_DEFAULT)) { values = linecutter(g_strdup(attributeset_get_first(&element, var->Attributes, ATTR_DEFAULT)), '|'); if (values->n_lines > 0) { /* Parse the RGB value to create the necessary GdkColor. * This function doesn't like trailing whitespace so it * needs to be stripped first with g_strstrip() */ if (gdk_color_parse(g_strstrip(values->line[0]), &color)) { #ifdef DEBUG_CONTENT fprintf(stderr, "%s:() valid colour found\n", __func__); #endif gtk_color_button_set_color(GTK_COLOR_BUTTON(var->Widget), &color); } } if (values->n_lines > 1) { /* Read alpha as an unsigned decimal integer */ if (sscanf(values->line[1], "%u", &alpha) == 1) { #ifdef DEBUG_CONTENT fprintf(stderr, "%s:() valid alpha=%u found\n", __func__, alpha); #endif /* This requires use-alpha="true" */ gtk_color_button_set_alpha(GTK_COLOR_BUTTON(var->Widget), alpha); } } /* Free linecutter memory */ if (values) list_t_free(values); } if (attributeset_is_avail(var->Attributes, ATTR_HEIGHT)) fprintf(stderr, "%s(): <height> not implemented for this widget.\n", __func__); if (attributeset_is_avail(var->Attributes, ATTR_WIDTH)) fprintf(stderr, "%s(): <width> not implemented for this widget.\n", __func__); if ((attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "false")) || (attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "disabled")) || /* Deprecated */ (attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "no")) || (attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "0"))) gtk_widget_set_sensitive(var->Widget, FALSE); /* Connect signals */ g_signal_connect(G_OBJECT(var->Widget), "color-set", G_CALLBACK(on_any_widget_color_set_event), (gpointer)var->Attributes); } #ifdef DEBUG_TRANSITS fprintf(stderr, "%s(): Exiting.\n", __func__); #endif }
void widget_pixmap_refresh(variable *var) { GList *element; gchar *act; gchar *value; gint initialised = FALSE; #ifdef DEBUG_TRANSITS fprintf(stderr, "%s(): Entering.\n", __func__); #endif /* Get initialised state of widget */ if (g_object_get_data(G_OBJECT(var->Widget), "_initialised") != NULL) initialised = (gint)g_object_get_data(G_OBJECT(var->Widget), "_initialised"); /* The <input> tag... */ act = attributeset_get_first(&element, var->Attributes, ATTR_INPUT); while (act) { if (input_is_shell_command(act)) widget_pixmap_input_by_command(var, act + 8); /* input file stock = "File:", input file = "File:/path/to/file" */ if (strncasecmp(act, "file:", 5) == 0 && strlen(act) > 5) { if (!initialised) { /* Check for file-monitor and create if requested */ widget_file_monitor_try_create(var, act + 5); } /* Don't refresh images on the first call otherwise they * get created and then immediately refreshed at start-up */ if (initialised) { widget_pixmap_input_by_file(var, act + 5); } } act = attributeset_get_next(&element, var->Attributes, ATTR_INPUT); } /* The <item> tags... */ if (attributeset_is_avail(var->Attributes, ATTR_ITEM)) widget_pixmap_input_by_items(var); /* Initialise these only once at start-up */ if (!initialised) { /* Apply directives */ if (attributeset_is_avail(var->Attributes, ATTR_LABEL)) fprintf(stderr, "%s(): <label> not implemented for this widget.\n", __func__); if (attributeset_is_avail(var->Attributes, ATTR_DEFAULT)) fprintf(stderr, "%s(): <default> not implemented for this widget.\n", __func__); if ((attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "false")) || (attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "disabled")) || /* Deprecated */ (attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "no")) || (attributeset_cmp_left(var->Attributes, ATTR_SENSITIVE, "0"))) gtk_widget_set_sensitive(var->Widget, FALSE); /* Connect signals */ } #ifdef DEBUG_TRANSITS fprintf(stderr, "%s(): Exiting.\n", __func__); #endif }