本文整理汇总了C++中GTK_SWITCH函数的典型用法代码示例。如果您正苦于以下问题:C++ GTK_SWITCH函数的具体用法?C++ GTK_SWITCH怎么用?C++ GTK_SWITCH使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GTK_SWITCH函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gtk_switch_get_property
static void
gtk_switch_get_property (GObject *gobject,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkSwitchPrivate *priv = GTK_SWITCH (gobject)->priv;
switch (prop_id)
{
case PROP_ACTIVE:
g_value_set_boolean (value, priv->is_active);
break;
case PROP_RELATED_ACTION:
g_value_set_object (value, priv->action);
break;
case PROP_USE_ACTION_APPEARANCE:
g_value_set_boolean (value, priv->use_action_appearance);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
}
}
示例2: gpinstruct_lesson_test_multi_choice_editor_new
GPInstructLessonTestMultiChoiceEditor *
gpinstruct_lesson_test_multi_choice_editor_new (GPInstructEditorWindow *window,
GPInstructLessonTestMultiChoice *test)
{
GPInstructLessonTestMultiChoiceEditor *editor = g_object_new (GPINSTRUCT_TYPE_LESSON_TEST_MULTI_CHOICE_EDITOR, NULL);
GPInstructLessonTestMultiChoiceEditorPrivate *priv = editor->priv;
priv->window = window;
priv->test = test;
gtk_entry_set_text (GTK_ENTRY (priv->title_entry),
gpinstruct_lesson_element_get_title (GPINSTRUCT_LESSON_ELEMENT (test)));
g_signal_connect (priv->title_entry, "activate",
G_CALLBACK (title_entry_activate), editor);
GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->directions_view));
gtk_text_buffer_set_text (buffer,
gpinstruct_lesson_test_get_directions (GPINSTRUCT_LESSON_TEST (test)), -1);
g_signal_connect (buffer, "changed",
G_CALLBACK (directions_buffer_changed), editor);
gtk_switch_set_active (GTK_SWITCH (priv->explain_switch),
gpinstruct_lesson_test_get_explain (GPINSTRUCT_LESSON_TEST (test)));
g_signal_connect (priv->explain_switch, "notify::active",
G_CALLBACK (explain_activate), editor);
update_questions_tree_view (editor);
return editor;
}
示例3: gtk_switch_set_property
static void
gtk_switch_set_property (GObject *gobject,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkSwitch *sw = GTK_SWITCH (gobject);
switch (prop_id)
{
case PROP_ACTIVE:
gtk_switch_set_active (sw, g_value_get_boolean (value));
break;
case PROP_RELATED_ACTION:
gtk_switch_set_related_action (sw, g_value_get_object (value));
break;
case PROP_USE_ACTION_APPEARANCE:
gtk_switch_set_use_action_appearance (sw, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
}
}
示例4: cc_sharing_panel_switch_to_label_transform_func
static gboolean
cc_sharing_panel_switch_to_label_transform_func (GBinding *binding,
const GValue *source_value,
GValue *target_value,
CcSharingPanel *self)
{
gboolean active;
if (!G_VALUE_HOLDS_BOOLEAN (source_value))
return FALSE;
if (!G_VALUE_HOLDS_STRING (target_value))
return FALSE;
active = g_value_get_boolean (source_value);
if (active)
g_value_set_string (target_value, C_("service is enabled", "On"));
else
g_value_set_string (target_value, C_("service is disabled", "Off"));
/* ensure the master switch is active if one of the services is active */
if (active)
gtk_switch_set_active (GTK_SWITCH (self->priv->master_switch), TRUE);
return TRUE;
}
示例5: nimf_settings_page_key_build_boolean
static GtkWidget *
nimf_settings_page_key_build_boolean (NimfSettingsPageKey *page_key)
{
GtkWidget *gswitch;
GtkWidget *hbox;
gchar *detailed_signal;
gboolean is_active;
gswitch = gtk_switch_new ();
is_active = g_settings_get_boolean (page_key->gsettings, page_key->key);
gtk_switch_set_active (GTK_SWITCH (gswitch), is_active);
gtk_widget_set_halign (gswitch, GTK_ALIGN_END);
detailed_signal = g_strdup_printf ("changed::%s", page_key->key);
g_signal_connect (gswitch, "notify::active",
G_CALLBACK (on_notify_active), page_key);
g_signal_connect (page_key->gsettings, detailed_signal,
G_CALLBACK (on_gsettings_changed), gswitch);
g_free (detailed_signal);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 15);
gtk_box_pack_start (GTK_BOX (hbox), page_key->label, FALSE, FALSE, 0);
gtk_box_pack_end (GTK_BOX (hbox), gswitch, FALSE, FALSE, 0);
return hbox;
}
示例6: device_ethernet_refresh_ui
static void
device_ethernet_refresh_ui (NetDeviceEthernet *device)
{
NMDevice *nm_device;
NMDeviceState state;
GtkWidget *widget;
gchar *speed = NULL;
nm_device = net_device_get_nm_device (NET_DEVICE (device));
widget = GTK_WIDGET (gtk_builder_get_object (device->builder, "label_device"));
gtk_label_set_label (GTK_LABEL (widget), net_object_get_title (NET_OBJECT (device)));
widget = GTK_WIDGET (gtk_builder_get_object (device->builder, "image_device"));
gtk_image_set_from_icon_name (GTK_IMAGE (widget),
panel_device_to_icon_name (nm_device, FALSE),
GTK_ICON_SIZE_DIALOG);
widget = GTK_WIDGET (gtk_builder_get_object (device->builder, "device_off_switch"));
state = nm_device_get_state (nm_device);
gtk_widget_set_visible (widget,
state != NM_DEVICE_STATE_UNAVAILABLE
&& state != NM_DEVICE_STATE_UNMANAGED);
device->updating_device = TRUE;
gtk_switch_set_active (GTK_SWITCH (widget), device_state_to_off_switch (state));
device->updating_device = FALSE;
if (state != NM_DEVICE_STATE_UNAVAILABLE)
speed = net_device_simple_get_speed (NET_DEVICE_SIMPLE (device));
panel_set_device_status (device->builder, "label_status", nm_device, speed);
populate_ui (device);
}
示例7: on_perm_store_set_done
static void
on_perm_store_set_done (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
LocationAppStateData *data;
GVariant *results;
GError *error = NULL;
results = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object),
res,
&error);
if (results == NULL)
{
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
g_warning ("Failed to store permissions: %s", error->message);
g_error_free (error);
return;
}
g_variant_unref (results);
data = (LocationAppStateData *) user_data;
data->changing_state = FALSE;
gtk_switch_set_state (GTK_SWITCH (data->widget), data->pending_state);
}
示例8: gtk_switch_key_release
static gboolean
gtk_switch_key_release (GtkWidget *widget,
GdkEventKey *event)
{
GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv;
if (event->keyval == GDK_KEY_Return ||
event->keyval == GDK_KEY_KP_Enter ||
event->keyval == GDK_KEY_ISO_Enter ||
event->keyval == GDK_KEY_space ||
event->keyval == GDK_KEY_KP_Space)
{
gtk_switch_set_active (GTK_SWITCH (widget), !priv->is_active);
}
return FALSE;
}
示例9: on_gsettings_changed
static void
on_gsettings_changed (GSettings *settings,
gchar *key,
GtkWidget *widget)
{
if (GTK_IS_SWITCH (widget))
{
gboolean active1 = g_settings_get_boolean (settings, key);
gboolean active2 = gtk_switch_get_active (GTK_SWITCH (widget));
if (active1 != active2)
gtk_switch_set_active (GTK_SWITCH (widget), active1);
}
else if (GTK_IS_COMBO_BOX (widget))
{
gchar *id;
gboolean retval;
id = g_settings_get_string (settings, key);
retval = gtk_combo_box_set_active_id (GTK_COMBO_BOX (widget), id);
if (retval == FALSE && g_strcmp0 (key, "default-engine") == 0)
g_settings_set_string (settings, key, "nimf-system-keyboard");
g_free (id);
}
else if (GTK_IS_TREE_VIEW (widget))
{
GtkTreeModel *model;
gchar **vals;
GtkTreeIter iter;
gint i;
vals = g_settings_get_strv (settings, key);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
gtk_list_store_clear (GTK_LIST_STORE (model));
for (i = 0; vals[i] != NULL; i++)
{
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, vals[i], -1);
}
g_strfreev (vals);
}
}
示例10: change_ntp
static void
change_ntp (GObject *gobject,
GParamSpec *pspec,
CcDateTimePanel *self)
{
update_widget_state_for_ntp (self, gtk_switch_get_active (GTK_SWITCH (gobject)));
queue_set_ntp (self);
}
示例11: keybinds_conf_save
void keybinds_conf_save (void) {
int i;
int Mod1[HOTKEY_COUNT], Mod2[HOTKEY_COUNT] , Key[HOTKEY_COUNT];
char sMods[5][10] = { "" , "<CTRL>", "<SHIFT>", "<ALT>", "<WIN>" };
char ConfFilePath [512];
FILE *fpConfig = NULL;
#ifdef __linux__
sprintf(ConfFilePath ,"%s/keybinds.ini" ,DirConf);
#elif __WIN32
sprintf(ConfFilePath ,"%s\\keybinds.ini" ,DirConf);
#endif
fpConfig = fopen(ConfFilePath , "w");
if (fpConfig == NULL) {
log_error(true,"***Error: Couldn't write to config file 'keybinds.ini'");
return;
}
for ( i = 0 ; i < HOTKEY_COUNT ; ++i) {
Mod1[i] = gtk_combo_box_get_active(GTK_COMBO_BOX(com_kb_mod1[i]));
Mod2[i] = gtk_combo_box_get_active(GTK_COMBO_BOX(com_kb_mod2[i]));
Key[i] = gtk_combo_box_get_active(GTK_COMBO_BOX(com_kb_key[i]));
}
fprintf(fpConfig, "Hotkey_FUP = %s%s%c\n",
Mod1[0] != Mod2[0] ? sMods[Mod1[0]] : "" , sMods[Mod2[0]], Key[0]+33);
fprintf(fpConfig, "Hotkey_SS_A_UP = %s%s%c\n",
Mod1[1] != Mod2[1] ? sMods[Mod1[1]] : "" , sMods[Mod2[1]], Key[1]+33);
fprintf(fpConfig, "Hotkey_SS_W_UP = %s%s%c\n",
Mod1[2] != Mod2[2] ? sMods[Mod1[2]] : "" , sMods[Mod2[2]], Key[2]+33);
fprintf(fpConfig, "Hotkey_SS_F_UP = %s%s%c\n",
Mod1[3] != Mod2[3] ? sMods[Mod1[3]] : "" , sMods[Mod2[3]], Key[3]+33);
fprintf(fpConfig, "Hotkey_SS_A_CAP = %s%s%c\n",
Mod1[4] != Mod2[4] ? sMods[Mod1[4]] : "" , sMods[Mod2[4]], Key[4]+33);
fprintf(fpConfig, "Hotkey_SS_W_CAP = %s%s%c\n",
Mod1[5] != Mod2[5] ? sMods[Mod1[5]] : "" , sMods[Mod2[5]], Key[5]+33);
fprintf(fpConfig, "Hotkey_SS_F_CAP = %s%s%c\n",
Mod1[6] != Mod2[6] ? sMods[Mod1[6]] : "" , sMods[Mod2[6]], Key[6]+33);
fprintf(fpConfig, "Hotkey_OPEN = %s%s%c\n",
Mod1[7] != Mod2[7] ? sMods[Mod1[7]] : "" , sMods[Mod2[7]], Key[7]+33);
fprintf(fpConfig, "Enable_HK_FUP = %d\n", gtk_switch_get_active (GTK_SWITCH(sw_kb[0])));
fprintf(fpConfig, "Enable_HK_SS_A_UP = %d\n", gtk_switch_get_active (GTK_SWITCH(sw_kb[1])));
fprintf(fpConfig, "Enable_HK_SS_W_UP = %d\n", gtk_switch_get_active (GTK_SWITCH(sw_kb[2])));
fprintf(fpConfig, "Enable_HK_SS_F_UP = %d\n",gtk_switch_get_active (GTK_SWITCH(sw_kb[3])));
fprintf(fpConfig, "Enable_HK_SS_A_CAP = %d\n", gtk_switch_get_active (GTK_SWITCH(sw_kb[4])));
fprintf(fpConfig, "Enable_HK_SS_W_CAP = %d\n", gtk_switch_get_active (GTK_SWITCH(sw_kb[5])));
fprintf(fpConfig, "Enable_HK_SS_F_CAP = %d\n", gtk_switch_get_active (GTK_SWITCH(sw_kb[6])));
fprintf(fpConfig, "Enable_HK_OPEN = %d\n",gtk_switch_get_active (GTK_SWITCH(sw_kb[7])));
fclose(fpConfig);
keybinds_window_destroy();
keybinds_conf_load();
}
示例12: gtk_switch_motion
static gboolean
gtk_switch_motion (GtkWidget *widget,
GdkEventMotion *event)
{
GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv;
/* if this is a direct toggle we don't handle motion */
if (priv->in_press)
return GDK_EVENT_PROPAGATE;
if (ABS (event->x - priv->drag_start) < priv->drag_threshold)
return GDK_EVENT_STOP;
if (event->state & GDK_BUTTON1_MASK)
{
gint position = event->x - priv->offset;
GtkAllocation allocation;
GtkStyleContext *context;
GtkStateFlags state;
GtkBorder padding;
gint width, focus_width, focus_pad;
gtk_widget_style_get (widget,
"focus-line-width", &focus_width,
"focus-padding", &focus_pad,
NULL);
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
gtk_style_context_save (context);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER);
gtk_style_context_get_padding (context, state, &padding);
gtk_style_context_restore (context);
gtk_widget_get_allocation (widget, &allocation);
width = allocation.width - 2 * (focus_width + focus_pad);
/* constrain the handle within the trough width */
if (position > (width / 2) - padding.right)
priv->handle_x = width / 2 - padding.right;
else if (position < padding.left)
priv->handle_x = 0;
else
priv->handle_x = position;
priv->is_dragging = TRUE;
/* we need to redraw the handle */
gtk_widget_queue_draw (widget);
return GDK_EVENT_STOP;
}
return GDK_EVENT_PROPAGATE;
}
示例13: property_page_commit
static gboolean
property_page_commit (PropertyPage *page)
{
gboolean is_shared;
ShareInfo share_info;
ConfirmPermissionsStatus status;
GError *error;
gboolean retval;
is_shared = gtk_switch_get_active (GTK_SWITCH (page->switch_share_folder));
share_info.path = page->path;
share_info.share_name = (char *) gtk_entry_get_text (GTK_ENTRY (page->entry_share_name));
share_info.comment = (char *) gtk_entry_get_text (GTK_ENTRY (page->entry_share_comment));
share_info.is_writable = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (page->checkbutton_share_rw_ro));
share_info.guest_ok = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (page->checkbutton_share_guest_ok));
/* Do we need to unset the write permissions that we added in the past? */
if (is_shared && page->was_writable && !share_info.is_writable)
restore_write_permissions (page->path);
status = confirm_sharing_permissions (page->main, page->path, is_shared, share_info.guest_ok, share_info.is_writable);
if (status == CONFIRM_CANCEL_OR_ERROR)
return FALSE; /* the user didn't want us to change his folder's permissions */
error = NULL;
retval = shares_modify_share (share_info.path, is_shared ? &share_info : NULL, &error);
if (!retval)
{
property_page_set_error (page, error->message);
g_error_free (error);
/* Since the operation failed, we restore things to the way they were */
if (status == CONFIRM_MODIFIED)
restore_saved_permissions (page->path);
}
else
{
property_page_validate_fields (page);
nemo_file_info_invalidate_extension_info (page->fileinfo);
}
if (!is_shared)
restore_saved_permissions (page->path);
/* update initially shared state, so that we may undo later on */
if (retval)
{
page->was_initially_shared = is_shared;
page->is_dirty = FALSE;
}
return retval;
}
示例14: gtk_switch_leave
static gboolean
gtk_switch_leave (GtkWidget *widget,
GdkEventCrossing *event)
{
GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv;
if (event->window == priv->event_window)
priv->in_switch = FALSE;
return FALSE;
}
示例15: flashlight_set_active
/* flashlight_set_active */
void flashlight_set_active(Flashlight * flashlight, gboolean active)
{
flashlightbackend_set(active);
gtk_widget_set_sensitive(flashlight->image, active);
#if GTK_CHECK_VERSION(3, 0, 0)
gtk_switch_set_active(GTK_SWITCH(flashlight->co_toggle), active);
#else
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flashlight->co_toggle),
active);
#endif
}