Пример #1
0
/*!
 \brief gets called to set the  entry backgroup color based on a match or not
 \param entry is a pointer to the MaskEntry structure
 */
G_MODULE_EXPORT void mask_entry_set_background (MaskEntry *entry)
{
	gchar *tmpbuf = NULL;
	gchar *tmpstr = NULL;
	gint len = 0;
	static const GdkColor error_color = { 0, 65535, 60000, 60000 };

	if (entry->mask)
	{
		tmpstr = g_utf8_normalize(gtk_entry_get_text (GTK_ENTRY (entry)),-1,G_NORMALIZE_DEFAULT);
		tmpbuf = g_utf8_casefold(tmpstr,-1);
		g_free(tmpstr);
		if (g_regex_match_simple(tmpbuf,entry->mask,
					(GRegexCompileFlags)0,(GRegexMatchFlags)0))
		{
			gtk_widget_modify_base (GTK_WIDGET (entry), GTK_STATE_NORMAL, &error_color);
			g_free(tmpbuf);
			return;
		}
		g_free(tmpbuf);
	}

	gtk_widget_modify_base (GTK_WIDGET (entry), GTK_STATE_NORMAL, NULL);
	return;
}
Пример #2
0
static void
search_box_set_entry_color (SearchBox* search_box, gboolean found)
{
	if (!found)
	{
		GdkColor red;
		GdkColor white;

		/* FIXME: a11y and theme */

		gdk_color_parse ("#FF6666", &red);
		gdk_color_parse ("white", &white);

		gtk_widget_modify_base (search_box->priv->search_entry,
				        GTK_STATE_NORMAL,
				        &red);
		gtk_widget_modify_text (search_box->priv->search_entry,
				        GTK_STATE_NORMAL,
				        &white);
	}
	else
	{
		gtk_widget_modify_base (search_box->priv->search_entry,
				        GTK_STATE_NORMAL,
				        NULL);
		gtk_widget_modify_text (search_box->priv->search_entry,
				        GTK_STATE_NORMAL,
				        NULL);
	}
}
Пример #3
0
static regrow *make_regrow(GtkWidget *ww, GtkSignalFunc play_callback, GtkSignalFunc name_callback)
{
  regrow *r;
  r = (regrow *)CALLOC(1, sizeof(regrow));

  /* assume "ww" is a vbox widget in this case */
  r->rw = gtk_hbox_new(false, 0);
  gtk_box_pack_start(GTK_BOX(ww), r->rw, false, false, 0);
  gtk_widget_modify_bg(r->rw, GTK_STATE_NORMAL, ss->sgx->highlight_color);
  gtk_widget_modify_base(r->rw, GTK_STATE_NORMAL, ss->sgx->highlight_color);
  gtk_widget_show(r->rw);

  r->pl = gtk_check_button_new();
  gtk_box_pack_start(GTK_BOX(r->rw), r->pl, false, false, 2);
  SG_SIGNAL_CONNECT(r->pl, "toggled", play_callback, r);
  gtk_widget_show(r->pl);

  r->nm = gtk_button_new_with_label("");
  sg_left_justify_button(r->nm);
  gtk_box_pack_start(GTK_BOX(r->rw), r->nm, true, true, 2);
  SG_SIGNAL_CONNECT(r->nm, "clicked", name_callback, r);
  SG_SIGNAL_CONNECT(r->nm, "enter_notify_event", regrow_mouse_enter_label, r);
  SG_SIGNAL_CONNECT(r->nm, "leave_notify_event", regrow_mouse_leave_label, r);
  set_user_data(G_OBJECT(r->nm), (gpointer)r);
  gtk_widget_modify_bg(r->nm, GTK_STATE_NORMAL, ss->sgx->highlight_color);
  gtk_widget_modify_base(r->nm, GTK_STATE_NORMAL, ss->sgx->highlight_color);
  gtk_widget_show(r->nm);

  return(r);
}
Пример #4
0
gboolean refresh(PROC_T *p){
    if(!p->entry_iseed) create_entry(p);

    switch(p->status.info){
    case 0:
	break;
    case S_RUNNING:
	break;
    case S_WAIT:
	/*waiting to start */
	gtk_entry_set_text(GTK_ENTRY(p->entry_timing),"Waiting");
	break;
    case S_START:
	/*just started. */
	gtk_entry_set_text(GTK_ENTRY(p->entry_timing),"Started");
	{
	    char lb[12];
	    char stime[80];
	    snprintf(lb,12," %5d",p->pid);
	    struct tm *tim=localtime(&(p->status.timstart));
	    strftime(stime,80,"[%F %k:%M:%S]",tim);
	    strcat(stime,lb);
	    gtk_label_set_text(GTK_LABEL(p->entry_pid), stime);
	}
	notify_user(p);
	break;
    case S_QUEUED:
	/*queued in scheduler */
	gtk_entry_set_text(GTK_ENTRY(p->entry_timing),"Queued");
	break;
    case S_FINISH:/*Finished */
	p->frac=1;
	change_button(p,GTK_STOCK_APPLY,(GCallback)delete_hbox_event);
	/*progress bar color. */
	gtk_widget_modify_bg(p->entry_timing,GTK_STATE_SELECTED,&green);
	notify_user(p);
	break;
    case S_CRASH:/*Error */
	gtk_entry_set_text(GTK_ENTRY(p->entry_timing),"Error");
	change_button(p,GTK_STOCK_CLOSE,(GCallback)delete_hbox_event);
	gtk_widget_modify_base(p->entry_timing,GTK_STATE_NORMAL,&red);
	notify_user(p);
	break;
    case S_TOKILL:/*kill command sent */
	gtk_entry_set_text(GTK_ENTRY(p->entry_timing),"Kill command sent");
	change_button(p,GTK_STOCK_CLOSE,(GCallback)delete_hbox_event);
	gtk_widget_modify_base(p->entry_timing,GTK_STATE_NORMAL,&yellow);
	break;
    case S_KILLED:
	gtk_entry_set_text(GTK_ENTRY(p->entry_timing),"Killed");
	change_button(p,GTK_STOCK_CLOSE,(GCallback)delete_hbox_event);
	gtk_widget_modify_base(p->entry_timing,GTK_STATE_NORMAL,&red);
	notify_user(p);
	break;
    default:
	warning("Unknown info\n");
    }
    update_prog(p);
    return 0;
}
Пример #5
0
void
mc_command_update_entry_color (MCData *mc)
{
    GdkColor fg;
    GdkColor bg;
    char *rc_string;

    fg.red   = mc->preferences.cmd_line_color_fg_r;
    fg.green = mc->preferences.cmd_line_color_fg_g;
    fg.blue  = mc->preferences.cmd_line_color_fg_b;

    /* FIXME: wish we had an API for this, see bug #79585 */
    rc_string = g_strdup_printf (
		    "\n"
		    " style \"minicommander-applet-entry-style\"\n"
		    " {\n"
		    "  GtkWidget::cursor-color=\"#%04x%04x%04x\"\n"
		    " }\n"
		    " widget \"*.minicommander-applet-entry\" "
		    "style \"minicommander-applet-entry-style\"\n"
		    "\n",
		    fg.red, fg.green, fg.blue);
    gtk_rc_parse_string (rc_string);
    g_free (rc_string);

    gtk_widget_modify_text (mc->entry, GTK_STATE_NORMAL, &fg);
    gtk_widget_modify_text (mc->entry, GTK_STATE_PRELIGHT, &fg);

    bg.red   = mc->preferences.cmd_line_color_bg_r;
    bg.green = mc->preferences.cmd_line_color_bg_g;
    bg.blue  = mc->preferences.cmd_line_color_bg_b;

    gtk_widget_modify_base (mc->entry, GTK_STATE_NORMAL, &bg);
    gtk_widget_modify_base (mc->entry, GTK_STATE_PRELIGHT, &bg);
}
Пример #6
0
void browser_notify(Browser *b, int level, char *message)
{
	/* show inputbar */
	if (!gtk_widget_get_visible(GTK_WIDGET(b->UI.inputbar))) {
		gtk_widget_show(GTK_WIDGET(b->UI.inputbar));
	}

	/* set inputbar color */
	switch (level) {
	case ERROR:
		gtk_widget_modify_base(GTK_WIDGET(b->UI.inputbar), GTK_STATE_NORMAL, &(ripcurl->Style.notification_e_bg));
		gtk_widget_modify_text(GTK_WIDGET(b->UI.inputbar), GTK_STATE_NORMAL, &(ripcurl->Style.notification_e_fg));
		break;
	case WARNING:
		break;
	default:
		gtk_widget_modify_base(GTK_WIDGET(b->UI.inputbar), GTK_STATE_NORMAL, &(ripcurl->Style.inputbar_bg));
		gtk_widget_modify_text(GTK_WIDGET(b->UI.inputbar), GTK_STATE_NORMAL, &(ripcurl->Style.inputbar_fg));
		break;
	}

	/* display message, if any */
	if (message) {
		gtk_entry_set_text(b->UI.inputbar, message);
	}
}
Пример #7
0
void dialog_show_cb(GtkWidget *widget, gpointer data) {
	struct compoundWidget * cw = (struct compoundWidget *) data;

	gtk_widget_modify_base(cw->compoundEntry,GTK_STATE_NORMAL,&white);
	gtk_widget_modify_base(cw->weightEntry,GTK_STATE_NORMAL,&white);

}
Пример #8
0
gboolean
parse_user_data(GtkWidget *widget, gpointer gdata) {
    Data *data = (Data *) gdata;


    if (!gtk_entry_get_text_length(GTK_ENTRY(data->player1Entry)) ||
            !gtk_entry_get_text_length(GTK_ENTRY(data->player2Entry))) {
        GdkColor *baseColor = (GdkColor *) calloc(1, sizeof (GdkColor)),
                *textColor = (GdkColor *) calloc(1, sizeof (GdkColor));
        gdk_color_parse(INVALID_BASE_COLOR, baseColor);
        gdk_color_parse(INVALID_TEXT_COLOR, textColor);
        if (!gtk_entry_get_text_length(GTK_ENTRY(data->player1Entry))) {
            gtk_widget_modify_base((data->player1Entry), GTK_STATE_NORMAL,
                    baseColor);
            gtk_widget_modify_text((data->player1Entry), GTK_STATE_NORMAL,
                    textColor);
            gtk_entry_set_text(GTK_ENTRY(data->player1Entry), "Invalid Name");
        }
        if (!gtk_entry_get_text_length(GTK_ENTRY(data->player2Entry))) {
            gtk_widget_modify_base((data->player2Entry), GTK_STATE_NORMAL,
                    baseColor);
            gtk_widget_modify_text((data->player2Entry), GTK_STATE_NORMAL,
                    textColor);
            gtk_entry_set_text(GTK_ENTRY(data->player2Entry), "Invalid Name");
        }
        free(baseColor);
        free(textColor);
        return FALSE;
    }
    strcpy(data->player1Name, (const char *) gtk_entry_get_text(GTK_ENTRY
            (data->player1Entry)));
    strcpy(data->player2Name, (const char *) gtk_entry_get_text(GTK_ENTRY
            (data->player2Entry)));

    if (!strcmp(data->player1Name, "Invalid Name") ||
            !strcmp(data->player2Name, "Invalid Name"))
        return FALSE;
    if (!strcmp(data->player1Name, data->player2Name)) {
        strcat(data->player1Name, " (Player 1)");
        strcat(data->player2Name, " (Player 2)");
    }
    data->horizontalLines = atoi((char *) gtk_combo_box_get_active_text
            (GTK_COMBO_BOX(data->comboBoxHorizontal)));
    data->verticalLines = atoi((char *) gtk_combo_box_get_active_text
            (GTK_COMBO_BOX(data->comboBoxVertical)));
    data->opponent = (GTK_TOGGLE_BUTTON(data->radioButtonComputer))->active ?
            COMPUTER : HUMAN;
    if (data->opponent == COMPUTER) {
        char *diff;
        diff = gtk_combo_box_get_active_text(GTK_COMBO_BOX(data->difficulty_combo));
        if (!strcmp(diff, "Easy"))
            data->difficulty = easy;
        else if (!strcmp(diff, "Medium"))
            data->difficulty = medium;
        else data->difficulty = hard;
    }
    gtk_main_quit();
    return TRUE;
}
Пример #9
0
/**
 * positionne les couleurs pour les tree_view
 *
 *\param tree_view
 *
 * */
