本文整理汇总了C++中GTK_COLOR_SELECTION函数的典型用法代码示例。如果您正苦于以下问题:C++ GTK_COLOR_SELECTION函数的具体用法?C++ GTK_COLOR_SELECTION怎么用?C++ GTK_COLOR_SELECTION使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GTK_COLOR_SELECTION函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: upj2
void upj2(GtkWidget *wgt, gpointer dta)
{
GdkColor cl1;
guint16 alp;
GtkPlot *pt;
pt=GTK_PLOT(pt2);
if (gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(wgt)))
{
(cl1.red)=(guint16) (65535*g_array_index((pt->rd), gdouble, 1));
(cl1.green)=(guint16) (65535*g_array_index((pt->gr), gdouble, 1));
(cl1.blue)=(guint16) (65535*g_array_index((pt->bl), gdouble, 1));
alp=(guint16) (65535*g_array_index((pt->al), gdouble, 1));
}
else
{
(cl1.red)=(guint16) (65535*g_array_index((pt->rd), gdouble, 0));
(cl1.green)=(guint16) (65535*g_array_index((pt->gr), gdouble, 0));
(cl1.blue)=(guint16) (65535*g_array_index((pt->bl), gdouble, 0));
alp=(guint16) (65535*g_array_index((pt->al), gdouble, 0));
}
gdk_colormap_alloc_color(cmp, &cl1, FALSE, TRUE);
gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(cs2), &cl1);
gtk_color_selection_set_current_alpha(GTK_COLOR_SELECTION(cs2), alp);
}
示例2: row_activated
static void row_activated(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *column, GtkWidget *widget)
{
GtkTreeIter iter;
GtkTreeModel *model = gtk_tree_view_get_model(view);
GValue value = { 0, };
int id;
if(!gtk_tree_model_get_iter(model,&iter,path))
{
gtk_widget_set_sensitive(widget,0);
return;
}
gtk_tree_model_get_value(model,&iter,1,&value);
id = g_value_get_int(&value);
g_object_set_data(G_OBJECT(widget),"selected",(gpointer) id);
if(id < 0 || id >= TERMINAL_COLOR_COUNT)
{
gtk_widget_set_sensitive(widget,0);
return;
}
gtk_color_selection_set_previous_color(GTK_COLOR_SELECTION(widget),color+id);
gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(widget),color+id);
gtk_widget_set_sensitive(widget,1);
}
示例3: clip_GTK_COLORSELECTIONSETCOLOR
/* Sets the color in the GtkColorSelection. The widgets are updated to
* reflect the new color. */
int
clip_GTK_COLORSELECTIONSETCOLOR(ClipMachine * ClipMachineMemory)
{
C_widget *ccsel = _fetch_cw_arg(ClipMachineMemory);
ClipVar *mcolor = _clip_spar(ClipMachineMemory, 2);
gdouble color[4];
gdouble k, max;
CHECKCWID(ccsel, GTK_IS_COLOR_SELECTION);
CHECKOPT(2, MAP_type_of_ClipVarType);
if (_clip_parinfo(ClipMachineMemory, 2) == UNDEF_type_of_ClipVarType)
gtk_color_selection_get_color(GTK_COLOR_SELECTION(ccsel->widget), color);
else
_map_get_colors(ClipMachineMemory, mcolor, color);
color[0] = color[0] > 0 ? color[0] : 1;
color[1] = color[1] > 0 ? color[1] : 1;
color[2] = color[2] > 0 ? color[2] : 1;
max = color[0] > color[1] ? color[0] : color[1];
max = max > color[2] ? max : color[2];
max = max > 0 ? max : 1;
k = 1 / max;
color[0] *= k;
color[1] *= k;
color[2] *= k;
gtk_color_selection_set_color(GTK_COLOR_SELECTION(ccsel->widget), color);
return 0;
err:
return 1;
}
示例4: uber_label_block_button_press_event
/**
* uber_label_block_button_press_event:
* @widget: A #GtkWidget.
* @event: A #GdkEventButton.
* @label: An #UberLabel.
*
* Callback to handle a button press event within the colored block.
*
* Returns: %FALSE always to allow further signal emission.
* Side effects: None.
*/
static gboolean
uber_label_block_button_press_event (GtkWidget *widget, /* IN */
GdkEventButton *event, /* IN */
UberLabel *label) /* IN */
{
UberLabelPrivate *priv;
GtkWidget *dialog;
GtkWidget *selection;
g_return_val_if_fail(UBER_IS_LABEL(label), FALSE);
priv = label->priv;
dialog = gtk_color_selection_dialog_new("");
selection = gtk_color_selection_dialog_get_color_selection(
GTK_COLOR_SELECTION_DIALOG(dialog));
gtk_color_selection_set_current_color(
GTK_COLOR_SELECTION(selection),
&priv->color);
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
gtk_color_selection_get_current_color(
GTK_COLOR_SELECTION(selection),
&priv->color);
gtk_widget_queue_draw(widget);
g_signal_emit(label, signals[COLOR_CHANGED],
0, &priv->color);
}
gtk_widget_destroy(dialog);
return FALSE;
}
示例5: gtk_color_selection_set_current_color
bool GtkToolkitColorChooser::Show(X11Types::Window parent, uint32_t initial_color)
{
GdkColor old_color = GtkUtils::ColorrefToGdkColor(initial_color);
gtk_color_selection_set_current_color (
GTK_COLOR_SELECTION(m_color_selector), &old_color);
// we have to show dialog before running it
gtk_widget_show(m_dialog);
// otherwise this will result in nasty crash inside gtk
XSetTransientForHint(GDK_WINDOW_XDISPLAY(gtk_widget_get_window(m_dialog)),
GDK_WINDOW_XID(gtk_widget_get_window(m_dialog)), parent);
GtkUtils::SetResourceName(m_dialog, "colorselectordialog");
gint result = gtk_dialog_run(GTK_DIALOG(m_dialog));
GdkColor new_color;
gtk_color_selection_get_current_color(
GTK_COLOR_SELECTION(m_color_selector), &new_color);
m_color = GtkUtils::GdkColorToColorref(&new_color);
gtk_widget_destroy (m_dialog);
GtkUtils::ProcessEvents();
return (GTK_RESPONSE_OK == result);
}
示例6: purplerc_set_color
static void
purplerc_set_color(GtkWidget *widget, gpointer data)
{
GdkColor color;
gchar title[128];
const gchar *pref = NULL;
GtkWidget *color_dialog = NULL;
gint subscript = GPOINTER_TO_INT(data);
g_snprintf(title, sizeof(title), _("Select Color for %s"),
_(color_names[GPOINTER_TO_INT(data)]));
color_dialog = gtk_color_selection_dialog_new(_("Select Color"));
g_signal_connect(G_OBJECT(color_dialog), "response",
G_CALLBACK(purplerc_color_response), data);
pref = purple_prefs_get_string(color_prefs[subscript]);
if (pref != NULL && strcmp(pref, "")) {
if (gdk_color_parse(pref, &color)) {
#if GTK_CHECK_VERSION(2,14,0)
gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(
gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(color_dialog))),
&color);
#else
gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(color_dialog)->colorsel), &color);
#endif
}
}
gtk_window_present(GTK_WINDOW(color_dialog));
}
示例7: DIA_colorSel
int DIA_colorSel(uint8_t *r, uint8_t *g, uint8_t *b)
{
GtkWidget *dialog;
int ret=0;
GdkColor color;
dialog=create_colorselectiondialog1();
color.red=*r<<8;
color.green=*g<<8;
color.blue=*b<<8;
gtk_color_selection_set_current_color (GTK_COLOR_SELECTION(WID(color_selection1)),&color);
if(GTK_RESPONSE_OK==gtk_dialog_run(GTK_DIALOG(dialog)))
{
gtk_color_selection_get_current_color (GTK_COLOR_SELECTION(WID(color_selection1)),&color);
*r=color.red>>8;
*g=color.green>>8;
*b=color.blue>>8;
ret=1;
}
示例8: clip_GTK_COLORSELECTIONGETCOLOR
/* Retrieve the currently selected color value. */
int
clip_GTK_COLORSELECTIONGETCOLOR(ClipMachine * ClipMachineMemory)
{
C_widget *ccsel = _fetch_cw_arg(ClipMachineMemory);
GtkColorSelection *colorsel;
ClipVar mcolor;
gdouble color[4];
CHECKCWID(ccsel, GTK_IS_COLOR_SELECTION);
colorsel = GTK_COLOR_SELECTION(ccsel->widget);
gtk_color_selection_get_color(GTK_COLOR_SELECTION(ccsel->widget), color);
color[0] *= CLIP_GTK_MAX_COLOR;
color[1] *= CLIP_GTK_MAX_COLOR;
color[2] *= CLIP_GTK_MAX_COLOR;
memset(&mcolor, 0, sizeof(mcolor));
_clip_map(ClipMachineMemory, &mcolor);
_map_put_colors(ClipMachineMemory, &mcolor, color);
_clip_mclone(ClipMachineMemory, RETPTR(ClipMachineMemory), &mcolor);
return 0;
err:
return 1;
}
示例9: gtk_color_button_clicked
static void
gtk_color_button_clicked (GtkButton *button)
{
GtkColorButton *color_button = GTK_COLOR_BUTTON (button);
GtkColorSelectionDialog *color_dialog;
/* if dialog already exists, make sure it's shown and raised */
if (!color_button->priv->cs_dialog)
{
/* Create the dialog and connects its buttons */
GtkWidget *parent;
parent = gtk_widget_get_toplevel (GTK_WIDGET (color_button));
color_button->priv->cs_dialog = gtk_color_selection_dialog_new (color_button->priv->title);
color_dialog = GTK_COLOR_SELECTION_DIALOG (color_button->priv->cs_dialog);
if (gtk_widget_is_toplevel (parent) && GTK_IS_WINDOW (parent))
{
if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (color_dialog)))
gtk_window_set_transient_for (GTK_WINDOW (color_dialog), GTK_WINDOW (parent));
gtk_window_set_modal (GTK_WINDOW (color_dialog),
gtk_window_get_modal (GTK_WINDOW (parent)));
}
g_signal_connect (color_dialog->ok_button, "clicked",
G_CALLBACK (dialog_ok_clicked), color_button);
g_signal_connect (color_dialog->cancel_button, "clicked",
G_CALLBACK (dialog_cancel_clicked), color_button);
g_signal_connect (color_dialog, "destroy",
G_CALLBACK (dialog_destroy), color_button);
}
color_dialog = GTK_COLOR_SELECTION_DIALOG (color_button->priv->cs_dialog);
gtk_color_selection_set_has_opacity_control (GTK_COLOR_SELECTION (color_dialog->colorsel),
color_button->priv->use_alpha);
gtk_color_selection_set_previous_color (GTK_COLOR_SELECTION (color_dialog->colorsel),
&color_button->priv->color);
gtk_color_selection_set_previous_alpha (GTK_COLOR_SELECTION (color_dialog->colorsel),
color_button->priv->alpha);
gtk_color_selection_set_current_color (GTK_COLOR_SELECTION (color_dialog->colorsel),
&color_button->priv->color);
gtk_color_selection_set_current_alpha (GTK_COLOR_SELECTION (color_dialog->colorsel),
color_button->priv->alpha);
gtk_window_present (GTK_WINDOW (color_button->priv->cs_dialog));
}
示例10: gsm_color_button_clicked
static gint
gsm_color_button_clicked (GtkWidget * widget, GdkEventButton * event)
{
GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
GtkColorSelectionDialog *color_dialog;
/* if dialog already exists, make sure it's shown and raised */
if (!color_button->priv->cs_dialog)
{
/* Create the dialog and connects its buttons */
GtkWidget *parent;
parent = gtk_widget_get_toplevel (GTK_WIDGET (color_button));
color_button->priv->cs_dialog =
gtk_color_selection_dialog_new (color_button->priv->title);
color_dialog =
GTK_COLOR_SELECTION_DIALOG (color_button->priv->cs_dialog);
if (gtk_widget_is_toplevel (parent) && GTK_IS_WINDOW (parent))
{
if (GTK_WINDOW (parent) !=
gtk_window_get_transient_for (GTK_WINDOW (color_dialog)))
gtk_window_set_transient_for (GTK_WINDOW (color_dialog),
GTK_WINDOW (parent));
gtk_window_set_modal (GTK_WINDOW (color_dialog),
gtk_window_get_modal (GTK_WINDOW (parent)));
}
g_signal_connect (color_dialog, "response",
G_CALLBACK (dialog_response), color_button);
g_signal_connect (color_dialog, "destroy",
G_CALLBACK (dialog_destroy), color_button);
}
color_dialog = GTK_COLOR_SELECTION_DIALOG (color_button->priv->cs_dialog);
gtk_color_selection_set_previous_color (GTK_COLOR_SELECTION
(gtk_color_selection_dialog_get_color_selection (color_dialog)),
&color_button->priv->color);
gtk_color_selection_set_current_color (GTK_COLOR_SELECTION
(gtk_color_selection_dialog_get_color_selection (color_dialog)),
&color_button->priv->color);
gtk_window_present (GTK_WINDOW (color_button->priv->cs_dialog));
return 0;
}
示例11: cb_tsin_cursor_color
static gboolean cb_tsin_cursor_color( GtkWidget *widget,
gpointer data )
{
GtkWidget *color_selector = gtk_color_selection_dialog_new (_("詞音游標的顏色"));
gtk_color_selection_set_current_color(
GTK_COLOR_SELECTION(gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(color_selector))),
&tsin_cursor_gcolor);
#if 0
g_signal_connect (GTK_OBJECT (color_selector->ok_button),
"clicked",
G_CALLBACK (cb_save_tsin_cursor_color),
(gpointer) color_selector);
#if 1
g_signal_connect_swapped (GTK_OBJECT (color_selector->ok_button),
"clicked",
G_CALLBACK (gtk_widget_destroy),
(gpointer) color_selector);
#endif
g_signal_connect_swapped (GTK_OBJECT (color_selector->cancel_button),
"clicked",
G_CALLBACK (gtk_widget_destroy),
(gpointer) color_selector);
#endif
gtk_widget_show((GtkWidget*)color_selector);
#if 1
if (gtk_dialog_run(GTK_DIALOG(color_selector)) == GTK_RESPONSE_OK)
cb_save_tsin_cursor_color((GtkWidget *)color_selector, (gpointer) color_selector);
gtk_widget_destroy((GtkWidget *)color_selector);
#endif
return TRUE;
}
示例12: GetParentForModalDialog
bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
{
if (data)
m_data = *data;
m_parent = GetParentForModalDialog(parent, 0);
GtkWindow * const parentGTK = m_parent ? GTK_WINDOW(m_parent->m_widget)
: NULL;
wxString title(_("Choose colour"));
m_widget = gtk_color_selection_dialog_new(wxGTK_CONV(title));
g_object_ref(m_widget);
if ( parentGTK )
{
gtk_window_set_transient_for(GTK_WINDOW(m_widget), parentGTK);
}
GtkColorSelection* sel = GTK_COLOR_SELECTION(
gtk_color_selection_dialog_get_color_selection(
GTK_COLOR_SELECTION_DIALOG(m_widget)));
gtk_color_selection_set_has_palette(sel, true);
return true;
}
示例13: change_color_callback
static void
change_color_callback (GtkWidget *button,
gpointer data)
{
GtkWidget *dialog;
GtkColorSelection *colorsel;
GtkColorSelectionDialog *selection_dialog;
gint response;
dialog = gtk_color_selection_dialog_new ("Changing color");
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
selection_dialog = GTK_COLOR_SELECTION_DIALOG (dialog);
colorsel = GTK_COLOR_SELECTION (gtk_color_selection_dialog_get_color_selection (selection_dialog));
gtk_color_selection_set_previous_rgba (colorsel, &color);
gtk_color_selection_set_current_rgba (colorsel, &color);
gtk_color_selection_set_has_palette (colorsel, TRUE);
response = gtk_dialog_run (GTK_DIALOG (dialog));
if (response == GTK_RESPONSE_OK)
{
gtk_color_selection_get_current_rgba (colorsel, &color);
gtk_widget_override_background_color (da, 0, &color);
}
gtk_widget_destroy (dialog);
}
示例14: colsel_ok_clicked_lcb
static void colsel_ok_clicked_lcb(GtkWidget *widget, Tcolsel *csd) {
gchar *tmpstr;
GdkColor gcolor;
/* only on a OK click we do the setcolor thing */
gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(csd->csel), &gcolor);
tmpstr = gdk_color_to_hexstring(&gcolor, FALSE);
if (csd->bfwin) {
csd->bfwin->session->colorlist = add_to_stringlist(csd->bfwin->session->colorlist, tmpstr);
}
if (csd->is_modal) {
g_free(csd->returnval);
csd->returnval = tmpstr;
gtk_main_quit();
} else {
if (string_is_color(tmpstr)) {
if (csd->startpos || csd->endpos) {
DEBUG_MSG("colsel_ok_clicked_lcb, replacing with %s\n", tmpstr);
doc_replace_text(csd->bfwin->current_document, tmpstr, csd->startpos, csd->endpos);
} else {
DEBUG_MSG("colsel_ok_clicked_lcb, inserting %s\n", tmpstr);
doc_insert_two_strings(csd->bfwin->current_document,tmpstr, NULL);
}
}
g_free(tmpstr);
window_destroy(csd->win);
}
}
示例15: on_color_change_button_clicked
void
on_color_change_button_clicked (GtkButton * button, gpointer user_data)
{
GtkTreePath *gpath;
GtkTreeViewColumn *gcol;
GtkTreeIter it;
GdkColor *gdk_color;
GtkColorSelectionDialog *dlg;
GtkColorSelection *csel;
EATreePos ep;
if (!get_color_store (&ep))
return;
/* gets the row (path) at cursor */
gtk_tree_view_get_cursor (ep.gv, &gpath, &gcol);
if (!gpath)
return; /* no row selected */
/* get iterator from path */
if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (ep.gs), &it, gpath))
return;
gtk_tree_model_get (GTK_TREE_MODEL (ep.gs), &it, 1, &gdk_color, -1);
dlg = GTK_COLOR_SELECTION_DIALOG
(glade_xml_get_widget (appdata.xml, "colorselectiondialog"));
csel = GTK_COLOR_SELECTION(dlg->colorsel);
gtk_color_selection_set_current_color(csel, gdk_color);
gtk_color_selection_set_previous_color(csel, gdk_color);
g_object_set_data( G_OBJECT(dlg), "isadd", GINT_TO_POINTER(FALSE));
gtk_widget_show (GTK_WIDGET(dlg));
} /* on_color_change_button_clicked */