void
nautilus_toolbar_set_active_slot (NautilusToolbar    *toolbar,
                                  NautilusWindowSlot *slot)
{
        g_return_if_fail (NAUTILUS_IS_TOOLBAR (toolbar));

        g_clear_pointer (&toolbar->priv->icon_binding, g_binding_unbind);
        g_clear_pointer (&toolbar->priv->view_widget_binding, g_binding_unbind);

        if (toolbar->priv->active_slot != slot) {
                toolbar->priv->active_slot = slot;

                if (slot) {
                        toolbar->priv->icon_binding =
                                        g_object_bind_property_full (slot, "icon",
                                                                     toolbar->priv->view_icon, "gicon",
                                                                     G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE,
                                                                     (GBindingTransformFunc) nautilus_toolbar_view_icon_transform_to,
                                                                     NULL,
                                                                     toolbar,
                                                                     NULL);
                        toolbar->priv->view_widget_binding =
                                        g_object_bind_property_full (slot, "view-widget",
                                                                     toolbar->priv->view_button, "popover",
                                                                     G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE,
                                                                     (GBindingTransformFunc) nautilus_toolbar_view_widget_transform_to,
                                                                     NULL,
                                                                     toolbar,
                                                                     NULL);
                }

        }
}
/**
 * nm_editor_bind_ip_gateway_to_string:
 * @family: the IP address family
 * @source: the source #NMSettingIPConfig
 * @target: the target object (eg, an #NmtIPEntry)
 * @target_property: the property on @target to bind (eg, "text")
 * @target_sensitive_property: the "sensitivity" property on @target to bind
 * @flags: %GBindingFlags
 *
 * Binds the #NMSettingIPConfig:gateway property on @source to the
 * %G_TYPE_STRING property @target_property and %G_TYPE_BOOLEAN property
 * @target_sensitive_property on @target, also taking the
 * #NMSettingIPConfig:addresses property on @source into account.
 *
 * In particular, if @source has no static IP addresses, then @target_property
 * will be set to "" and @target_sensitive_property will be set to %FALSE.
 *
 * If @source has at least one static IP address, then
 * @target_sensitive_property will be set to %TRUE, @target_property will be
 * initialized from @source's #NMSettingIPConfig:gateway, and @source will be
 * updated with the value of @target_property whenever it contains a valid IP
 * address.
 */
void
nm_editor_bind_ip_gateway_to_string (int                family,
                                     NMSettingIPConfig *source,
                                     gpointer           target,
                                     const gchar       *target_property,
                                     const gchar       *target_sensitive_property,
                                     GBindingFlags      flags)
{
	g_object_bind_property_full (source, "gateway",
	                             target, target_property,
	                             flags,
	                             ip_gateway_to_string,
	                             ip_gateway_from_string,
	                             GINT_TO_POINTER (family), NULL);
	g_object_bind_property_full (source, "addresses",
	                             source, "gateway",
	                             (flags & G_BINDING_SYNC_CREATE),
	                             ip_addresses_to_gateway,
	                             NULL,
	                             NULL, NULL);
	g_object_bind_property_full (source, "addresses",
	                             target, target_sensitive_property,
	                             (flags & G_BINDING_SYNC_CREATE),
	                             ip_addresses_to_sensitivity,
	                             NULL,
	                             NULL, NULL);
}
/**
 * nm_editor_bind_ip_route_to_strings:
 * @family: the IP address family
 * @source: the source object
 * @source_property: the source property
 * @dest_target: the target object for the route's destionation
 * @dest_target_property: the property on @dest_target
 * @next_hop_target: the target object for the route's next hop
 * @next_hop_target_property: the property on @next_hop_target
 * @metric_target: the target object for the route's metric
 * @metric_target_property: the property on @metric_target
 * @flags: %GBindingFlags
 *
 * Binds the #NMIPRoute-valued property @source_property on @source to the
 * three indicated string-valued target properties (and vice versa if
 * %G_BINDING_BIDIRECTIONAL is specified).
 *
 * @dest_target_property should be an "address/prefix" string, as with
 * nm_editor_bind_ip4_addresses_with_prefix_to_strv(). @next_hop_target_property
 * is a plain IP address, and @metric_target_property is a number.
 */