void utils_set_tree_view_selection_and_text_color ( GtkWidget *tree_view )
{
    gtk_widget_modify_base ( tree_view, GTK_STATE_SELECTED, gsb_color_get_couleur ( "couleur_selection" ) );
    gtk_widget_modify_base ( tree_view, GTK_STATE_ACTIVE, gsb_color_get_couleur ( "couleur_selection" ) );

    gtk_widget_modify_text ( tree_view, GTK_STATE_SELECTED, gsb_color_get_couleur_with_indice ( "text_color", 0 ) );
    gtk_widget_modify_text ( tree_view, GTK_STATE_ACTIVE, gsb_color_get_couleur_with_indice ( "text_color", 0 ) );
}
Пример #10
0
void density_thickness_changed_cb(GtkWidget *widget, gpointer data) {
	char *textPtr,*textPtr2,*endPtr,*lastPtr,*endPtr2,*lastPtr2, *textPtr3, *lastPtr3,*endPtr3 ;
	struct layerWidget *lw = (struct layerWidget *) data;
	int density_ok, thickness_ok, layer_ok;
	double density, thickness, sum;

	textPtr = (char *) gtk_entry_get_text(GTK_ENTRY(lw->densityEntry));
	textPtr2 = (char *) gtk_entry_get_text(GTK_ENTRY(lw->thicknessEntry));
	textPtr3 = (char *) gtk_entry_get_text(GTK_ENTRY(lw->sumEntry));

	density = strtod(textPtr, &endPtr);
	thickness = strtod(textPtr2, &endPtr2);
	sum = strtod(textPtr3, &endPtr3);
	
	lastPtr = textPtr + strlen(textPtr);
	lastPtr2 = textPtr2 + strlen(textPtr2);
	lastPtr3 = textPtr3 + strlen(textPtr3);

	if (lastPtr == endPtr && density > 0.0)
		density_ok = 1;
	else
		density_ok = 0;

	if (lastPtr2 == endPtr2 && thickness > 0.0)
		thickness_ok = 1;
	else
		thickness_ok = 0;

	if (lastPtr3 == endPtr3 && sum > 0.0)
		layer_ok = 1;
	else
		layer_ok = 0;

	if (widget == lw->densityEntry) {
		if (density_ok)
			gtk_widget_modify_base(widget,GTK_STATE_NORMAL,&white);
		else {
			gtk_widget_modify_base(widget,GTK_STATE_NORMAL,&red);
			gtk_widget_set_sensitive(lw->okButton,FALSE);
		}
	}
	else if (widget ==  lw->thicknessEntry) {
		if (thickness_ok) 
			gtk_widget_modify_base(widget,GTK_STATE_NORMAL,&white);
		else {
			gtk_widget_modify_base(widget,GTK_STATE_NORMAL,&red);
			gtk_widget_set_sensitive(lw->okButton,FALSE);
		}
	}

	if (thickness_ok && density_ok && layer_ok) {
		gtk_widget_set_sensitive(lw->okButton,TRUE);
		(*(lw->my_layer))->thickness = thickness;
		(*(lw->my_layer))->density = density;
	}

	return;
}
Пример #11
0
void compound_changed(GtkWidget * widget, gpointer data) {
	char *textPtr,*textPtr2,*endPtr,*lastPtr;
	struct compoundWidget *cw = (struct compoundWidget *) data;
	struct compoundData cd;
	double weight;
	int cp_rv;

	textPtr = (char *) gtk_entry_get_text(GTK_ENTRY(cw->compoundEntry));
	textPtr2 = (char *) gtk_entry_get_text(GTK_ENTRY(cw->weightEntry));
	weight = strtod(textPtr2, &endPtr);
	cp_rv = CompoundParser(textPtr, &cd); 

#if DEBUG == 1
	fprintf(stdout,"weight: %lf\n",weight);

#endif

	lastPtr = textPtr2 + strlen(textPtr2);

#if DEBUG == 1
	fprintf(stdout,"lastPtr: %p\n",lastPtr);
	fprintf(stdout,"endPtr: %p\n",endPtr);
#endif

	if (widget == cw->compoundEntry) {
		if (cp_rv == 1) {
			gtk_widget_modify_base(widget,GTK_STATE_NORMAL,&white);
			FREE_COMPOUND_DATA(cd);
		}
		else {
			//bad value
			gtk_widget_modify_base(widget,GTK_STATE_NORMAL,&red);
			gtk_widget_set_sensitive(cw->okButton,FALSE);
		}
		if (cp_rv == 1 && lastPtr == endPtr && weight > 0.0) {
			gtk_widget_set_sensitive(cw->okButton,TRUE);
		}
	}
	else if (widget == cw->weightEntry) {
		if (lastPtr == endPtr && weight > 0.0) {
			gtk_widget_modify_base(widget,GTK_STATE_NORMAL,&white);
		}
		else {
			//bad value
			gtk_widget_modify_base(widget,GTK_STATE_NORMAL,&red);
			gtk_widget_set_sensitive(cw->okButton,FALSE);
		}
		if (cp_rv == 1 && lastPtr == endPtr && weight > 0.0) {
			gtk_widget_set_sensitive(cw->okButton,TRUE);
			FREE_COMPOUND_DATA(cd);
		}
	}



	

}
Пример #12
0
static void highlight_region(void)
{
  if (current_region != -1)
    {
      regrow *oldr;
      oldr = region_row(current_region);
      gtk_widget_modify_bg(oldr->nm, GTK_STATE_NORMAL, ss->sgx->zoom_color);
      gtk_widget_modify_base(oldr->nm, GTK_STATE_NORMAL, ss->sgx->zoom_color);
      gtk_widget_modify_bg(oldr->rw, GTK_STATE_NORMAL, ss->sgx->zoom_color);
      gtk_widget_modify_base(oldr->rw, GTK_STATE_NORMAL, ss->sgx->zoom_color);
    }
}
Пример #13
0
GtkWidget *snd_gtk_entry_label_new(const char *label, GdkColor *color)
{
  GtkWidget *rlw;
  rlw = gtk_entry_new();
  gtk_entry_set_has_frame(GTK_ENTRY(rlw), false);
  if (label) gtk_entry_set_text(GTK_ENTRY(rlw), label);
  gtk_editable_set_editable(GTK_EDITABLE(rlw), false);
  GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(rlw), GTK_CAN_FOCUS); /* turn off the $%#@$! blinking cursor */
  gtk_widget_modify_base(rlw, GTK_STATE_NORMAL, color);
  gtk_widget_modify_base(rlw, GTK_STATE_ACTIVE, color);
  return(rlw);
}
Пример #14
0
void color_widget_default(GtkWidget * widget)
// Set the widget to the default color.
{
  gtk_widget_modify_base(widget, GTK_STATE_NORMAL, NULL);
  gtk_widget_modify_base(widget, GTK_STATE_SELECTED, NULL);
  gtk_widget_modify_base(widget, GTK_STATE_ACTIVE, NULL);
  gtk_widget_modify_text(widget, GTK_STATE_SELECTED, NULL);
  gtk_widget_modify_text(widget, GTK_STATE_ACTIVE, NULL);
  gtk_widget_modify_text(widget, GTK_STATE_NORMAL, NULL);
  // See the gedit source for this function.
  //modify_cursor_color (widget, NULL); 
}
static void
thunar_sbr_number_renamer_update (ThunarSbrNumberRenamer *number_renamer)
{
  gboolean invalid = TRUE;
  GdkColor back;
  GdkColor text;
  gchar   *endp;
  guint    number;

  /* check whether "start" is valid for the "mode" */
  if (number_renamer->mode < THUNAR_SBR_NUMBER_MODE_ABC)
    {
      /* "start" must be a positive number */
      number = strtoul (number_renamer->start, &endp, 10);
      invalid = (endp <= number_renamer->start || *endp != '\0');
    }
  else if (number_renamer->mode == THUNAR_SBR_NUMBER_MODE_ABC)
    {
      /* "start" property must be 'a', 'b', 'c', etc. */
      invalid = (strlen (number_renamer->start) != 1
              || g_ascii_tolower (*number_renamer->start) < 'a'
              || g_ascii_tolower (*number_renamer->start) > 'z');
    }

  /* check if the start entry is realized */
  if (GTK_WIDGET_REALIZED (number_renamer->start_entry))
    {
      /* check if the "start" value is valid */
      if (G_UNLIKELY (invalid))
        {
          /* if GTK+ wouldn't be that stupid with style properties and 
           * type plugins, this would be themable, but unfortunately
           * GTK+ is totally broken, and so it's hardcoded.
           */
          gdk_color_parse ("#ff6666", &back);
          gdk_color_parse ("White", &text);

          /* setup a red background/text color to indicate the error */
          gtk_widget_modify_base (number_renamer->start_entry, GTK_STATE_NORMAL, &back);
          gtk_widget_modify_text (number_renamer->start_entry, GTK_STATE_NORMAL, &text);
        }
      else
        {
          /* reset background/text color */
          gtk_widget_modify_base (number_renamer->start_entry, GTK_STATE_NORMAL, NULL);
          gtk_widget_modify_text (number_renamer->start_entry, GTK_STATE_NORMAL, NULL);
        }
    }

  /* notify everybody that we have a new state */
  thunarx_renamer_changed (THUNARX_RENAMER (number_renamer));
}
Пример #16
0
void color_widget_set(GtkWidget * widget, unsigned int normal_text, unsigned int background, unsigned int selected_text, unsigned int selection)
{
  GdkColor gdkcolor;
  color_decimal_to_gdk(normal_text, &gdkcolor);
  gtk_widget_modify_text(widget, GTK_STATE_NORMAL, &gdkcolor);
  //modify_cursor_color (widget, &gdkcolor);
  color_decimal_to_gdk(background, &gdkcolor);
  gtk_widget_modify_base(widget, GTK_STATE_NORMAL, &gdkcolor);
  color_decimal_to_gdk(selected_text, &gdkcolor);
  gtk_widget_modify_text(widget, GTK_STATE_SELECTED, &gdkcolor);
  gtk_widget_modify_text(widget, GTK_STATE_ACTIVE, &gdkcolor);
  color_decimal_to_gdk(selection, &gdkcolor);
  gtk_widget_modify_base(widget, GTK_STATE_SELECTED, &gdkcolor);
  gtk_widget_modify_base(widget, GTK_STATE_ACTIVE, &gdkcolor);
}
Пример #17
0
static void
mask_entry_set_background (MaskEntry *entry)
{
  static const GdkColor error_color = { 0, 65535, 60000, 60000 };

  if (entry->mask)
    {
      if (!g_regex_match_simple (entry->mask, gtk_entry_get_text (GTK_ENTRY (entry)), 0, 0))
    {
      gtk_widget_modify_base (GTK_WIDGET (entry), GTK_STATE_NORMAL, &error_color);
      return;
    }
    }

  gtk_widget_modify_base (GTK_WIDGET (entry), GTK_STATE_NORMAL, NULL);
}
Пример #18
0
static void context_apply_config(GtkWidget *console)
{
#if !GTK_CHECK_VERSION(3, 0, 0)
	gtk_widget_modify_base(console, GTK_STATE_NORMAL, &pref_vte_colour_back);
	gtk_widget_modify_cursor(console, &pref_vte_colour_fore, &pref_vte_colour_back);
#else
	GString *css_string;
	GtkStyleContext *context;
	GtkCssProvider *provider;
	gchar *css_code, *color, *background_color;

	color = gdk_rgba_to_string (&pref_vte_colour_fore);
	background_color = gdk_rgba_to_string (&pref_vte_colour_back);

	gtk_widget_set_name(console, "scope-console");
	context = gtk_widget_get_style_context(console);
	provider = gtk_css_provider_new();
	gtk_style_context_add_provider(context, GTK_STYLE_PROVIDER(provider),
		GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

	css_string = g_string_new(NULL);
	g_string_printf(css_string, "#scope-console { color: %s; background-color: %s; }",
		color, background_color);
	css_code = g_string_free(css_string, FALSE);

	gtk_css_provider_load_from_data(GTK_CSS_PROVIDER(provider), css_code, -1, NULL);

	g_free(css_code);
	g_object_unref(provider);
#endif
	ui_widget_modify_font_from_string(console, pref_vte_font);
}
Пример #19
0
static VALUE
rg_modify_base(VALUE self, VALUE state, VALUE color)
{
    gtk_widget_modify_base(_SELF(self), RVAL2GTKSTATETYPE(state),
                         RVAL2GDKCOLOR(color));
    return self;
}
Пример #20
0
void Color_Widget_bg(char *colorstring, GtkWidget * widget)
{
    GdkColor color;
    gdk_color_parse(colorstring, &color);
    gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &color);
    gtk_widget_modify_base(widget, GTK_STATE_NORMAL, &color);
}
Пример #21
0
/*!
  \brief ECU specific plugin handler for combo boxes
  \param widget is the pointer to the combo box 
  \param data is unused
  \returns TRUE
  */
