static void
gimp_container_entry_changed (GtkEntry          *entry,
                              GimpContainerView *view)
{
  GimpContainer *container = gimp_container_view_get_container (view);
  GimpObject    *object;
  const gchar   *text;

  if (! container)
    return;

  text = gtk_entry_get_text (entry);

  object = gimp_container_get_child_by_name (container, text);

  if (object)
    {
      gtk_widget_modify_text (GTK_WIDGET (entry), GTK_STATE_NORMAL, NULL);
      gimp_container_view_item_selected (view, GIMP_VIEWABLE (object));
    }
  else
    {
      /* While editing the entry, contents shows in red for non-existent item. */
      GdkColor     gdk_red;

      gdk_red.red = 65535;
      gdk_red.green = 0;
      gdk_red.blue = 0;

      gtk_widget_modify_text (GTK_WIDGET (entry), GTK_STATE_NORMAL, &gdk_red);
    }
}
示例#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
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);
}
示例#4
0
文件: ripcurl.c 项目: dluco/ripcurl
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);
	}
}
static gboolean
gimp_container_entry_select_item (GimpContainerView *view,
                                  GimpViewable      *viewable,
                                  gpointer           insert_data)
{
  GtkEntry    *entry = GTK_ENTRY (view);
  GtkTreeIter *iter  = insert_data;

  g_signal_handlers_block_by_func (entry,
                                   gimp_container_entry_changed,
                                   view);

  if (iter)
    {
      gtk_widget_modify_text (GTK_WIDGET (entry), GTK_STATE_NORMAL, NULL);
    }
  else
    {
      /* The selected item does not exist. */
      GdkColor     gdk_red;

      gdk_red.red = 65535;
      gdk_red.green = 0;
      gdk_red.blue = 0;

      gtk_widget_modify_text (GTK_WIDGET (entry), GTK_STATE_NORMAL, &gdk_red);
    }
  gtk_entry_set_text (entry, viewable? gimp_object_get_name (viewable) : "");

  g_signal_handlers_unblock_by_func (entry,
                                     gimp_container_entry_changed,
                                     view);

  return TRUE;
}
示例#6
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;
}
示例#7
0
static void playlist3_header_update_style(GtkWidget *widget, GtkStyle *prev, gpointer data)
{
    gtk_widget_modify_text(header_labels[1], GTK_STATE_NORMAL, &(widget->style->text[GTK_STATE_INSENSITIVE]));
    gtk_widget_modify_fg(header_labels[1], GTK_STATE_NORMAL, &(widget->style->text[GTK_STATE_INSENSITIVE]));

    gtk_widget_modify_text(header_labels[3], GTK_STATE_NORMAL, &(widget->style->text[GTK_STATE_INSENSITIVE]));
    gtk_widget_modify_fg(header_labels[3], GTK_STATE_NORMAL, &(widget->style->text[GTK_STATE_INSENSITIVE]));
}
示例#8
0
文件: utils.c 项目: wazari972/Grisbi
/**
 * 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 ) );
}
示例#9
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));
}
示例#11
0
/*!
  \brief hides a tab
  \param widget is the widget clicked to get this to come up
  \param data is the index to the tab to hide
  \return TRUE on success
  */