void
nm_editor_bind_ip_route_to_strings (int            family,
                                    gpointer       source,
                                    const gchar   *source_property,
                                    gpointer       dest_target,
                                    const gchar   *dest_target_property,
                                    gpointer       next_hop_target,
                                    const gchar   *next_hop_target_property,
                                    gpointer       metric_target,
                                    const gchar   *metric_target_property,
                                    GBindingFlags  flags)
{
	g_object_bind_property_full (source, source_property,
	                             dest_target, dest_target_property,
	                             flags,
	                             ip_route_transform_to_dest_string,
	                             ip_route_transform_from_dest_string,
	                             GINT_TO_POINTER (family), NULL);
	g_object_bind_property_full (source, source_property,
	                             next_hop_target, next_hop_target_property,
	                             flags,
	                             ip_route_transform_to_next_hop_string,
	                             ip_route_transform_from_next_hop_string,
	                             GINT_TO_POINTER (family), NULL);
	g_object_bind_property_full (source, source_property,
	                             metric_target, metric_target_property,
	                             flags,
	                             ip_route_transform_to_metric_string,
	                             ip_route_transform_from_metric_string,
	                             GINT_TO_POINTER (family), NULL);
}
GtkWidget *
gimp_clone_options_gui (GimpToolOptions *tool_options)
{
  GObject   *config = G_OBJECT (tool_options);
  GtkWidget *vbox   = gimp_paint_options_gui (tool_options);
  GtkWidget *frame;
  GtkWidget *combo;
  GtkWidget *source_vbox;
  GtkWidget *button;
  GtkWidget *hbox;

  /*  the source frame  */
  frame = gimp_frame_new (NULL);
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  /*  the source type menu  */
  combo = gimp_prop_enum_combo_box_new (config, "clone-type", 0, 0);
  gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Source"));
  g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
  gtk_frame_set_label_widget (GTK_FRAME (frame), combo);
  gtk_widget_show (combo);

  source_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  gtk_container_add (GTK_CONTAINER (frame), source_vbox);
  gtk_widget_show (source_vbox);

  button = gimp_prop_check_button_new (config, "sample-merged", NULL);
  gtk_box_pack_start (GTK_BOX (source_vbox), button, FALSE, FALSE, 0);

  g_object_bind_property_full (config, "clone-type",
                               button, "visible",
                               G_BINDING_SYNC_CREATE,
                               gimp_clone_options_sync_source,
                               NULL,
                               GINT_TO_POINTER (GIMP_CLONE_IMAGE), NULL);

  hbox = gimp_prop_pattern_box_new (NULL, GIMP_CONTEXT (tool_options),
                                    NULL, 2,
                                    "pattern-view-type", "pattern-view-size");
  gtk_box_pack_start (GTK_BOX (source_vbox), hbox, FALSE, FALSE, 0);

  g_object_bind_property_full (config, "clone-type",
                               hbox,   "visible",
                               G_BINDING_SYNC_CREATE,
                               gimp_clone_options_sync_source,
                               NULL,
                               GINT_TO_POINTER (GIMP_CLONE_PATTERN), NULL);

  combo = gimp_prop_enum_combo_box_new (config, "align-mode", 0, 0);
  gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Alignment"));
  g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
  gtk_box_pack_start (GTK_BOX (vbox), combo, TRUE, TRUE, 0);
  gtk_widget_show (combo);

  return vbox;
}
Esempio n. 5
0
GstElement * _owr_payload_create_encoder(OwrPayload *payload)
{
    GstElement *encoder = NULL;
    gchar *element_name = NULL;
    GstElementFactory *factory;
    const gchar *factory_name;

    g_return_val_if_fail(payload, NULL);

    switch (payload->priv->codec_type) {
    case OWR_CODEC_TYPE_H264:
        encoder = try_codecs(h264_encoders, "encoder");
        g_return_val_if_fail(encoder, NULL);

        factory = gst_element_get_factory(encoder);
        factory_name = gst_plugin_feature_get_name(factory);

        if (!strcmp(factory_name, "openh264enc")) {
            g_object_set(encoder, "gop-size", 0, NULL);
            gst_util_set_object_arg(G_OBJECT(encoder), "rate-control", "bitrate");
            g_object_bind_property(payload, "bitrate", encoder, "bitrate", G_BINDING_SYNC_CREATE);
        } else if (!strcmp(factory_name, "x264enc")) {
            g_object_bind_property_full(payload, "bitrate", encoder, "bitrate", G_BINDING_SYNC_CREATE,
                binding_transform_to_kbps, NULL, NULL, NULL);
            g_object_set(encoder, "tune", 0x04 /* zero-latency */, NULL);
        } else if (!strcmp(factory_name, "vtenc_h264")) {
            g_object_bind_property_full(payload, "bitrate", encoder, "bitrate", G_BINDING_SYNC_CREATE,
                binding_transform_to_kbps, NULL, NULL, NULL);
        } else {
            /* Assume bits/s instead of kbit/s */
            g_object_bind_property(payload, "bitrate", encoder, "bitrate", G_BINDING_SYNC_CREATE);
        }
        g_object_set(payload, "bitrate", evaluate_bitrate_from_payload(payload), NULL);
        break;

    case OWR_CODEC_TYPE_VP8:
        encoder = try_codecs(vp8_encoders, "encoder");
        g_return_val_if_fail(encoder, NULL);
        g_object_set(encoder, "end-usage", 1, "deadline", G_GINT64_CONSTANT(1), "lag-in-frames", 0,
            "error-resilient", 1, "keyframe-mode", 0, NULL);
        g_object_bind_property(payload, "bitrate", encoder, "target-bitrate", G_BINDING_SYNC_CREATE);
        g_object_set(payload, "bitrate", evaluate_bitrate_from_payload(payload), NULL);
        break;
    default:
        element_name = g_strdup_printf("encoder_%s_%u", OwrCodecTypeEncoderElementName[payload->priv->codec_type], get_unique_id());
        encoder = gst_element_factory_make(OwrCodecTypeEncoderElementName[payload->priv->codec_type], element_name);
        g_free(element_name);
        g_return_val_if_fail(encoder, NULL);
        break;
    }

    return encoder;
}
Esempio n. 6
0
static void
nmt_mtu_entry_init (NmtMtuEntry *entry)
{

	NmtMtuEntryPrivate *priv = NMT_MTU_ENTRY_GET_PRIVATE (entry);
	NmtNewtGrid *grid = NMT_NEWT_GRID (entry);
	NmtNewtWidget *real_entry, *label;

	real_entry = nmt_newt_entry_numeric_new (10, 0, 65535);
	priv->entry = NMT_NEWT_ENTRY (real_entry);

	label = nmt_newt_label_new (_("bytes"));
	priv->label = NMT_NEWT_LABEL (label);

	nmt_newt_grid_add (grid, real_entry, 0, 0);
	nmt_newt_grid_add (grid, label, 1, 0);
	nmt_newt_widget_set_padding (label, 1, 0, 0, 0);

	nmt_newt_entry_set_validator (priv->entry, mtu_validator, entry);
	g_object_bind_property_full (entry, "mtu", real_entry, "text",
	                             G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE,
	                             mtu_transform_to_text,
	                             NULL,
	                             NULL, NULL);
}
Esempio n. 7
0
static GtkWidget *
make_switch (gboolean is_on,
             gboolean is_sensitive)
{
  GtkWidget *hbox;
  GtkWidget *sw, *label;

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);

  sw = gtk_switch_new ();
  gtk_switch_set_active (GTK_SWITCH (sw), is_on);
  gtk_box_pack_start (GTK_BOX (hbox), sw, FALSE, FALSE, 0);
  gtk_widget_set_sensitive (sw, is_sensitive);
  gtk_widget_show (sw);

  label = gtk_label_new (is_on ? "Enabled" : "Disabled");
  gtk_box_pack_end (GTK_BOX (hbox), label, TRUE, TRUE, 0);
  gtk_widget_show (label);

  g_object_bind_property_full (sw, "active",
                               label, "label",
                               G_BINDING_DEFAULT,
                               boolean_to_text,
                               NULL,
                               NULL, NULL);

  return hbox;
}
Esempio n. 8
0
static void
sysroot_constructed (GObject *object)
{
  RpmostreedSysroot *self = RPMOSTREED_SYSROOT (object);
  GError *local_error = NULL;

  /* TODO Integrate with PolicyKit via the "g-authorize-method" signal. */

  g_object_bind_property_full (self->transaction_monitor,
                               "active-transaction",
                               self,
                               "active-transaction",
                               G_BINDING_DEFAULT |
                               G_BINDING_SYNC_CREATE,
                               sysroot_transform_transaction_to_attrs,
                               NULL,
                               NULL,
                               NULL);

  /* Failure is not fatal, but the client may miss some messages. */
  if (!sysroot_setup_stdout_redirect (self, &local_error))
    {
      g_critical ("%s", local_error->message);
      g_clear_error (&local_error);
    }

  G_OBJECT_CLASS (rpmostreed_sysroot_parent_class)->constructed (object);
}
static void
constructed(GObject* obj)
{
    GtChannelsContainerChild* self = GT_CHANNELS_CONTAINER_CHILD(obj);
    GtChannelsContainerChildPrivate* priv = gt_channels_container_child_get_instance_private(self);

    g_object_bind_property(priv->channel, "display-name",
                           priv->name_label, "label",
                           G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
    g_object_bind_property(priv->channel, "game",
                           priv->game_label, "label",
                           G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
    g_object_bind_property(priv->channel, "favourited",
                           priv->favourite_button, "active",
                           G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
    g_object_bind_property(priv->channel, "preview",
                           priv->preview_image, "pixbuf",
                           G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
    g_object_bind_property(priv->channel, "online",
                           priv->viewers_label, "visible",
                           G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
    g_object_bind_property(priv->channel, "online",
                           priv->play_image, "visible",
                           G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
    g_object_bind_property(priv->channel, "online",
                           priv->bottom_box, "visible",
                           G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
    g_object_bind_property_full(priv->channel, "viewers",
                                priv->viewers_label, "label",
                                G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE,
                                (GBindingTransformFunc) viewers_converter,
                                NULL, NULL, NULL);
    g_object_bind_property_full(priv->channel, "stream-started-time",
                                priv->time_label, "label",
                                G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE,
                                (GBindingTransformFunc) time_converter,
                                NULL, NULL, NULL);
    g_object_bind_property_full(priv->channel, "updating",
                                priv->middle_stack, "visible-child-name",
                                G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE,
                                (GBindingTransformFunc) updating_converter,
                                NULL, NULL, NULL);

    g_signal_connect(priv->channel, "notify::online", G_CALLBACK(online_cb), self);

    G_OBJECT_CLASS(gt_channels_container_child_parent_class)->constructed(obj);
}
Esempio n. 10
0
void
ide_workbench_set_context (IdeWorkbench *self,
                           IdeContext   *context)
{
  g_autoptr(GSettings) settings = NULL;
  IdeProject *project;
  guint duration;

  g_return_if_fail (IDE_IS_WORKBENCH (self));
  g_return_if_fail (IDE_IS_CONTEXT (context));
  g_return_if_fail (self->context == NULL);

  settings = g_settings_new ("org.gnome.builder");

  g_set_object (&self->context, context);

  project = ide_context_get_project (context);
  g_object_bind_property_full (project, "name",
                               self, "title",
                               G_BINDING_SYNC_CREATE,
                               transform_title, NULL, NULL, NULL);

  self->addins = peas_extension_set_new (peas_engine_get_default (),
                                         IDE_TYPE_WORKBENCH_ADDIN,
                                         NULL);

  g_signal_connect (self->addins,
                    "extension-added",
                    G_CALLBACK (ide_workbench_addin_added),
                    self);

  g_signal_connect (self->addins,
                    "extension-removed",
                    G_CALLBACK (ide_workbench_addin_removed),
                    self);

  peas_extension_set_foreach (self->addins, ide_workbench_addin_added, self);

  /*
   * Creating all the addins above is a bit intenstive, so give ourselves
   * just a bit of time to stablize allocations and sizing before
   * transitioning to the editor.
   */
  g_timeout_add (STABLIZE_DELAY_MSEC, stablize_cb, g_object_ref (self));

  /*
   * When restoring, previous buffers may get loaded. This causes new
   * widgets to be created and added to the workspace. Doing so during
   * the stack transition results in non-smooth transitions. So instead,
   * we will delay until the transition has completed.
   */
  if (g_settings_get_boolean (settings, "restore-previous-files"))
    {
      duration = gtk_stack_get_transition_duration (self->top_stack);
      g_timeout_add (STABLIZE_DELAY_MSEC + duration, restore_in_timeout, g_object_ref (context));
    }
}
static void
cc_sharing_panel_bind_switch_to_label (CcSharingPanel *self,
                                       GtkWidget      *gtkswitch,
                                       GtkWidget      *label)
{
  g_object_bind_property_full (gtkswitch, "active", label, "label",
                               G_BINDING_SYNC_CREATE,
                               (GBindingTransformFunc) cc_sharing_panel_switch_to_label_transform_func,
                               NULL, self, NULL);
}
static void
cc_sharing_panel_bind_networks_to_label (CcSharingPanel *self,
					 GtkWidget      *networks,
					 GtkWidget      *label)
{
  g_object_bind_property_full (networks, "status", label, "label",
                               G_BINDING_SYNC_CREATE,
                               (GBindingTransformFunc) cc_sharing_panel_networks_to_label_transform_func,
                               NULL, self, NULL);
}
/*
 * Called when a reference to the system bus is acquired. This is where you are
 * supposed to export your well-known name, not in name_acquired; that is too
 * late.
 */
static void
on_bus_acquired (GDBusConnection *system_bus,
                 const gchar     *name,
                 gpointer         user_data)
{
  EmerDaemon *daemon = EMER_DAEMON (user_data);
  EmerEventRecorderServer *server = emer_event_recorder_server_skeleton_new ();

  g_signal_connect (server, "handle-record-singular-event",
                    G_CALLBACK (on_record_singular_event), daemon);
  g_signal_connect (server, "handle-record-aggregate-event",
                    G_CALLBACK (on_record_aggregate_event), daemon);
  g_signal_connect (server, "handle-record-event-sequence",
                    G_CALLBACK (on_record_event_sequence), daemon);
  g_signal_connect (server, "handle-set-enabled",
                    G_CALLBACK (on_set_enabled), daemon);
  g_signal_connect (server, "handle-upload-events",
                    G_CALLBACK (on_upload_events), daemon);
  g_signal_connect (server, "handle-reset-tracking-id",
                    G_CALLBACK (on_reset_tracking_id), daemon);
  g_signal_connect (server, "g-authorize-method",
                    G_CALLBACK (on_authorize_method_check), daemon);

  EmerPermissionsProvider *permissions =
    emer_daemon_get_permissions_provider (daemon);
  g_object_bind_property_full (permissions, "daemon-enabled", server, "enabled",
                               G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE,
                               sync_recorder_server_enabled_for_daemon, NULL,
                               daemon, NULL);
  g_object_bind_property_full (permissions, "uploading-enabled", server, "enabled",
                               G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE,
                               sync_recorder_server_enabled_for_upload, NULL,
                               daemon, NULL);

  GError *error = NULL;
  if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (server),
                                         system_bus,
                                         "/com/endlessm/Metrics",
                                         &error))
    g_error ("Could not export metrics interface on system bus: %s.",
             error->message);
}
static void
bind_switch_to_row (CcDateTimePanel *self,
                    GtkWidget       *gtkswitch,
                    GtkWidget       *listrow)
{
  g_object_bind_property_full (gtkswitch, "active",
                               listrow, "sensitive",
                               G_BINDING_SYNC_CREATE,
                               (GBindingTransformFunc) switch_to_row_transform_func,
                               NULL, self, NULL);
}
Esempio n. 15
0
/*
 *  Main function
 */
static GtkWidget * dmm_init(struct osc_plugin *plugin, GtkWidget *notebook, const char *ini_fn)
{
	GtkBuilder *builder;
	GtkWidget *dmm_panel;

	builder = gtk_builder_new();
	nbook = GTK_NOTEBOOK(notebook);

	ctx = osc_create_context();
	if (!ctx)
		return NULL;

	if (osc_load_glade_file(builder, "dmm") < 0)
		return NULL;

	dmm_panel = GTK_WIDGET(gtk_builder_get_object(builder, "dmm_panel"));
	device_list_widget = GTK_WIDGET(gtk_builder_get_object(builder, "device_list_view"));
	device_list_store = GTK_LIST_STORE(gtk_builder_get_object(builder, "device_list"));

	dmm_button = GTK_WIDGET(gtk_builder_get_object(builder, "dmm_button"));
	channel_list_store = GTK_LIST_STORE(gtk_builder_get_object(builder, "channel_list"));

	dmm_results = GTK_WIDGET(gtk_builder_get_object(builder, "dmm_results"));
	select_all_channels = GTK_WIDGET(gtk_builder_get_object(builder, "all_channels"));

	g_builder_connect_signal(builder, "device_toggle", "toggled",
			G_CALLBACK(device_toggled), device_list_store);
	g_builder_connect_signal(builder, "channel_toggle", "toggled",
			G_CALLBACK(channel_toggle), channel_list_store);
	g_builder_connect_signal(builder, "all_channels", "clicked",
			G_CALLBACK(pick_all_channels), channel_list_store);

	g_builder_connect_signal(builder, "dmm_button", "toggled",
			G_CALLBACK(dmm_button_clicked), channel_list_store);

	g_builder_bind_property(builder, "dmm_button", "active",
			"channel_list_view", "sensitive", G_BINDING_INVERT_BOOLEAN);
	g_builder_bind_property(builder, "dmm_button", "active",
			"device_list_view", "sensitive", G_BINDING_INVERT_BOOLEAN);

	g_object_bind_property_full(dmm_button, "active", dmm_button,
			"stock-id", 0, dmm_button_icon_transform, NULL, NULL, NULL);

	gtk_widget_show_all(dmm_panel);
	gtk_widget_hide(select_all_channels);

	init_device_list();

	/* we are looking for almost random numbers, so this will work */
	srand((unsigned int)time(NULL));

	return dmm_panel;
}
Esempio n. 16
0
static void
gb_editor_view_set_document (GbEditorView     *self,
                             GbEditorDocument *document)
{
  g_return_if_fail (GB_IS_EDITOR_VIEW (self));
  g_return_if_fail (GB_IS_EDITOR_DOCUMENT (document));

  if (g_set_object (&self->document, document))
    {
      if (self->frame1)
        gb_editor_frame_set_document (self->frame1, document);

      if (self->frame2)
        gb_editor_frame_set_document (self->frame2, document);

      g_settings_bind (self->settings, "style-scheme-name",
                       document, "style-scheme-name",
                       G_SETTINGS_BIND_GET);
      g_settings_bind (self->settings, "highlight-matching-brackets",
                       document, "highlight-matching-brackets",
                       G_SETTINGS_BIND_GET);

      g_object_bind_property_full (document, "language", self->tweak_button,
                                   "label", G_BINDING_SYNC_CREATE,
                                   language_to_string, NULL, NULL, NULL);

      g_signal_connect_object (document,
                               "modified-changed",
                               G_CALLBACK (gb_editor_view__buffer_modified_changed),
                               self,
                               G_CONNECT_SWAPPED);

      g_signal_connect_object (document,
                               "notify::title",
                               G_CALLBACK (gb_editor_view__buffer_notify_title),
                               self,
                               G_CONNECT_SWAPPED);

      g_signal_connect_object (document,
                               "notify::changed-on-volume",
                               G_CALLBACK (gb_editor_view__buffer_changed_on_volume),
                               self,
                               G_CONNECT_SWAPPED);

      g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_DOCUMENT]);

      gb_editor_view_actions_update (self);
    }
}
Esempio n. 17
0
static NmtNewtWidget *
create_warning_label (NmtNewtWidget *entry)
{
	NmtNewtWidget *label;

	label = g_object_new (NMT_TYPE_NEWT_LABEL,
	                      "highlight", TRUE,
	                      NULL);
	g_object_bind_property_full (entry, "valid",
	                             label, "text",
	                             G_BINDING_SYNC_CREATE,
	                             entry_validity_transform_to_warning_label,
	                             NULL, NULL, NULL);
	return label;
}
/**
 * nm_editor_bind_ip_addresses_to_strv:
 * @family: the IP address family
 * @source: the source object (eg, an #NMSettingIP4Config)
 * @source_property: the property on @source to bind (eg,
 *   %NM_SETTING_IP4_CONFIG_DNS)
 * @target: the target object (eg, an #NmtAddressList)
 * @target_property: the property on @target to bind
 *   (eg, "strings")
 * @flags: %GBindingFlags
 *
 * Binds the %G_TYPE_STRV property @source_property on @source to the
 * %G_TYPE_STRV property @target_property on @target, verifying that
 * each string is a valid address of type @family when copying.
 */
void
nm_editor_bind_ip_addresses_to_strv (int            family,
                                     gpointer       source,
                                     const gchar   *source_property,
                                     gpointer       target,
                                     const gchar   *target_property,
                                     GBindingFlags  flags)
{
	g_object_bind_property_full (source, source_property,
	                             target, target_property,
	                             flags,
	                             ip_addresses_check_and_copy,
	                             ip_addresses_check_and_copy,
	                             GINT_TO_POINTER (family), NULL);
}
Esempio n. 19
0
static void
ide_source_map__view_changed (IdeSourceMap *self,
                              GParamSpec   *psepct,
                              gpointer      data)
{
  GtkSourceView *view;

  g_return_if_fail (IDE_IS_SOURCE_MAP (self));

  view = gtk_source_map_get_view (GTK_SOURCE_MAP (self));

  g_object_bind_property_full (view, "font-desc", self, "font-desc", G_BINDING_SYNC_CREATE,
                               shrink_font, NULL, NULL, NULL);

  dzl_signal_group_set_target (self->view_signals, view);
}
Esempio n. 20
0
/**
 * g_object_bind_property:
 * @source: (type GObject.Object): the source #GObject
 * @source_property: the property on @source to bind
 * @target: (type GObject.Object): the target #GObject
 * @target_property: the property on @target to bind
 * @flags: flags to pass to #GBinding
 *
 * Creates a binding between @source_property on @source and @target_property
 * on @target. Whenever the @source_property is changed the @target_property is
 * updated using the same value. For instance:
 *
 * |[
 *   g_object_bind_property (action, "active", widget, "sensitive", 0);
 * ]|
 *
 * Will result in the "sensitive" property of the widget #GObject instance to be
 * updated with the same value of the "active" property of the action #GObject
 * instance.
 *
 * If @flags contains %G_BINDING_BIDIRECTIONAL then the binding will be mutual:
 * if @target_property on @target changes then the @source_property on @source
 * will be updated as well.
 *
 * The binding will automatically be removed when either the @source or the
 * @target instances are finalized. To remove the binding without affecting the
 * @source and the @target you can just call g_object_unref() on the returned
 * #GBinding instance.
 *
 * A #GObject can have multiple bindings.
 *
 * Return value: (transfer none): the #GBinding instance representing the
 *   binding between the two #GObject instances. The binding is released
 *   whenever the #GBinding reference count reaches zero.
 *
 * Since: 2.26
 */
GBinding *
g_object_bind_property (gpointer       source,
                        const gchar   *source_property,
                        gpointer       target,
                        const gchar   *target_property,
                        GBindingFlags  flags)
{
  /* type checking is done in g_object_bind_property_full() */

  return g_object_bind_property_full (source, source_property,
                                      target, target_property,
                                      flags,
                                      NULL,
                                      NULL,
                                      NULL, NULL);
}
Esempio n. 21
0
static GtkWidget *
make_delayed_switch (gboolean is_on,
                     gboolean is_sensitive)
{
  GtkWidget *hbox;
  GtkWidget *sw, *label, *spinner, *check;

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);

  sw = gtk_switch_new ();
  gtk_switch_set_active (GTK_SWITCH (sw), is_on);
  gtk_box_pack_start (GTK_BOX (hbox), sw, FALSE, FALSE, 0);
  gtk_widget_set_sensitive (sw, is_sensitive);
  gtk_widget_show (sw);

  g_signal_connect (sw, "state-set", G_CALLBACK (set_state), NULL);

  spinner = gtk_spinner_new ();
  gtk_box_pack_start (GTK_BOX (hbox), spinner, FALSE, TRUE, 0);
  gtk_widget_set_opacity (spinner, 0.0);
  gtk_widget_show (spinner);
  
  check = gtk_check_button_new ();
  gtk_box_pack_end (GTK_BOX (hbox), check, FALSE, TRUE, 0);
  gtk_widget_show (check);
  g_object_bind_property (sw, "state",
                          check, "active",
                          G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);

  label = gtk_label_new (is_on ? "Enabled" : "Disabled");
  gtk_box_pack_end (GTK_BOX (hbox), label, TRUE, TRUE, 0);
  gtk_widget_show (label);

  g_object_bind_property_full (sw, "active",
                               label, "label",
                               G_BINDING_DEFAULT,
                               boolean_to_text,
                               NULL,
                               NULL, NULL);

  g_signal_connect (sw, "notify", G_CALLBACK (sw_delay_notify), spinner);

  return hbox;
}
static void
mail_config_format_html_constructed (GObject *object)
{
    EExtension *extension;
    EExtensible *extensible;
    EShellSettings *shell_settings;
    EShell *shell;

    extension = E_EXTENSION (object);
    extensible = e_extension_get_extensible (extension);

    shell = e_shell_get_default ();
    shell_settings = e_shell_get_shell_settings (shell);

    g_object_bind_property_full (
        shell_settings, "mail-citation-color",
        extensible, "citation-color",
        G_BINDING_SYNC_CREATE,
        e_binding_transform_string_to_color,
        NULL, NULL, (GDestroyNotify) NULL);

    g_object_bind_property (
        shell_settings, "mail-image-loading-policy",
        extensible, "image-loading-policy",
        G_BINDING_SYNC_CREATE);

    g_object_bind_property (
        shell_settings, "mail-only-local-photos",
        extensible, "only-local-photos",
        G_BINDING_SYNC_CREATE);

    g_object_bind_property (
        shell_settings, "mail-show-sender-photo",
        extensible, "show-sender-photo",
        G_BINDING_SYNC_CREATE);

    g_object_bind_property (
        shell_settings, "mail-show-real-date",
        extensible, "show-real-date",
        G_BINDING_SYNC_CREATE);

    /* Chain up to parent's constructed() method. */
    G_OBJECT_CLASS (parent_class)->constructed (object);
}
Esempio n. 23
0
static NmtNewtWidget *
create_route_entry (NmtWidgetList *list,
                    int            num,
                    gpointer       table)
{
	NmtRouteTablePrivate *priv = NMT_ROUTE_TABLE_GET_PRIVATE (table);
	NmtNewtWidget *entry;

	entry = nmt_route_entry_new (priv->family,
	                             priv->ip_entry_width,
	                             priv->metric_entry_width);

	g_object_bind_property_full (table, "routes",
	                             entry, "route",
	                             G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE,
	                             route_list_transform_to_route,
	                             route_list_transform_from_route,
	                             GINT_TO_POINTER (num), NULL);
	return entry;
}
Esempio n. 24
0
/**
 * camel_binding_bind_property_full:
 * @source: (type GObject.Object): the source #GObject
 * @source_property: the property on @source to bind
 * @target: (type GObject.Object): the target #GObject
 * @target_property: the property on @target to bind
 * @flags: flags to pass to #GBinding
 * @transform_to: (scope notified) (allow-none): the transformation function
 *   from the @source to the @target, or %NULL to use the default
 * @transform_from: (scope notified) (allow-none): the transformation function
 *   from the @target to the @source, or %NULL to use the default
 * @user_data: custom data to be passed to the transformation functions,
 *   or %NULL
 * @notify: function to be called when disposing the binding, to free the
 *   resources used by the transformation functions
 *
 * Thread safe variant of g_object_bind_property_full(). See its documentation
 * for more information on arguments and return value.
 *
 * Return value: (transfer none): the #GBinding instance representing the
 *   binding between the two #GObject instances. The binding is released
 *   whenever the #GBinding reference count reaches zero.
 *
 * Since: 3.16
 **/
GBinding *
camel_binding_bind_property_full (gpointer source,
				  const gchar *source_property,
				  gpointer target,
				  const gchar *target_property,
				  GBindingFlags flags,
				  GBindingTransformFunc transform_to,
				  GBindingTransformFunc transform_from,
				  gpointer user_data,
				  GDestroyNotify notify)
{
	GBinding *binding;

	g_rec_mutex_lock (&camel_binding_lock);

	binding = g_object_bind_property_full (source, source_property, target, target_property, flags,
		transform_to, transform_from, user_data, notify);

	g_rec_mutex_unlock (&camel_binding_lock);

	return binding;
}
Esempio n. 25
0
/**
 * g_object_bind_property_with_closures:
 * @source: (type GObject.Object): the source #GObject
 * @source_property: the property on @source to bind
 * @target: (type GObject.Object): the target #GObject
 * @target_property: the property on @target to bind
 * @flags: flags to pass to #GBinding
 * @transform_to: a #GClosure wrapping the transformation function
 *   from the @source to the @target, or %NULL to use the default
 * @transform_from: a #GClosure wrapping the transformation function
 *   from the @target to the @source, or %NULL to use the default
 *
 * Creates a binding between @source_property on @source and @target_property
 * on @target, allowing you to set the transformation functions to be used by
 * the binding.
 *
 * This function is the language bindings friendly version of
 * g_object_bind_property_full(), using #GClosure<!-- -->s instead of
 * function pointers.
 *
 * Rename to: g_object_bind_property_full
 *
 * Return value: (transfer none): the #GBinding instance representing the
 *   binding between the two #GObject instances. The binding is released
 *   whenever the #GBinding reference count reaches zero.
 *
 * Since: 2.26
 */
GBinding *
g_object_bind_property_with_closures (gpointer       source,
                                      const gchar   *source_property,
                                      gpointer       target,
                                      const gchar   *target_property,
                                      GBindingFlags  flags,
                                      GClosure      *transform_to,
                                      GClosure      *transform_from)
{
  TransformData *data;

  data = g_slice_new0 (TransformData);

  if (transform_to != NULL)
    {
      if (G_CLOSURE_NEEDS_MARSHAL (transform_to))
        g_closure_set_marshal (transform_to, g_cclosure_marshal_BOOLEAN__BOXED_BOXED);

      data->transform_to_closure = g_closure_ref (transform_to);
      g_closure_sink (data->transform_to_closure);
    }

  if (transform_from != NULL)
    {
      if (G_CLOSURE_NEEDS_MARSHAL (transform_from))
        g_closure_set_marshal (transform_from, g_cclosure_marshal_BOOLEAN__BOXED_BOXED);

      data->transform_from_closure = g_closure_ref (transform_from);
      g_closure_sink (data->transform_from_closure);
    }

  return g_object_bind_property_full (source, source_property,
                                      target, target_property,
                                      flags,
                                      transform_to != NULL ? bind_with_closures_transform_to : NULL,
                                      transform_from != NULL ? bind_with_closures_transform_from : NULL,
                                      data,
                                      bind_with_closures_free_func);
}
Esempio n. 26
0
/**
 * ppg_instrument_view_visualizer_added:
 * @view: (in): A #PpgInstrumentView.
 *
 * Handle the "visualizer-added" event for the #PpgInstrument. Add the
 * visualizer to our table of visualizers.
 *
 * Returns: None.
 * Side effects: None.
 */
static void
ppg_instrument_view_visualizer_added (PpgInstrumentView *view,
                                      PpgVisualizer     *visualizer,
                                      PpgInstrument     *instrument)
{
    PpgInstrumentViewPrivate *priv;
    GooCanvasItem *item = (GooCanvasItem *)visualizer;
    gdouble width;

    g_return_if_fail(PPG_IS_INSTRUMENT_VIEW(view));
    g_return_if_fail(PPG_IS_VISUALIZER(visualizer));
    g_return_if_fail(PPG_IS_INSTRUMENT(instrument));

    priv = view->priv;

    g_object_get(view, "width", &width, NULL);
    width = MAX(200.0, width - HEADER_WIDTH);
    g_object_set(item,
                 "parent", priv->table,
                 "width", width,
                 "visibility", GOO_CANVAS_ITEM_VISIBLE,
                 NULL);
    g_object_bind_property_full(view, "width", item, "width", 0,
                                ppg_instrument_view_transform_width,
                                NULL, NULL, NULL);
    goo_canvas_item_set_child_properties(priv->table, item,
                                         "bottom-padding", ROW_SPACING,
                                         "column", 0,
                                         "row", priv->visualizers->len,
                                         NULL);
    g_ptr_array_add(priv->visualizers, visualizer);
    g_signal_connect_swapped(visualizer, "notify::natural-height",
                             G_CALLBACK(ppg_instrument_view_notify_natural_height),
                             view);
    ppg_instrument_view_relayout(view);
}
Esempio n. 27
0
void
ide_workbench_set_context (IdeWorkbench *self,
                           IdeContext   *context)
{
  g_autoptr(GSettings) settings = NULL;
  IdeBuildManager *build_manager;
  IdeRunManager *run_manager;
  IdeProject *project;
  guint delay_msec;

  IDE_ENTRY;

  g_return_if_fail (IDE_IS_WORKBENCH (self));
  g_return_if_fail (IDE_IS_CONTEXT (context));
  g_return_if_fail (self->context == NULL);

  settings = g_settings_new ("org.gnome.builder");

  g_set_object (&self->context, context);

  project = ide_context_get_project (context);
  g_object_bind_property_full (project, "name",
                               self, "title",
                               G_BINDING_SYNC_CREATE,
                               transform_title, NULL, NULL, NULL);

  build_manager = ide_context_get_build_manager (context);
  gtk_widget_insert_action_group (GTK_WIDGET (self),
                                  "build-manager",
                                  G_ACTION_GROUP (build_manager));

  run_manager = ide_context_get_run_manager (context);
  gtk_widget_insert_action_group (GTK_WIDGET (self),
                                  "run-manager",
                                  G_ACTION_GROUP (run_manager));

  self->addins = peas_extension_set_new (peas_engine_get_default (),
                                         IDE_TYPE_WORKBENCH_ADDIN,
                                         NULL);

  g_signal_connect (self->addins,
                    "extension-added",
                    G_CALLBACK (ide_workbench_addin_added),
                    self);

  g_signal_connect (self->addins,
                    "extension-removed",
                    G_CALLBACK (ide_workbench_addin_removed),
                    self);

  peas_extension_set_foreach (self->addins, ide_workbench_addin_added, self);

  g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_CONTEXT]);

  /*
   * Creating all the addins above is a bit intensive, so give ourselves
   * just a bit of time to stablize allocations and sizing before
   * transitioning to the editor.
   */
  delay_msec = self->disable_greeter ? 0 : STABLIZE_DELAY_MSEC;
  g_timeout_add (delay_msec, stablize_cb, g_object_ref (self));

  /*
   * When restoring, previous buffers may get loaded. This causes new
   * widgets to be created and added to the workspace. Doing so during
   * the stack transition results in non-smooth transitions. So instead,
   * we will delay until the transition has completed.
   */
  if (g_settings_get_boolean (settings, "restore-previous-files"))
    {
      guint duration = 0;

      if (!self->disable_greeter)
        duration = gtk_stack_get_transition_duration (self->perspectives_stack);
      g_timeout_add (delay_msec + duration, restore_in_timeout, g_object_ref (context));
    }

  IDE_EXIT;
}
Esempio n. 28
0
static ClutterActor *
create_property_editor (GObject    *object,
                        GParamSpec *pspec)
{
  ClutterActor *box, *label, *value;
  gint i;

  /* skip properties that are not writable */
  if (!(pspec->flags & G_PARAM_WRITABLE))
    return NULL;

  /* skip other properties */
  for (i = 0; i < G_N_ELEMENTS (skip_properties); i++)
    {
      if (g_str_equal (pspec->name, skip_properties[i]))
        return NULL;
    }


  box = mx_box_layout_new ();

  label = mx_label_new_with_text (pspec->name);
  clutter_actor_set_width (label, 150);
  clutter_actor_add_child (box, label);

  if (pspec->value_type == G_TYPE_BOOLEAN)
    {
      value = mx_toggle_new ();

      g_object_bind_property (object, pspec->name, value, "active",
                              G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
    }
  else if (pspec->value_type == G_TYPE_STRING)
    {
      value = mx_entry_new ();

      g_object_bind_property (object, pspec->name, value, "text",
                              G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
    }
  else if (pspec->value_type == G_TYPE_INT || pspec->value_type == G_TYPE_UINT
           || pspec->value_type == G_TYPE_FLOAT
           || pspec->value_type == G_TYPE_DOUBLE)
    {
      value = mx_entry_new ();

      g_object_bind_property_full (object, pspec->name, value, "text",
                                   G_BINDING_BIDIRECTIONAL
                                   | G_BINDING_SYNC_CREATE,
                                   num_to_string,
                                   string_to_num,
                                   NULL, NULL);
    }
  else if (g_type_is_a (pspec->value_type, G_TYPE_ENUM))
    {
      GEnumValue *evalue;
      GEnumClass *eclass;
      gint init = 0;

      value = mx_combo_box_new ();
      clutter_actor_set_width (value, 100);

      eclass = g_type_class_ref (pspec->value_type);

      while ((evalue = g_enum_get_value (eclass, init)))
        {
          mx_combo_box_append_text (MX_COMBO_BOX (value), evalue->value_nick);
          init++;
        }

      g_type_class_unref (eclass);

      g_object_bind_property (object, pspec->name, value, "index",
                              G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);

    }
  else
    value = NULL;

  if (value)
    {
      clutter_actor_add_child (box, value);
      return box;
    }
  else
    return NULL;
}
Esempio n. 29
0
static void
nmt_page_ppp_constructed (GObject *object)
{
	NmtPagePpp *ppp = NMT_PAGE_PPP (object);
	NmtPagePppPrivate *priv = NMT_PAGE_PPP_GET_PRIVATE (ppp);
	NmtEditorSection *section;
	NmtEditorGrid *grid;
	NMSettingPpp *s_ppp;
	NmtNewtWidget *widget, *use_mppe;
	NmtNewtGrid *auth_grid, *mppe_grid;
	NmtNewtSection *auth_section, *mppe_section;
	NMConnection *conn;

	conn = nmt_editor_page_get_connection (NMT_EDITOR_PAGE (ppp));
	s_ppp = nm_connection_get_setting_ppp (conn);
	if (s_ppp) {
		priv->lcp_echo_interval = nm_setting_ppp_get_lcp_echo_interval (s_ppp);
		priv->lcp_echo_failure = nm_setting_ppp_get_lcp_echo_failure (s_ppp);
	} else {
		s_ppp = (NMSettingPpp *) nm_setting_ppp_new ();
		nm_connection_add_setting (conn, (NMSetting *) s_ppp);

		priv->lcp_echo_interval = 30;
		priv->lcp_echo_failure = 5;
	}

	section = nmt_editor_section_new (_("PPP CONFIGURATION"), NULL, TRUE);
	grid = nmt_editor_section_get_body (section);

	/* Auth methods */
	widget = nmt_newt_section_new (FALSE);
	auth_section = NMT_NEWT_SECTION (widget);
	g_object_set (auth_section, "open", TRUE, NULL);
	nmt_editor_grid_append (grid, NULL, widget, NULL);

	widget = nmt_newt_label_new (_("Allowed authentication methods:"));
	nmt_newt_section_set_header (auth_section, widget);

	widget = nmt_newt_grid_new ();
	auth_grid = NMT_NEWT_GRID (widget);
	nmt_newt_section_set_body (auth_section, widget);

	widget = nmt_newt_checkbox_new (_("EAP"));
	g_object_bind_property (s_ppp, NM_SETTING_PPP_REFUSE_EAP,
	                        widget, "active",
	                        G_BINDING_BIDIRECTIONAL |
	                        G_BINDING_INVERT_BOOLEAN |
	                        G_BINDING_SYNC_CREATE);
	nmt_newt_grid_add (auth_grid, widget, 0, 0);

	widget = nmt_newt_checkbox_new (_("PAP"));
	g_object_bind_property (s_ppp, NM_SETTING_PPP_REFUSE_PAP,
	                        widget, "active",
	                        G_BINDING_BIDIRECTIONAL |
	                        G_BINDING_INVERT_BOOLEAN |
	                        G_BINDING_SYNC_CREATE);
	nmt_newt_grid_add (auth_grid, widget, 0, 1);

	widget = nmt_newt_checkbox_new (_("CHAP"));
	g_object_bind_property (s_ppp, NM_SETTING_PPP_REFUSE_CHAP,
	                        widget, "active",
	                        G_BINDING_BIDIRECTIONAL |
	                        G_BINDING_INVERT_BOOLEAN |
	                        G_BINDING_SYNC_CREATE);
	nmt_newt_grid_add (auth_grid, widget, 0, 2);

	widget = nmt_newt_checkbox_new (_("MSCHAPv2"));
	g_object_bind_property (s_ppp, NM_SETTING_PPP_REFUSE_MSCHAPV2,
	                        widget, "active",
	                        G_BINDING_BIDIRECTIONAL |
	                        G_BINDING_INVERT_BOOLEAN |
	                        G_BINDING_SYNC_CREATE);
	nmt_newt_grid_add (auth_grid, widget, 0, 3);

	widget = nmt_newt_checkbox_new (_("MSCHAP"));
	g_object_bind_property (s_ppp, NM_SETTING_PPP_REFUSE_MSCHAP,
	                        widget, "active",
	                        G_BINDING_BIDIRECTIONAL |
	                        G_BINDING_INVERT_BOOLEAN |
	                        G_BINDING_SYNC_CREATE);
	nmt_newt_grid_add (auth_grid, widget, 0, 4);

	nmt_editor_grid_append (grid, NULL, nmt_newt_separator_new (), NULL);

	/* MPPE */
	widget = nmt_newt_section_new (FALSE);
	mppe_section = NMT_NEWT_SECTION (widget);
	g_object_set (mppe_section, "open", TRUE, NULL);
	nmt_editor_grid_append (grid, NULL, widget, NULL);

	widget = nmt_newt_checkbox_new (_("Use point-to-point encryption (MPPE)"));
	g_object_bind_property (s_ppp, NM_SETTING_PPP_REQUIRE_MPPE,
	                        widget, "active",
	                        G_BINDING_BIDIRECTIONAL |
	                        G_BINDING_SYNC_CREATE);
	use_mppe = widget;
	nmt_newt_section_set_header (mppe_section, widget);

	widget = nmt_newt_grid_new ();
	mppe_grid = NMT_NEWT_GRID (widget);
	nmt_newt_section_set_body (mppe_section, widget);

	widget = nmt_newt_checkbox_new (_("Require 128-bit encryption"));
	g_object_bind_property (use_mppe, "active",
	                        widget, "sensitive",
	                        G_BINDING_SYNC_CREATE);
	g_object_bind_property (s_ppp, NM_SETTING_PPP_REQUIRE_MPPE_128,
	                        widget, "active",
	                        G_BINDING_BIDIRECTIONAL |
	                        G_BINDING_SYNC_CREATE);
	nmt_newt_grid_add (mppe_grid, widget, 0, 0);

	widget = nmt_newt_checkbox_new (_("Use stateful MPPE"));
	g_object_bind_property (use_mppe, "active",
	                        widget, "sensitive",
	                        G_BINDING_SYNC_CREATE);
	g_object_bind_property (s_ppp, NM_SETTING_PPP_MPPE_STATEFUL,
	                        widget, "active",
	                        G_BINDING_BIDIRECTIONAL |
	                        G_BINDING_SYNC_CREATE);
	nmt_newt_grid_add (mppe_grid, widget, 0, 1);

	nmt_editor_grid_append (grid, NULL, nmt_newt_separator_new (), NULL);

	widget = nmt_newt_checkbox_new (_("Allow BSD data compression"));
	g_object_bind_property (s_ppp, NM_SETTING_PPP_NOBSDCOMP,
	                        widget, "active",
	                        G_BINDING_BIDIRECTIONAL |
	                        G_BINDING_INVERT_BOOLEAN |
	                        G_BINDING_SYNC_CREATE);
	nmt_editor_grid_append (grid, NULL, widget, NULL);

	widget = nmt_newt_checkbox_new (_("Allow Deflate data compression"));
	g_object_bind_property (s_ppp, NM_SETTING_PPP_NODEFLATE,
	                        widget, "active",
	                        G_BINDING_BIDIRECTIONAL |
	                        G_BINDING_INVERT_BOOLEAN |
	                        G_BINDING_SYNC_CREATE);
	nmt_editor_grid_append (grid, NULL, widget, NULL);

	widget = nmt_newt_checkbox_new (_("Use TCP header compression"));
	g_object_bind_property (s_ppp, NM_SETTING_PPP_NO_VJ_COMP,
	                        widget, "active",
	                        G_BINDING_BIDIRECTIONAL |
	                        G_BINDING_INVERT_BOOLEAN |
	                        G_BINDING_SYNC_CREATE);
	nmt_editor_grid_append (grid, NULL, widget, NULL);

	nmt_editor_grid_append (grid, NULL, nmt_newt_separator_new (), NULL);

	widget = nmt_newt_checkbox_new (_("Send PPP echo packets"));
	g_object_bind_property_full (s_ppp, NM_SETTING_PPP_LCP_ECHO_INTERVAL,
	                             widget, "active",
	                             G_BINDING_BIDIRECTIONAL |
	                             G_BINDING_SYNC_CREATE,
	                             transform_lcp_echo_properties_to_checkbox,
	                             transform_checkbox_to_lcp_echo_interval,
	                             ppp, NULL);
	g_object_bind_property_full (s_ppp, NM_SETTING_PPP_LCP_ECHO_FAILURE,
	                             widget, "active",
	                             G_BINDING_BIDIRECTIONAL |
	                             G_BINDING_SYNC_CREATE,
	                             transform_lcp_echo_properties_to_checkbox,
	                             transform_checkbox_to_lcp_echo_failure,
	                             ppp, NULL);
	nmt_editor_grid_append (grid, NULL, widget, NULL);

	nmt_editor_page_add_section (NMT_EDITOR_PAGE (ppp), section);

	G_OBJECT_CLASS (nmt_page_ppp_parent_class)->constructed (object);
}
Esempio n. 30
0
static void
nmt_page_ip4_constructed (GObject *object)
{
	NmtPageIP4 *ip4 = NMT_PAGE_IP4 (object);
	gboolean show_by_default;
	NmtEditorSection *section;
	NmtEditorGrid *grid;
	NMSettingIPConfig *s_ip4;
	NmtNewtWidget *widget, *button;
	NMConnection *conn;

	conn = nmt_editor_page_get_connection (NMT_EDITOR_PAGE (ip4));
	s_ip4 = nm_connection_get_setting_ip4_config (conn);
	if (!s_ip4) {
		s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new ();
		g_object_set (G_OBJECT (s_ip4),
		              NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
		              NULL);
		nm_connection_add_setting (conn, (NMSetting *) s_ip4);
	}

	widget = nmt_newt_popup_new (ip4methods);
	g_object_bind_property (s_ip4, NM_SETTING_IP_CONFIG_METHOD,
	                        widget, "active-id",
	                        G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);

	if (!g_strcmp0 (nm_setting_ip_config_get_method (s_ip4), NM_SETTING_IP4_CONFIG_METHOD_MANUAL))
		show_by_default = TRUE;
	else if (nm_setting_ip_config_get_num_addresses (s_ip4))
		show_by_default = TRUE;
	else
		show_by_default = FALSE;

	section = nmt_editor_section_new (_("IPv4 CONFIGURATION"), widget, show_by_default);
	grid = nmt_editor_section_get_body (section);

	widget = nmt_address_list_new (NMT_ADDRESS_LIST_IP4_WITH_PREFIX);
	nm_editor_bind_ip_addresses_with_prefix_to_strv (AF_INET,
	                                                 s_ip4, NM_SETTING_IP_CONFIG_ADDRESSES,
	                                                 widget, "strings",
	                                                 G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
	nmt_editor_grid_append (grid, _("Addresses"), widget, NULL);

	widget = nmt_ip_entry_new (25, AF_INET, FALSE, TRUE);
	nm_editor_bind_ip_gateway_to_string (AF_INET,
	                                     s_ip4,
	                                     widget, "text", "sensitive",
	                                     G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
	nmt_editor_grid_append (grid, _("Gateway"), widget, NULL);

	widget = nmt_address_list_new (NMT_ADDRESS_LIST_IP4);
	nm_editor_bind_ip_addresses_to_strv (AF_INET,
	                                     s_ip4, NM_SETTING_IP_CONFIG_DNS,
	                                     widget, "strings",
	                                     G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
	nmt_editor_grid_append (grid, _("DNS servers"), widget, NULL);

	widget = nmt_address_list_new (NMT_ADDRESS_LIST_HOSTNAME);
	g_object_bind_property (s_ip4, NM_SETTING_IP_CONFIG_DNS_SEARCH,
	                        widget, "strings",
	                        G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
	nmt_editor_grid_append (grid, _("Search domains"), widget, NULL);

	nmt_editor_grid_append (grid, NULL, nmt_newt_separator_new (), NULL);

	widget = g_object_new (NMT_TYPE_NEWT_LABEL,
	                       "text", "",
	                       "style", NMT_NEWT_LABEL_PLAIN,
	                       NULL);
	g_object_bind_property_full (s_ip4, NM_SETTING_IP_CONFIG_ROUTES,
	                             widget, "text",
	                             G_BINDING_SYNC_CREATE,
	                             ip4_routes_transform_to_description,
	                             NULL, NULL, NULL);
	button = nmt_newt_button_new (_("Edit..."));
	g_signal_connect (button, "clicked", G_CALLBACK (edit_routes), s_ip4);
	nmt_editor_grid_append (grid, _("Routing"), widget, button);

	widget = nmt_newt_checkbox_new (_("Never use this network for default route"));
	g_object_bind_property (s_ip4, NM_SETTING_IP_CONFIG_NEVER_DEFAULT,
	                        widget, "active",
	                        G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
	nmt_editor_grid_append (grid, NULL, widget, NULL);

	widget = nmt_newt_checkbox_new (_("Ignore automatically obtained routes"));
	g_object_bind_property (s_ip4, NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES,
	                        widget, "active",
	                        G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
	nmt_editor_grid_append (grid, NULL, widget, NULL);

	nmt_editor_grid_append (grid, NULL, nmt_newt_separator_new (), NULL);

	widget = nmt_newt_checkbox_new (_("Require IPv4 addressing for this connection"));
	g_object_bind_property (s_ip4, NM_SETTING_IP_CONFIG_MAY_FAIL,
	                        widget, "active",
	                        G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL |
	                        G_BINDING_INVERT_BOOLEAN);
	nmt_editor_grid_append (grid, NULL, widget, NULL);

	nmt_editor_page_add_section (NMT_EDITOR_PAGE (ip4), section);

	G_OBJECT_CLASS (nmt_page_ip4_parent_class)->constructed (object);
}