G_MODULE_EXPORT gboolean ecu_update_combo(GtkWidget *widget, gpointer data)
{
	gfloat value = 0.0;
	GtkTreeModel *model = NULL;
	GtkTreeIter iter;
	JimStimStdHandler handler;
	GdkColor white = {0,65535,65535,65535};

	handler = (JimStimStdHandler)OBJ_GET(widget,"handler");
	if (handler == RPM_MODE)
	{
		value = convert_after_upload_f(widget);
		model = gtk_combo_box_get_model(GTK_COMBO_BOX(widget));

		/* If set to 65535, pick second choice, otherwise first one..
		   */
		gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model),&iter);
		if ((GINT)value == 65535)
			gtk_tree_model_iter_next (GTK_TREE_MODEL(model), &iter);
                g_signal_handlers_block_by_func(widget,(gpointer)std_combo_handler_f,NULL);

		gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widget),&iter);
		gtk_widget_modify_base(gtk_bin_get_child(GTK_BIN(widget)),GTK_STATE_NORMAL,&white);
                g_signal_handlers_unblock_by_func(widget,(gpointer)std_combo_handler_f,NULL);
	}
	return TRUE;
}
Пример #22
0
/* Modify BASE for a button */
int
clip_GTK_BUTTONMODIFYBASE(ClipMachine * ClipMachineMemory)
{
   C_widget *cbtn = _fetch_cw_arg(ClipMachineMemory);

   ClipVar  *mstyle = _clip_par(ClipMachineMemory, 2);

   GtkStateType state = _clip_parni(ClipMachineMemory, 3);

   GdkColor  basecolor;

   double    colors[4];

   GtkWidget *wid;

   CHECKARG2(2, MAP_type_of_ClipVarType, ARRAY_type_of_ClipVarType);
   CHECKOPT(3, NUMERIC_type_of_ClipVarType);
   CHECKCWID(cbtn, GTK_IS_BUTTON);

   _map_get_colors(ClipMachineMemory, mstyle, colors);
   basecolor.red = colors[0];
   basecolor.green = colors[1];
   basecolor.blue = colors[2];
   basecolor.pixel = colors[3];

   if (_clip_parinfo(ClipMachineMemory, 3) != NUMERIC_type_of_ClipVarType)
      state = GTK_STATE_NORMAL;

  //wid = GTK_BIN(&(GTK_BUTTON(cbtn->widget)->bin))->child;
   wid = GTK_WIDGET(cbtn->widget);
   gtk_widget_modify_base(wid, state, &basecolor);
   return 0;
 err:
   return 1;
}
Пример #23
0
void
utl_gui_change_bg_widget_state (GtkWidget *widget, gchar *color_str, GUI *appGUI) {

GdkColor color;

    if (color_str != NULL) {

        gdk_color_parse (color_str, &color);
        gtk_widget_modify_base (widget, GTK_STATE_NORMAL, &color);

    } else {

        gtk_widget_modify_base (widget, GTK_STATE_NORMAL, 
                                &(appGUI->main_window)->style->base[GTK_WIDGET_STATE (appGUI->main_window)]);
    }

}
static gboolean
cell_changed_cb (GtkEditable *editable,
                 gpointer user_data)
{
	char *cell_text;
	guint column;
#if GTK_CHECK_VERSION(3,0,0)
	GdkRGBA rgba;
#else
	GdkColor color;
#endif
	gboolean value_valid = FALSE;
	const char *colorname = NULL;

	cell_text = gtk_editable_get_chars (editable, 0, -1);

	column = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (user_data), "column"));

	if (column == COL_PREFIX) {
		long int tmp_int;

		errno = 0;
		tmp_int = strtol (cell_text, NULL, 10);
		if (errno || tmp_int < 0 || tmp_int > 128)
			value_valid = FALSE;
		else
			value_valid = TRUE;
	} else if (column == COL_METRIC) {
		long int tmp_int;

		errno = 0;
		tmp_int = strtol (cell_text, NULL, 10);
		if (errno || tmp_int < 0 || tmp_int > G_MAXUINT32)
			value_valid = FALSE;
		else
			value_valid = TRUE;
	} else {
		struct in6_addr tmp_addr;

		if (inet_pton (AF_INET6, cell_text, &tmp_addr) > 0)
			value_valid = TRUE;
	}

	/* Change cell's background color while editing */
	colorname = value_valid ? "lightgreen" : "red";