G_MODULE_EXPORT gboolean hide_tab(GtkWidget *widget, gpointer data)
{
	GtkWidget *child;
	GtkWidget *label;
	GtkWidget *notebook;
	GtkWidget *item = NULL;
	GladeXML *main_xml = NULL;
	extern GdkColor red;
	extern GdkColor black;
	gint index = (GINT)data;
	gint total = (GINT)DATA_GET(global_data,"notebook_rows");
	gint i = 0;
	gboolean hidden = FALSE;
	gint *hidden_list;

	ENTER();
	main_xml = (GladeXML *)DATA_GET(global_data,"main_xml");
	hidden_list = (gboolean *)DATA_GET(global_data,"hidden_list");
	notebook = glade_xml_get_widget(main_xml,"toplevel_notebook");

	child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),index);
	label = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook),child);

	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
	{
		gtk_widget_hide(child);
		gtk_widget_hide(label);
		hidden_list[index] = TRUE;
	}
	else
	{
		gtk_widget_show(child);
		gtk_widget_show(label);
		hidden_list[index] = FALSE;
	}

	for (i=0;i<total;i++)
	{
		if (hidden_list[i])
			hidden = TRUE;
	}
	item = lookup_widget("show_tab_visibility_menuitem");
	if (hidden)
		 gtk_widget_modify_text(gtk_bin_get_child(GTK_BIN(item)),GTK_STATE_NORMAL,&red);
	else
		 gtk_widget_modify_text(gtk_bin_get_child(GTK_BIN(item)),GTK_STATE_NORMAL,&black);
	EXIT();
	return TRUE;
}
示例#12
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);
}
示例#13
0
/* Modify TEXT for a button */
int
clip_GTK_BUTTONMODIFYTEXT(ClipMachine * ClipMachineMemory)
{
   C_widget *cbtn = _fetch_cw_arg(ClipMachineMemory);

   ClipVar  *mstyle = _clip_par(ClipMachineMemory, 2);

   GtkStateType state = _clip_parni(ClipMachineMemory, 3);

   GdkColor  textcolor;

   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);
   textcolor.red = colors[0];
   textcolor.green = colors[1];
   textcolor.blue = colors[2];
   textcolor.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_text(wid, state, &textcolor);
   return 0;
 err:
   return 1;
}
示例#14
0
/*
 * Set the default style
 */