#if GTK_CHECK_VERSION(3,0,0)
	gdk_rgba_parse (&rgba, colorname);
	gtk_widget_override_background_color (GTK_WIDGET (editable), GTK_STATE_NORMAL, &rgba);
#else
	gdk_color_parse (colorname, &color);
	gtk_widget_modify_base (GTK_WIDGET (editable), GTK_STATE_NORMAL, &color);
#endif

	g_free (cell_text);
	return FALSE;
}
Пример #25
0
static void compound_changed(GtkEditable *widget, gpointer data) {
  const char *textPtr,*textPtr2;
  char *endPtr;
  const char *lastPtr;
  XmiMsimGuiCompoundDialog *dialog = (XmiMsimGuiCompoundDialog *) data;
  struct compoundData *cd;
  double weight;

  textPtr = gtk_entry_get_text(GTK_ENTRY(dialog->compoundEntry));
  textPtr2 = gtk_entry_get_text(GTK_ENTRY(dialog->weightEntry));
  weight = strtod(textPtr2, &endPtr);
  cd = CompoundParser(textPtr);

  lastPtr = textPtr2 + strlen(textPtr2);

  if (GTK_WIDGET(widget) == dialog->compoundEntry) {
    if (cd) {
      gtk_widget_modify_base(GTK_WIDGET(widget), GTK_STATE_NORMAL, NULL);
    }
    else {
      //bad value
      gtk_widget_modify_base(GTK_WIDGET(widget), GTK_STATE_NORMAL, &red);
      gtk_widget_set_sensitive(gtk_dialog_get_widget_for_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT), FALSE);
    }
    if (cd && lastPtr == endPtr && weight > 0.0) {
      gtk_widget_set_sensitive(gtk_dialog_get_widget_for_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT), TRUE);
    }
  }
  else if (GTK_WIDGET(widget) == dialog->weightEntry) {
    if (lastPtr == endPtr && weight > 0.0) {
      gtk_widget_modify_base(GTK_WIDGET(widget), GTK_STATE_NORMAL, NULL);
    }
    else {
      //bad value
      gtk_widget_modify_base(GTK_WIDGET(widget), GTK_STATE_NORMAL, &red);
      gtk_widget_set_sensitive(gtk_dialog_get_widget_for_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT), FALSE);
    }
    if (cd && lastPtr == endPtr && weight > 0.0) {
      gtk_widget_set_sensitive(gtk_dialog_get_widget_for_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT), TRUE);
    }
  }
  if (cd)
    FreeCompoundData(cd);
}
Пример #26
0
/*--------------------------------------------------------------------------*/
static void
property_page_set_warning (PropertyPage *page)
{
  GdkColor  colorYellow;

  gtk_label_set_text (GTK_LABEL (page->label_status), _("Share name is too long"));

  gdk_color_parse ("#ECDF62", &colorYellow);
  gtk_widget_modify_base (page->entry_share_name, GTK_STATE_NORMAL, &colorYellow);
}
Пример #27
0
static void
property_page_set_error (PropertyPage *page, const char *message)
{
  GdkColor colorRed;

  gtk_label_set_text (GTK_LABEL (page->label_status), message);

  gdk_color_parse ("#C1665A", &colorRed);
  gtk_widget_modify_base (page->entry_share_name, GTK_STATE_NORMAL, &colorRed);
}
Пример #28
0
static void
jana_gtk_recurrence_style_set (GtkWidget *widget, GtkStyle *previous_style)
{
	JanaGtkRecurrencePrivate *priv = RECURRENCE_PRIVATE (widget);
	
	gtk_widget_modify_base (priv->preview_textview, GTK_STATE_NORMAL,
		&widget->style->bg[GTK_STATE_NORMAL]);
	
	GTK_WIDGET_CLASS (jana_gtk_recurrence_parent_class)->
		style_set (widget, previous_style);
}
Пример #29
0
MidoratorEntry* midorator_entry_new(GtkWidget *parent) {
	GtkWidget *e = g_object_new(MIDORATOR_TYPE_ENTRY, NULL);
	gtk_entry_set_has_frame(GTK_ENTRY(e), false);
	if (parent) {
		gtk_widget_modify_base(e, GTK_STATE_NORMAL, &parent->style->bg[0]);
		gtk_widget_modify_base(e, GTK_STATE_ACTIVE, &parent->style->bg[0]);
		gtk_widget_modify_bg(e, GTK_STATE_NORMAL, &parent->style->bg[0]);
		gtk_widget_modify_bg(e, GTK_STATE_ACTIVE, &parent->style->bg[0]);
	}
	if (GTK_IS_BOX(parent)) {
		gtk_box_pack_start(GTK_BOX(parent), e, true, true, 0);
		gtk_widget_show(e);
		gtk_widget_grab_focus(e);
		gtk_box_reorder_child(GTK_BOX(parent), e, 0);
	} else if (GTK_IS_CONTAINER(parent)) {
		gtk_container_add(GTK_CONTAINER(parent), e);
		gtk_widget_show(e);
	}
	return MIDORATOR_ENTRY(e);
	//return (MidoratorEntry*)(e);
}
Пример #30
0
/**
 * manual set of the color of the entry
 * used for example in reconciliation, if cancel it, to set back the good color
 * of the entry
 *
 * \param entry
 * \param normal_color TRUE if we want to set the normal color, FALSE to set to red
 *
 * \return FALSE
 * */
gboolean gsb_calendar_entry_set_color ( GtkWidget *entry,
					gboolean normal_color )
{
    if (!entry)
	return FALSE;

    if (normal_color)
    {
	gtk_widget_modify_base ( entry,
				 GTK_STATE_NORMAL,
				 NULL );
    }
    else
    {
	gtk_widget_modify_base ( entry,
				 GTK_STATE_NORMAL,
				 gsb_color_get_couleur ( "entry_error_color" ) );
    }

    return FALSE;
}