static void
set_default_tag (GtkTextBuffer *buffer, GtkTextTag *tag)
{
  PangoFontDescription *font_desc;
  GdkColor *color = (GdkColor *)g_malloc(sizeof(GdkColor));
  PangoUnderline *underline;
  int val;
  GtkJustification justification;

  if(!tag)
    return;

  g_object_get (G_OBJECT (tag), "foreground-gdk", &color, NULL);
  g_object_get (G_OBJECT (tag), "underline", &underline, NULL);
  g_object_get (G_OBJECT (tag), "font-desc", &font_desc, NULL);

  gtk_widget_modify_font (view, font_desc);
  gtk_widget_modify_text (view, GTK_STATE_NORMAL, color);

  g_object_get (G_OBJECT (tag), "left-margin", &val, NULL);
  gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), val);

  g_object_get (G_OBJECT (tag), "justification", &justification, NULL);
  gtk_text_view_set_justification(GTK_TEXT_VIEW (view), justification);

  g_object_get (G_OBJECT (tag), "pixels-below-lines", &val, NULL);
  gtk_text_view_set_pixels_below_lines(GTK_TEXT_VIEW (view), val);

  g_object_get (G_OBJECT (tag), "pixels-above-lines", &val, NULL);
  gtk_text_view_set_pixels_above_lines(GTK_TEXT_VIEW (view), val);
}
示例#15
0
int main(int argc, char *argv[])
{
	GtkWidget *btnLogin;
	GdkColor color;
    color.red = 0000;
    color.green = 0000;
    color.blue = 0;

    GdkColor color2;
    color2.red = 47;
    color2.green = 79;
    color2.blue = 79;

	gtk_init(&argc, &argv);
	gtkBuilder = gtk_builder_new();
	gtk_builder_add_from_file(gtkBuilder, "windowInitial.glade", NULL);
	window = GTK_WIDGET(gtk_builder_get_object(gtkBuilder, "windowInitial"));
	gtk_widget_set_size_request(GTK_WINDOW(window),500,200);
	gdk_color_parse ("#008B8B", &color2);
	gtk_widget_modify_bg(GTK_WINDOW(window), GTK_STATE_NORMAL, &color2);

	btnLogin = GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "btnLogin"));
	txtUser= GTK_WIDGET (gtk_builder_get_object (gtkBuilder, "txtUser"));
	gdk_color_parse ("#ffffff", &color);
	gtk_widget_modify_text(GTK_WIDGET(btnLogin),GTK_STATE_NORMAL, &color);	
	g_signal_connect (window, "destroy", G_CALLBACK (on_window_destroy), NULL);
	gtk_widget_set_tooltip_text (btnLogin, "Proporcione los datos indicados para realizar el inicio de sesión. ");
	g_signal_connect (btnLogin, "clicked",G_CALLBACK (imprimir),NULL);
	g_object_unref(G_OBJECT(gtkBuilder));
	gtk_widget_show(window);
	gtk_main();
	return 0;
}
示例#16
0
static VALUE
rg_modify_text(VALUE self, VALUE state, VALUE color)
{
    gtk_widget_modify_text(_SELF(self), RVAL2GTKSTATETYPE(state),
                         RVAL2GDKCOLOR(color));
    return self;
}
示例#17
0
/*
 Main sidegadget's function
*/
GtkWidget*
sidegadget_new (void)
{
	block_notes = g_new0 (block_notes_s, 1);
	block_notes->work_dir = g_strdup_printf ("sidegadget/block-notes/%s", BLOCK_NOTES_DATA_FILE);

	/* Get initial text */
	block_notes_conf_get_initial_text (block_notes, block_notes->work_dir);
	
	block_notes->view = gtk_text_view_new ();
	
	gtk_widget_set_size_request (block_notes->view, -1, 200 - 25);

	/* Set textview's color*/
//	gtk_widget_modify_base (block_notes->view, GTK_STATE_NORMAL, &sidegadget->color_gadget);
	gtk_widget_grab_focus (block_notes->view);

	gtk_text_view_set_editable (GTK_TEXT_VIEW (block_notes->view), TRUE);
	gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (block_notes->view), TRUE);

	gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (block_notes->view), GTK_WRAP_WORD_CHAR);
	gtk_text_view_set_justification (GTK_TEXT_VIEW (block_notes->view), GTK_JUSTIFY_LEFT);

	/* Set space between two rows */
	gtk_text_view_set_pixels_above_lines (GTK_TEXT_VIEW (block_notes->view), 1);
	gtk_text_view_set_pixels_below_lines (GTK_TEXT_VIEW (block_notes->view), 1);

	/* Set borders */
	gtk_text_view_set_left_margin (GTK_TEXT_VIEW (block_notes->view), 2);
	gtk_text_view_set_right_margin (GTK_TEXT_VIEW (block_notes->view), 2);

	/* Set font color */
	gtk_widget_modify_text (block_notes->view, GTK_STATE_NORMAL, &block_notes->color_text);
	
	/* Set font */
	gtk_widget_modify_font (block_notes->view, block_notes->font_pango);

	gtk_widget_show (block_notes->view);

	/* Create a buffer*/
	block_notes->buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(block_notes->view));

	/* Insert init_text in the buffer */
	gtk_text_buffer_set_text (block_notes->buffer, block_notes->string_init, -1);

	/* Create scrolled window */
	block_notes->scrolled_win = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (block_notes->scrolled_win), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

	/* Insert the textview in the scrolled win */
	gtk_container_add (GTK_CONTAINER(block_notes->scrolled_win), block_notes->view);

	g_signal_connect (G_OBJECT (block_notes->buffer), "changed", G_CALLBACK (block_notes_save_text), block_notes);
	
	return block_notes->scrolled_win;
}
示例#18
0
static gboolean entry_focus_out(GtkWidget *entry, GdkEventFocus *event,
				QuickSearch *qsearch)
{
	if (!qsearch->entry_entered) {
		g_signal_handlers_block_by_func(entry, entry_changed, qsearch);
		gtk_widget_modify_text(entry, GTK_STATE_NORMAL, &dim_color);
		gtk_entry_set_text(GTK_ENTRY(entry), _("Search for Subject or From"));
		g_signal_handlers_unblock_by_func(entry, entry_changed, qsearch);
	}

	return FALSE;
}
示例#19
0
static gboolean entry_focus_in(GtkWidget *entry, GdkEventFocus *event,
			       QuickSearch *qsearch)
{
	if (!qsearch->entry_entered) {
		g_signal_handlers_block_by_func(entry, entry_changed, qsearch);
		gtk_entry_set_text(GTK_ENTRY(entry), "");
		gtk_widget_modify_text(entry, GTK_STATE_NORMAL, NULL);
		g_signal_handlers_unblock_by_func(entry, entry_changed, qsearch);
	}

	return FALSE;
}
示例#20
0
/* a entry that is colored red when filled with invalid coordinate */
static GtkWidget *pos_lon_entry_new(pos_float_t lon) {
  GtkWidget *widget = osm2go_platform::entry_new();
  gtk_widget_modify_text(widget, GTK_STATE_PRELIGHT, osm2go_platform::invalid_text_color());

  char str[32];
  pos_lon_str(str, sizeof(str), lon);
  gtk_entry_set_text(GTK_ENTRY(widget), str);

  g_signal_connect(widget, "changed", G_CALLBACK(callback_modified_lon), nullptr);

  return widget;
}
示例#21
0
gboolean
toggle_event(GtkWidget *widget, gpointer gdata) {
    Data *data = (Data *) gdata;
    GdkColor *textColor = (GdkColor *) calloc(1, sizeof (GdkColor)),
            *defaultTextColor = (GdkColor *) calloc(1, sizeof (GdkColor)),
            *baseColor = (GdkColor *) calloc(1, sizeof (GdkColor));
    gdk_color_parse(TEXT_ENTRY_NON_EDITABLE_TEXT_COLOR, textColor);
    gdk_color_parse(TEXT_ENTRY_DEFAULT_TEXT_COLOR, defaultTextColor);
    gdk_color_parse(TEXT_ENTRY_DEFAULT_BASE_COLOR, baseColor);

    if (GTK_TOGGLE_BUTTON(widget)->active) {
        gtk_combo_box_set_button_sensitivity(GTK_COMBO_BOX(data->difficulty_combo),
                GTK_SENSITIVITY_ON);
        strcpy(data->player2Name, (const char *) gtk_entry_get_text(GTK_ENTRY
                (data->player2Entry)));
        gtk_widget_modify_text(data->player2Entry, GTK_STATE_NORMAL,
                textColor);
        gtk_widget_modify_base(data->player2Entry, GTK_STATE_NORMAL,
                baseColor);
        gtk_entry_set_text(GTK_ENTRY(data->player2Entry), "computer");
        gtk_entry_set_editable(GTK_ENTRY(data->player2Entry), FALSE);
    } else {
        gtk_combo_box_set_button_sensitivity(GTK_COMBO_BOX(data->difficulty_combo),
                GTK_SENSITIVITY_OFF);
        gtk_widget_modify_text(data->player2Entry, GTK_STATE_NORMAL,
                defaultTextColor);
        if (strcmp(data->player2Name, "computer") &&
                strcmp(data->player2Name, "Invalid Name"))
            gtk_entry_set_text(GTK_ENTRY(data->player2Entry),
                data->player2Name);
        else
            gtk_entry_set_text(GTK_ENTRY(data->player2Entry), "");
        gtk_entry_set_editable(GTK_ENTRY(data->player2Entry), TRUE);
    }
    free(textColor);
    free(defaultTextColor);
    free(baseColor);
    return TRUE;
}
示例#22
0
文件: entry.c 项目: Alexis-D/luakit
static gint
luaH_entry_newindex(lua_State *L, luakit_token_t token)
{
    size_t len;
    widget_t *w = luaH_checkwidget(L, 1);
    const gchar *tmp;
    GdkColor c;
    PangoFontDescription *font;

    switch(token)
    {
      case L_TK_TEXT:
        gtk_entry_set_text(GTK_ENTRY(w->widget),
            luaL_checklstring(L, 3, &len));
        break;

      case L_TK_FG:
      case L_TK_BG:
        tmp = luaL_checklstring(L, 3, &len);
        if (!gdk_color_parse(tmp, &c))
            luaL_argerror(L, 3, "unable to parse color");
        if (token == L_TK_FG) {
            gtk_widget_modify_text(GTK_WIDGET(w->widget), GTK_STATE_NORMAL, &c);
            g_object_set_data_full(G_OBJECT(w->widget), "fg", g_strdup(tmp), g_free);
        } else {
            gtk_widget_modify_base(GTK_WIDGET(w->widget), GTK_STATE_NORMAL, &c);
            g_object_set_data_full(G_OBJECT(w->widget), "bg", g_strdup(tmp), g_free);
        }
        break;

      case L_TK_SHOW_FRAME:
        gtk_entry_set_has_frame(GTK_ENTRY(w->widget), luaH_checkboolean(L, 3));
        break;

      case L_TK_POSITION:
        gtk_editable_set_position(GTK_EDITABLE(w->widget), luaL_checknumber(L, 3));
        break;

      case L_TK_FONT:
        tmp = luaL_checklstring(L, 3, &len);
        font = pango_font_description_from_string(tmp);
        gtk_widget_modify_font(GTK_WIDGET(w->widget), font);
        g_object_set_data_full(G_OBJECT(w->widget), "font", g_strdup(tmp), g_free);
        break;

      default:
        warn("unknown property: %s", luaL_checkstring(L, 2));
        return 0;
    }
    return luaH_object_emit_property_signal(L, 1);
}
示例#23
0
static void title_set_colors(ChannelTitle *title)
{
	GtkWidget *topic;

	topic = GTK_WIDGET(title->topic);

	if (!title->locked) {
		gtk_widget_modify_base(topic, GTK_STATE_NORMAL, &unlocked_base);
		gtk_widget_modify_bg(topic, GTK_STATE_NORMAL, &unlocked_bg);
		gtk_widget_modify_text(topic, GTK_STATE_NORMAL, &unlocked_text);
	} else {
		gui_tab_set_focus_colors(topic, title->view->pane->focused);
	}
}
示例#24
0
static void search_entry_changed_cb (GtkEditable *editable, YGtkHelpDialog *dialog)
{
	static GdkColor red = { 0, 255 << 8, 102 << 8, 102 << 8 };
	static GdkColor white = { 0, 0xffff, 0xffff, 0xffff };
	static GdkColor yellow = { 0, 0xf7f7, 0xf7f7, 0xbdbd };
	static GdkColor black = { 0, 0, 0, 0 };

	GtkWidget *widget = GTK_WIDGET (editable);
	GtkEntry *entry = GTK_ENTRY (editable);
	const gchar *text = gtk_entry_get_text (entry);
	gboolean found = ygtk_html_wrap_search (dialog->help_text, text);

	if (found && *text) {
		gtk_widget_modify_base (widget, GTK_STATE_NORMAL, &yellow);
		gtk_widget_modify_text (widget, GTK_STATE_NORMAL, &black);
	}
	else if (found) {  // revert
		gtk_widget_modify_base (widget, GTK_STATE_NORMAL, NULL);
		gtk_widget_modify_text (widget, GTK_STATE_NORMAL, NULL);
	}
	else {
		gtk_widget_modify_base (widget, GTK_STATE_NORMAL, &red);
		gtk_widget_modify_text (widget, GTK_STATE_NORMAL, &white);
		gtk_widget_error_bell (widget);
	}

	gboolean showIcon = *text;  // show clear icon if text
	if (showIcon != gtk_entry_get_icon_activatable (entry, GTK_ENTRY_ICON_SECONDARY)) {
		gtk_entry_set_icon_activatable (entry,
			GTK_ENTRY_ICON_SECONDARY, showIcon);
		gtk_entry_set_icon_from_stock (entry,
			GTK_ENTRY_ICON_SECONDARY, showIcon ? GTK_STOCK_CLEAR : NULL);
		if (showIcon)
			gtk_entry_set_icon_tooltip_text (entry,
				GTK_ENTRY_ICON_SECONDARY, _("Clear"));
	}
}
示例#25
0
文件: ripcurl.c 项目: dluco/ripcurl
void browser_apply_settings(Browser *b)
{
	WebKitWebFrame *frame;

	/* view */
	if (show_scrollbars) {
		gtk_scrolled_window_set_policy(b->UI.scrolled_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	} else {
		frame = webkit_web_view_get_main_frame(b->UI.view);
		g_signal_connect(G_OBJECT(frame), "scrollbars-policy-changed", G_CALLBACK(gtk_true), NULL);

		gtk_scrolled_window_set_policy(b->UI.scrolled_window, GTK_POLICY_NEVER, GTK_POLICY_NEVER);
	}

	/* apply browser settings */
	webkit_web_view_set_settings(b->UI.view, ripcurl->Global.webkit_settings);

	/* statusbar */
	gtk_misc_set_alignment(GTK_MISC(b->Statusbar.text), 0.0, 0.0);
	gtk_misc_set_alignment(GTK_MISC(b->Statusbar.buffer), 1.0, 0.0);
	gtk_misc_set_alignment(GTK_MISC(b->Statusbar.position), 1.0, 0.0);

	gtk_misc_set_padding(GTK_MISC(b->Statusbar.text), 1.0, 2.0);
	gtk_misc_set_padding(GTK_MISC(b->Statusbar.buffer), 1.0, 2.0);
	gtk_misc_set_padding(GTK_MISC(b->Statusbar.position), 1.0, 2.0);

	gtk_widget_modify_bg(GTK_WIDGET(b->UI.statusbar), GTK_STATE_NORMAL, &(ripcurl->Style.statusbar_bg));
	gtk_widget_modify_fg(GTK_WIDGET(b->Statusbar.text), GTK_STATE_NORMAL, &(ripcurl->Style.statusbar_fg));
	gtk_widget_modify_fg(GTK_WIDGET(b->Statusbar.buffer), GTK_STATE_NORMAL, &(ripcurl->Style.statusbar_fg));
	gtk_widget_modify_fg(GTK_WIDGET(b->Statusbar.position), GTK_STATE_NORMAL, &(ripcurl->Style.statusbar_fg));

	gtk_widget_modify_font(GTK_WIDGET(b->Statusbar.text), ripcurl->Style.font);
	gtk_widget_modify_font(GTK_WIDGET(b->Statusbar.buffer), ripcurl->Style.font);
	gtk_widget_modify_font(GTK_WIDGET(b->Statusbar.position), ripcurl->Style.font);

	/* inputbar settings */
	gtk_entry_set_inner_border(b->UI.inputbar, NULL);
	gtk_entry_set_has_frame(b->UI.inputbar, FALSE);
	gtk_editable_set_editable(GTK_EDITABLE(b->UI.inputbar), TRUE);

	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));
	gtk_widget_modify_font(GTK_WIDGET(b->UI.inputbar), ripcurl->Style.font);

}
示例#26
0
gboolean
focus_text_entry_event(GtkEntry *entry, gpointer gdata) {
    const gchar *text = gtk_entry_get_text(entry);

    if (!(strcmp((char *) text, "Invalid Name"))) {
        GdkColor *baseColor = (GdkColor *) calloc(1, sizeof (GdkColor));
        GdkColor *defaultTextColor = (GdkColor *) calloc(1, sizeof (GdkColor));
        gdk_color_parse(TEXT_ENTRY_DEFAULT_BASE_COLOR, baseColor);
        gdk_color_parse(TEXT_ENTRY_DEFAULT_TEXT_COLOR, defaultTextColor);
        gtk_widget_modify_base(GTK_WIDGET(entry), GTK_STATE_NORMAL, baseColor);
        gtk_widget_modify_text(GTK_WIDGET(entry), GTK_STATE_NORMAL,
                defaultTextColor);
        gtk_entry_set_text(entry, "");
        gtk_entry_set_editable(entry, TRUE);
        free(defaultTextColor);
        free(baseColor);
    }
    return TRUE;
}
示例#27
0
static void
shell_searchbar_update_search_widgets (EShellSearchbar *searchbar)
{
	EShellView *shell_view;
	EShellWindow *shell_window;
	GtkAction *action;
	GtkWidget *widget;
	const gchar *search_text;
	gboolean sensitive;

	/* EShellView subclasses are responsible for actually
	 * executing the search.  This is all cosmetic stuff. */

	widget = searchbar->priv->search_entry;
	shell_view = e_shell_searchbar_get_shell_view (searchbar);
	shell_window = e_shell_view_get_shell_window (shell_view);
	search_text = e_shell_searchbar_get_search_text (searchbar);

	sensitive =
		(search_text != NULL && *search_text != '\0') ||
		(e_shell_view_get_search_rule (shell_view) != NULL);

	if (sensitive) {
		GtkStyle *style;
		const GdkColor *color;

		style = gtk_widget_get_style (widget);
		color = &style->mid[GTK_STATE_SELECTED];

		gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, color);
		gtk_widget_modify_text (widget, GTK_STATE_NORMAL, NULL);
	} else {
		/* Text color will be updated when we move the focus. */
		gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, NULL);
	}

	action = E_SHELL_WINDOW_ACTION_SEARCH_CLEAR (shell_window);
	gtk_action_set_sensitive (action, sensitive);

	action = E_SHELL_WINDOW_ACTION_SEARCH_SAVE (shell_window);
	gtk_action_set_sensitive (action, sensitive);
}
JNIEXPORT void JNICALL 
Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_gtkWidgetSetForeground
  (JNIEnv *env, jobject obj, jint red, jint green, jint blue)
{
  GdkColor color;
  void *ptr;

  ptr = NSA_GET_PTR (env, obj);

  color.red = (red / 255.0) * 65535;
  color.green = (green / 255.0) * 65535;
  color.blue = (blue / 255.0) * 65535;

  gdk_threads_enter ();

  gtk_widget_modify_text (GTK_WIDGET (ptr), GTK_STATE_NORMAL, &color);
  gtk_widget_modify_base (GTK_WIDGET (ptr), GTK_STATE_SELECTED, &color);

  gdk_threads_leave ();
}
示例#29
0
void
mousepad_util_entry_error (GtkWidget *widget,
                           gboolean   error)
{
  const GdkColor red   = {0, 0xffff, 0x6666, 0x6666};
  const GdkColor white = {0, 0xffff, 0xffff, 0xffff};
  gpointer       pointer;

  g_return_if_fail (GTK_IS_WIDGET (widget));

  /* get the current error state */
  pointer = mousepad_object_get_data (G_OBJECT (widget), "error-state");

  /* only change the state when really needed to avoid multiple widget calls */
  if (GPOINTER_TO_INT (pointer) != error)
    {
      /* set the widget style */
      gtk_widget_modify_base (widget, GTK_STATE_NORMAL, error ? &red : NULL);
      gtk_widget_modify_text (widget, GTK_STATE_NORMAL, error ? &white : NULL);

      /* set the new state */
      mousepad_object_set_data (G_OBJECT (widget), "error-state", GINT_TO_POINTER (error));
    }
}
示例#30
0
void
gui_main_init ()
{
    struct t_gui_buffer *ptr_buffer;
    struct t_gui_bar *ptr_bar;
    struct t_gui_bar_window *ptr_bar_win;
    GdkColor color_fg, color_bg;
    
    gui_color_init ();
    
    gui_ok = 1;
    
    /* build prefixes according to config */
    gui_chat_prefix_build ();
    
    /* init clipboard buffer */
    gui_input_clipboard = NULL;
    
    /* create Gtk widgets */
    
    gdk_color_parse ("white", &color_fg);
    gdk_color_parse ("black", &color_bg);
    
    gui_gtk_main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title (GTK_WINDOW (gui_gtk_main_window), PACKAGE_STRING);
    
    g_signal_connect (G_OBJECT (gui_gtk_main_window), "destroy", gtk_main_quit, NULL);
    
    gui_gtk_vbox1 = gtk_vbox_new (FALSE, 0);
    gtk_widget_show (gui_gtk_vbox1);
    gtk_container_add (GTK_CONTAINER (gui_gtk_main_window), gui_gtk_vbox1);
    
    gui_gtk_entry_topic = gtk_entry_new ();
    gtk_widget_show (gui_gtk_entry_topic);
    gtk_box_pack_start (GTK_BOX (gui_gtk_vbox1), gui_gtk_entry_topic, FALSE, FALSE, 0);
    gtk_widget_modify_text (gui_gtk_entry_topic, GTK_STATE_NORMAL, &color_fg);
    gtk_widget_modify_base (gui_gtk_entry_topic, GTK_STATE_NORMAL, &color_bg);
    
    gui_gtk_notebook1 = gtk_notebook_new ();
    gtk_widget_show (gui_gtk_notebook1);
    gtk_box_pack_start (GTK_BOX (gui_gtk_vbox1), gui_gtk_notebook1, TRUE, TRUE, 0);
    gtk_notebook_set_tab_pos (GTK_NOTEBOOK (gui_gtk_notebook1), GTK_POS_BOTTOM);
    
    gui_gtk_vbox2 = gtk_vbox_new (FALSE, 0);
    gtk_widget_show (gui_gtk_vbox2);
    gtk_container_add (GTK_CONTAINER (gui_gtk_notebook1), gui_gtk_vbox2);
    
    gui_gtk_hbox1 = gtk_hbox_new (FALSE, 0);
    gtk_widget_show (gui_gtk_hbox1);
    gtk_box_pack_start (GTK_BOX (gui_gtk_vbox2), gui_gtk_hbox1, TRUE, TRUE, 0);
    
    gui_gtk_hpaned1 = gtk_hpaned_new ();
    gtk_widget_show (gui_gtk_hpaned1);
    gtk_box_pack_start (GTK_BOX (gui_gtk_hbox1), gui_gtk_hpaned1, TRUE, TRUE, 0);
    gtk_paned_set_position (GTK_PANED (gui_gtk_hpaned1), 0);
    
    gui_gtk_scrolledwindow_chat = gtk_scrolled_window_new (NULL, NULL);
    gtk_widget_show (gui_gtk_scrolledwindow_chat);
    gtk_paned_pack1 (GTK_PANED (gui_gtk_hpaned1), gui_gtk_scrolledwindow_chat,
                     FALSE, TRUE);
    //gtk_box_pack_start (GTK_PANED (hpaned1), scrolledwindow_chat, TRUE, TRUE, 0);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (gui_gtk_scrolledwindow_chat),
                                    GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
    gtk_widget_modify_text (gui_gtk_scrolledwindow_chat, GTK_STATE_NORMAL, &color_fg);
    gtk_widget_modify_base (gui_gtk_scrolledwindow_chat, GTK_STATE_NORMAL, &color_bg);
    
    gui_gtk_scrolledwindow_nick = gtk_scrolled_window_new (NULL, NULL);
    gtk_widget_show (gui_gtk_scrolledwindow_nick);
    gtk_paned_pack2 (GTK_PANED (gui_gtk_hpaned1), gui_gtk_scrolledwindow_nick,
                     FALSE, TRUE);
    //gtk_box_pack_start (GTK_PANED (hpaned1), scrolledwindow_nick, TRUE, TRUE, 0);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (gui_gtk_scrolledwindow_nick),
                                    GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
    gtk_widget_modify_text (gui_gtk_scrolledwindow_nick, GTK_STATE_NORMAL, &color_fg);
    gtk_widget_modify_base (gui_gtk_scrolledwindow_nick, GTK_STATE_NORMAL, &color_bg);
    
    gui_gtk_entry_input = gtk_entry_new ();
    gtk_widget_show (gui_gtk_entry_input);
    gtk_box_pack_start (GTK_BOX (gui_gtk_vbox2), gui_gtk_entry_input, FALSE,
                        FALSE, 0);
    gtk_widget_modify_text (gui_gtk_entry_input, GTK_STATE_NORMAL, &color_fg);
    gtk_widget_modify_base (gui_gtk_entry_input, GTK_STATE_NORMAL, &color_bg);
    
    gui_gtk_label1 = gtk_label_new (_("server"));
    gtk_widget_show (gui_gtk_label1);
    gtk_notebook_set_tab_label (GTK_NOTEBOOK (gui_gtk_notebook1),
                                gtk_notebook_get_nth_page (GTK_NOTEBOOK (gui_gtk_notebook1), 0),
                                gui_gtk_label1);
    gtk_label_set_justify (GTK_LABEL (gui_gtk_label1), GTK_JUSTIFY_LEFT);
    
    gtk_widget_show_all (gui_gtk_main_window);
    
    gui_init_ok = 0;
    
    /* create core buffer */
    ptr_buffer = gui_buffer_new (NULL, "weechat", NULL, NULL, NULL, NULL);
    if (ptr_buffer)
    {
        gui_init_ok = 1;
        
        /* set title for core buffer */
        gui_buffer_set_title (ptr_buffer,
                              "WeeChat " WEECHAT_COPYRIGHT_DATE
                              " - " WEECHAT_WEBSITE);
        
        /* create main window (using full space) */
        if (gui_window_new (NULL, ptr_buffer, 0, 0, 0, 0, 100, 100))
        {
            gui_current_window = gui_windows;
            
            if (CONFIG_BOOLEAN(config_look_set_title))
                gui_window_set_title (PACKAGE_NAME " " PACKAGE_VERSION);
        }
        
        /* create bar windows for root bars (they were read from config,
           but no window was created (GUI was not initialized) */
        for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
        {
            if ((CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT)
                && (!ptr_bar->bar_window))
            {
                gui_bar_window_new (ptr_bar, NULL);
            }
        }
        for (ptr_bar_win = gui_windows->bar_windows;
             ptr_bar_win; ptr_bar_win = ptr_bar_win->next_bar_window)
        {
            gui_bar_window_calculate_pos_size (ptr_bar_win, gui_windows);
            gui_bar_window_create_win (ptr_bar_win);
        }
    }
}