/**
 * gtk_radio_menu_item_set_group:
 * @radio_menu_item: a #GtkRadioMenuItem.
 * @group: (element-type GtkRadioMenuItem): the new group.
 *
 * Sets the group of a radio menu item, or changes it.
 */
void
gtk_radio_menu_item_set_group (GtkRadioMenuItem *radio_menu_item,
			       GSList           *group)
{
  GtkRadioMenuItemPrivate *priv;
  GtkWidget *old_group_singleton = NULL;
  GtkWidget *new_group_singleton = NULL;

  g_return_if_fail (GTK_IS_RADIO_MENU_ITEM (radio_menu_item));

  priv = radio_menu_item->priv;

  if (priv->group == group)
    return;

  if (priv->group)
    {
      GSList *slist;

      priv->group = g_slist_remove (priv->group, radio_menu_item);

      if (priv->group && !priv->group->next)
	old_group_singleton = g_object_ref (priv->group->data);

      for (slist = priv->group; slist; slist = slist->next)
	{
	  GtkRadioMenuItem *tmp_item;
	  
	  tmp_item = slist->data;

	  tmp_item->priv->group = priv->group;
	}
    }
  
  if (group && !group->next)
    new_group_singleton = g_object_ref (group->data);

  priv->group = g_slist_prepend (group, radio_menu_item);

  if (group)
    {
      GSList *slist;
      
      for (slist = group; slist; slist = slist->next)
	{
	  GtkRadioMenuItem *tmp_item;
	  
	  tmp_item = slist->data;

	  tmp_item->priv->group = priv->group;
	}
    }
  else
    {
      _gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (radio_menu_item), TRUE);
      /* gtk_widget_set_state (GTK_WIDGET (radio_menu_item), GTK_STATE_ACTIVE);
       */
    }

  g_object_ref (radio_menu_item);

  g_object_notify (G_OBJECT (radio_menu_item), "group");
  g_signal_emit (radio_menu_item, group_changed_signal, 0);
  if (old_group_singleton)
    {
      g_signal_emit (old_group_singleton, group_changed_signal, 0);
      g_object_unref (old_group_singleton);
    }
  if (new_group_singleton)
    {
      g_signal_emit (new_group_singleton, group_changed_signal, 0);
      g_object_unref (new_group_singleton);
    }

  g_object_unref (radio_menu_item);
}
static gboolean
gimp_number_pair_entry_events (GtkWidget *widget,
                               GdkEvent  *event)
{
  GimpNumberPairEntry        *entry;
  GimpNumberPairEntryPrivate *priv;
  gboolean                    force_user_override;

  entry               = GIMP_NUMBER_PAIR_ENTRY (widget);
  priv                = GIMP_NUMBER_PAIR_ENTRY_GET_PRIVATE (entry);
  force_user_override = FALSE;

  switch (event->type)
    {
    case GDK_KEY_PRESS:
      {
        GdkEventKey *kevent = (GdkEventKey *) event;

        if (kevent->keyval != GDK_KEY_Return   &&
            kevent->keyval != GDK_KEY_KP_Enter &&
            kevent->keyval != GDK_KEY_ISO_Enter)
          break;

        /* If parsing was done due to widgets focus being lost, we only change
         * to user-override mode if the values differ from the default ones. If
         * Return was pressed however, we always switch to user-override mode.
         */
        force_user_override = TRUE;
      }
      /* Fall through */

    case GDK_FOCUS_CHANGE:
      {
        const gchar *text;
        ParseResult  parse_result;
        gdouble      left_value;
        gdouble      right_value;

        text = gtk_entry_get_text (GTK_ENTRY (entry));

        parse_result = gimp_number_pair_entry_parse_text (entry,
                                                          text,
                                                          &left_value,
                                                          &right_value);
        switch (parse_result)
          {
          case PARSE_VALID:
            {
              if (priv->left_number  != left_value  ||
                  priv->right_number != right_value ||
                  force_user_override)
                {
                  gimp_number_pair_entry_set_values (entry,
                                                     left_value,
                                                     right_value);

                  priv->user_override = TRUE;
                  g_object_notify (G_OBJECT (entry), "user-override");
                }
            }
            break;

          case PARSE_CLEAR:

            gimp_number_pair_entry_set_values (entry,
                                               priv->default_left_number,
                                               priv->default_right_number);

            priv->user_override = FALSE;
            g_object_notify (G_OBJECT (entry), "user-override");
            break;

          default:
            break;
          }

        /* Mak sure the entry text is up to date */

        gimp_number_pair_entry_update_text (entry);

        gtk_editable_set_position (GTK_EDITABLE (entry), -1);
      }
      break;

    default:
      break;
    }

  return FALSE;
}
static gboolean
gst_selector_pad_event (GstPad * pad, GstEvent * event)
{
  gboolean res = TRUE;
  gboolean forward = TRUE;
  GstInputSelector *sel;
  GstSelectorPad *selpad;
  GstPad *prev_active_sinkpad;
  GstPad *active_sinkpad;

  sel = GST_INPUT_SELECTOR (gst_pad_get_parent (pad));
  selpad = GST_SELECTOR_PAD_CAST (pad);

  GST_INPUT_SELECTOR_LOCK (sel);
  prev_active_sinkpad = sel->active_sinkpad;
  active_sinkpad = gst_input_selector_activate_sinkpad (sel, pad);

  /* only forward if we are dealing with the active sinkpad or if select_all
   * is enabled */
  if (pad != active_sinkpad && !sel->select_all)
    forward = FALSE;
  GST_INPUT_SELECTOR_UNLOCK (sel);

  if (prev_active_sinkpad != active_sinkpad && pad == active_sinkpad)
    g_object_notify (G_OBJECT (sel), "active-pad");

  switch (GST_EVENT_TYPE (event)) {
    case GST_EVENT_FLUSH_START:
      /* FIXME, flush out the waiter */
      break;
    case GST_EVENT_FLUSH_STOP:
      GST_INPUT_SELECTOR_LOCK (sel);
      gst_selector_pad_reset (selpad);
      sel->pending_close = FALSE;
      GST_INPUT_SELECTOR_UNLOCK (sel);
      break;
    case GST_EVENT_NEWSEGMENT:
    {
      gboolean update;
      GstFormat format;
      gdouble rate, arate;
      gint64 start, stop, time;

      gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format,
          &start, &stop, &time);

      GST_DEBUG_OBJECT (pad,
          "configured NEWSEGMENT update %d, rate %lf, applied rate %lf, "
          "format %d, "
          "%" G_GINT64_FORMAT " -- %" G_GINT64_FORMAT ", time %"
          G_GINT64_FORMAT, update, rate, arate, format, start, stop, time);

      GST_INPUT_SELECTOR_LOCK (sel);
      GST_OBJECT_LOCK (selpad);
      gst_segment_set_newsegment_full (&selpad->segment, update,
          rate, arate, format, start, stop, time);
      GST_OBJECT_UNLOCK (selpad);

      /* If we aren't forwarding the event (because the pad is not the
       * active_sinkpad, and select_all is not set, then set the flag on the
       * that says a segment needs sending if/when that pad is activated.
       * For all other cases, we send the event immediately, which makes
       * sparse streams and other segment updates work correctly downstream.
       */
      if (!forward)
        selpad->segment_pending = TRUE;

      GST_INPUT_SELECTOR_UNLOCK (sel);
      break;
    }
    case GST_EVENT_TAG:
    {
      GstTagList *tags, *oldtags, *newtags;

      gst_event_parse_tag (event, &tags);

      GST_OBJECT_LOCK (selpad);
      oldtags = selpad->tags;

      newtags = gst_tag_list_merge (oldtags, tags, GST_TAG_MERGE_REPLACE);
      selpad->tags = newtags;
      if (oldtags)
        gst_tag_list_free (oldtags);
      GST_DEBUG_OBJECT (pad, "received tags %" GST_PTR_FORMAT, newtags);
      GST_OBJECT_UNLOCK (selpad);

      g_object_notify (G_OBJECT (selpad), "tags");
      break;
    }
    case GST_EVENT_EOS:
      selpad->eos = TRUE;
      GST_DEBUG_OBJECT (pad, "received EOS");
      /* don't forward eos in select_all mode until all sink pads have eos */
      if (sel->select_all && !gst_input_selector_check_eos (GST_ELEMENT (sel))) {
        forward = FALSE;
      }
      break;
    default:
      break;
  }
  if (forward) {
    GST_DEBUG_OBJECT (pad, "forwarding event");
    res = gst_pad_push_event (sel->srcpad, event);
  } else
    gst_event_unref (event);

  gst_object_unref (sel);

  return res;
}
/**
 * gvir_config_domain_set_memory:
 * @domain: a #GVirConfigDomain
 * @memory: The amount of RAM in kilobytes.
 *
 * Sets the amount of RAM allocated to @domain in kilobytes (i.e. blocks of 1024 bytes).
 */
void gvir_config_domain_set_memory(GVirConfigDomain *domain, guint64 memory)
{
    gvir_config_object_set_node_content_uint64(GVIR_CONFIG_OBJECT(domain),
                                               "memory", memory);
    g_object_notify(G_OBJECT(domain), "memory");
}
static void
process_lldp_neighbors (NMLldpListener *self)
{
	NMLldpListenerPrivate *priv = NM_LLDP_LISTENER_GET_PRIVATE (self);
	sd_lldp_packet **packets = NULL;
	GHashTable *hash;
	int num, i;

	num = sd_lldp_get_packets (priv->lldp_handle, &packets);
	if (num < 0) {
		nm_log_dbg (LOGD_DEVICE, "LLDP: error %d retrieving neighbor packets for %s",
		            num, priv->iface);
		return;
	}

	hash = g_hash_table_new_full (lldp_neighbor_id_hash, lldp_neighbor_id_equal,
	                              lldp_neighbor_free, NULL);

	for (i = 0; packets && i < num; i++) {
		uint8_t chassis_id_type, port_id_type, *chassis_id, *port_id, data8;
		uint16_t chassis_id_len, port_id_len, len, data16;
		LLDPNeighbor *neigh;
		GValue *value;
		char *str;
		int r;

		if (i >= MAX_NEIGHBORS)
			goto next_packet;

		r = sd_lldp_packet_read_chassis_id (packets[i], &chassis_id_type,
		                                    &chassis_id, &chassis_id_len);
		if (r < 0)
			goto next_packet;

		r = sd_lldp_packet_read_port_id (packets[i], &port_id_type,
		                                 &port_id, &port_id_len);
		if (r < 0)
			goto next_packet;

		neigh = g_malloc0 (sizeof (LLDPNeighbor));
		neigh->tlvs = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, gvalue_destroy);
		neigh->chassis_id_type = chassis_id_type;
		neigh->port_id_type = port_id_type;
		sd_lldp_packet_get_destination_type (packets[i], &neigh->dest);

		if (chassis_id_len < 1) {
			lldp_neighbor_free (neigh);
			goto next_packet;
		}

		switch (chassis_id_type) {
		case LLDP_CHASSIS_SUBTYPE_INTERFACE_ALIAS:
		case LLDP_CHASSIS_SUBTYPE_INTERFACE_NAME:
		case LLDP_CHASSIS_SUBTYPE_LOCALLY_ASSIGNED:
		case LLDP_CHASSIS_SUBTYPE_CHASSIS_COMPONENT:
			neigh->chassis_id = strndup ((char *) chassis_id, chassis_id_len);
			break;
		case LLDP_CHASSIS_SUBTYPE_MAC_ADDRESS:
			neigh->chassis_id = nm_utils_hwaddr_ntoa (chassis_id, chassis_id_len);
			break;
		default:
			nm_log_dbg (LOGD_DEVICE, "LLDP: unsupported chassis ID type %d", chassis_id_type);
			lldp_neighbor_free (neigh);
			goto next_packet;
		}

		if (port_id_len < 1) {
			lldp_neighbor_free (neigh);
			goto next_packet;
		}

		switch (port_id_type) {
		case LLDP_PORT_SUBTYPE_INTERFACE_ALIAS:
		case LLDP_PORT_SUBTYPE_INTERFACE_NAME:
		case LLDP_PORT_SUBTYPE_LOCALLY_ASSIGNED:
		case LLDP_PORT_SUBTYPE_PORT_COMPONENT:
			neigh->port_id = strndup ((char *) port_id, port_id_len);
			break;
		case LLDP_PORT_SUBTYPE_MAC_ADDRESS:
			neigh->port_id = nm_utils_hwaddr_ntoa (port_id, port_id_len);
			break;
		default:
			nm_log_dbg (LOGD_DEVICE, "LLDP: unsupported port ID type %d", port_id_type);
			lldp_neighbor_free (neigh);
			goto next_packet;
		}

		if (sd_lldp_packet_read_port_description (packets[i], &str, &len) == 0) {
			value = gvalue_new_nstr (str, len);
			g_hash_table_insert (neigh->tlvs, NM_LLDP_ATTR_PORT_DESCRIPTION, value);
		}

		if (sd_lldp_packet_read_system_name (packets[i], &str, &len) == 0) {
			value = gvalue_new_nstr (str, len);
			g_hash_table_insert (neigh->tlvs, NM_LLDP_ATTR_SYSTEM_NAME, value);
		}

		if (sd_lldp_packet_read_system_description (packets[i], &str, &len) == 0) {
			value = gvalue_new_nstr (str, len);
			g_hash_table_insert (neigh->tlvs, NM_LLDP_ATTR_SYSTEM_DESCRIPTION, value);
		}

		if (sd_lldp_packet_read_system_capability (packets[i], &data16) == 0) {
			value = gvalue_new_uint (data16);
			g_hash_table_insert (neigh->tlvs, NM_LLDP_ATTR_SYSTEM_CAPABILITIES, value);
		}

		if (sd_lldp_packet_read_port_vlan_id (packets[i], &data16) == 0) {
			value = gvalue_new_uint (data16);
			g_hash_table_insert (neigh->tlvs, NM_LLDP_ATTR_IEEE_802_1_PVID, value);
		}

		if (sd_lldp_packet_read_port_protocol_vlan_id (packets[i], &data8, &data16) == 0) {
			value = gvalue_new_uint (data16);
			g_hash_table_insert (neigh->tlvs, NM_LLDP_ATTR_IEEE_802_1_PPVID, value);

			value = gvalue_new_uint (data8);
			g_hash_table_insert (neigh->tlvs, NM_LLDP_ATTR_IEEE_802_1_PPVID_FLAGS, value);
		}

		if (sd_lldp_packet_read_vlan_name (packets[i], &data16, &str, &len) == 0) {
			value = gvalue_new_uint (data16);
			g_hash_table_insert (neigh->tlvs, NM_LLDP_ATTR_IEEE_802_1_VID, value);

			value = gvalue_new_nstr (str, len);
			g_hash_table_insert (neigh->tlvs, NM_LLDP_ATTR_IEEE_802_1_VLAN_NAME, value);
		}

		nm_log_dbg (LOGD_DEVICE, "LLDP: new neigh: CHASSIS='%s' PORT='%s'",
		            neigh->chassis_id, neigh->port_id);

		g_hash_table_add (hash, neigh);
next_packet:
		sd_lldp_packet_unref (packets[i]);
	}

	g_free (packets);

	if (lldp_hash_table_equal (priv->lldp_neighbors, hash)) {
		g_hash_table_destroy (hash);
	} else {
		g_hash_table_destroy (priv->lldp_neighbors);
		priv->lldp_neighbors = hash;
		nm_clear_g_variant (&priv->variant);
		g_object_notify (G_OBJECT (self), NM_LLDP_LISTENER_NEIGHBORS);
	}

	/* Since the processing of the neighbor list is potentially
	 * expensive when there are many neighbors, coalesce multiple
	 * events arriving in short time.
	 */
	priv->timer = g_timeout_add_seconds (MIN_UPDATE_INTERVAL, lldp_timeout, self);
	priv->num_pending_events = 0;
}
Exemple #6
0
void
gimp_levels_config_adjust_by_colors (GimpLevelsConfig     *config,
                                     GimpHistogramChannel  channel,
                                     const GimpRGB        *black,
                                     const GimpRGB        *gray,
                                     const GimpRGB        *white)
{
  g_return_if_fail (GIMP_IS_LEVELS_CONFIG (config));

  g_object_freeze_notify (G_OBJECT (config));

  if (black)
    {
      config->low_input[channel] = gimp_levels_config_input_from_color (channel,
                                                                        black);
      g_object_notify (G_OBJECT (config), "low-input");
    }


  if (white)
    {
      config->high_input[channel] = gimp_levels_config_input_from_color (channel,
                                                                         white);
      g_object_notify (G_OBJECT (config), "high-input");
    }

  if (gray)
    {
      gdouble input;
      gdouble range;
      gdouble inten;
      gdouble out_light;
      gdouble lightness;

      /* Calculate lightness value */
      lightness = GIMP_RGB_LUMINANCE (gray->r, gray->g, gray->b);

      input = gimp_levels_config_input_from_color (channel, gray);

      range = config->high_input[channel] - config->low_input[channel];
      if (range <= 0)
        return;

      input -= config->low_input[channel];
      if (input < 0)
        return;

      /* Normalize input and lightness */
      inten = input / range;
      out_light = lightness/ range;

      if (out_light <= 0)
        return;

      /* Map selected color to corresponding lightness */
      config->gamma[channel] = log (inten) / log (out_light);
      g_object_notify (G_OBJECT (config), "gamma");
    }

  g_object_thaw_notify (G_OBJECT (config));
}
/**
 * gvir_config_domain_set_title:
 * @domain: a #GVirConfigDomain
 * @title: (allow-none): title of the domain
 *
 * Sets the title of the domain. This is an optional short textual description of the domain. Passing a NULL @title
 * unsets the current domain title.
 */
void gvir_config_domain_set_title(GVirConfigDomain *domain, const char *title)
{
    gvir_config_object_set_node_content(GVIR_CONFIG_OBJECT(domain),
                                        "title", title);
    g_object_notify(G_OBJECT(domain), "title");
}
Exemple #8
0
void gmpc_widgets_qtable_set_item_width (GmpcWidgetsQtable* self, gint value) {
	g_return_if_fail (self != NULL);
	self->priv->item_width_real = value;
	gtk_widget_queue_resize ((GtkWidget*) self);
	g_object_notify ((GObject *) self, "item-width");
}
Exemple #9
0
void gmpc_widgets_qtable_set_header_height (GmpcWidgetsQtable* self, gint value) {
	g_return_if_fail (self != NULL);
	self->priv->header_height_real = value;
	gtk_widget_queue_resize ((GtkWidget*) self);
	g_object_notify ((GObject *) self, "header-height");
}
Exemple #10
0
void gmpc_widgets_qtable_set_spacing (GmpcWidgetsQtable* self, gint value) {
	g_return_if_fail (self != NULL);
	self->priv->_spacing = value;
	g_object_notify ((GObject *) self, "spacing");
}
Exemple #11
0
void gmpc_widgets_qtable_set_max_columns (GmpcWidgetsQtable* self, gint value) {
	g_return_if_fail (self != NULL);
	self->priv->max_columns_real = value;
	gtk_widget_queue_resize ((GtkWidget*) self);
	g_object_notify ((GObject *) self, "max-columns");
}
Exemple #12
0
static void
goo_canvas_ellipse_set_common_property (GObject              *object,
					GooCanvasEllipseData *ellipse_data,
					guint                 prop_id,
					const GValue         *value,
					GParamSpec           *pspec)
{
  gdouble x, y;

  switch (prop_id)
    {
    case PROP_CENTER_X:
      ellipse_data->center_x = g_value_get_double (value);
      g_object_notify (object, "x");
      break;
    case PROP_CENTER_Y:
      ellipse_data->center_y = g_value_get_double (value);
      g_object_notify (object, "y");
      break;
    case PROP_RADIUS_X:
      ellipse_data->radius_x = g_value_get_double (value);
      g_object_notify (object, "width");
      break;
    case PROP_RADIUS_Y:
      ellipse_data->radius_y = g_value_get_double (value);
      g_object_notify (object, "height");
      break;
    case PROP_X:
      ellipse_data->center_x = g_value_get_double (value) + ellipse_data->radius_x;
      g_object_notify (object, "center-x");
      break;
    case PROP_Y:
      ellipse_data->center_y = g_value_get_double (value) + ellipse_data->radius_y;
      g_object_notify (object, "center-y");
      break;
    case PROP_WIDTH:
      /* Calculate the current x coordinate. */
      x = ellipse_data->center_x - ellipse_data->radius_x;
      /* Calculate the new radius_x, which is half the width. */
      ellipse_data->radius_x = g_value_get_double (value) / 2.0;
      /* Now calculate the new center_x. */
      ellipse_data->center_x = x + ellipse_data->radius_x;

      g_object_notify (object, "center-x");
      g_object_notify (object, "radius-x");
      break;
    case PROP_HEIGHT:
      /* Calculate the current y coordinate. */
      y = ellipse_data->center_y - ellipse_data->radius_y;
      /* Calculate the new radius_y, which is half the height. */
      ellipse_data->radius_y = g_value_get_double (value) / 2.0;
      /* Now calculate the new center_y. */
      ellipse_data->center_y = y + ellipse_data->radius_y;

      g_object_notify (object, "center-y");
      g_object_notify (object, "radius-y");
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
static void gnomenu_global_settings_set_screen (GnomenuGlobalSettings* self, GdkScreen* value) {
	GdkScreen* _tmp0_;
	g_return_if_fail (self != NULL);
	self->priv->_screen = (_tmp0_ = _g_object_ref0 (value), _g_object_unref0 (self->priv->_screen), _tmp0_);
	g_object_notify ((GObject *) self, "screen");
}
/**
 * empathy_account_chooser_set_has_all_option:
 * @self: an #EmpathyAccountChooser
 * @has_all_option: a new value for the #EmpathyAccountChooser:has-all-option
 * property
 *
 * Sets the #EmpathyAccountChooser:has-all-option property.
 */
void
empathy_account_chooser_set_has_all_option (EmpathyAccountChooser *self,
    gboolean has_all_option)
{
  GtkComboBox *combobox;
  GtkListStore *store;
  GtkTreeModel *model;
  GtkTreeIter iter;

  g_return_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (self));

  if (self->priv->has_all_option == has_all_option)
    return;

  combobox = GTK_COMBO_BOX (self);
  model = gtk_combo_box_get_model (combobox);
  store = GTK_LIST_STORE (model);

  self->priv->has_all_option = has_all_option;

  /*
   * The first 2 options are the ALL and separator
   */

  if (has_all_option)
    {
      gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (self),
          (GtkTreeViewRowSeparatorFunc)
          account_chooser_separator_func,
          self,
          NULL);

      gtk_list_store_prepend (store, &iter);
      gtk_list_store_set (store, &iter,
          COL_ACCOUNT_TEXT, NULL,
          COL_ACCOUNT_ENABLED, TRUE,
          COL_ACCOUNT_POINTER, NULL,
          COL_ACCOUNT_ROW_TYPE, ROW_SEPARATOR,
          -1);

      gtk_list_store_prepend (store, &iter);
      gtk_list_store_set (store, &iter,
          COL_ACCOUNT_TEXT, _("All accounts"),
          COL_ACCOUNT_ENABLED, TRUE,
          COL_ACCOUNT_POINTER, NULL,
          COL_ACCOUNT_ROW_TYPE, ROW_ALL,
          -1);
    }
  else
    {
      if (gtk_tree_model_get_iter_first (model, &iter))
        {
          if (gtk_list_store_remove (GTK_LIST_STORE (model), &iter))
            gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
        }

    gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (self),
        (GtkTreeViewRowSeparatorFunc)
        NULL,
        NULL,
        NULL);
  }

  g_object_notify (G_OBJECT (self), "has-all-option");
}
Exemple #15
0
/**
 * uca_camera_start_recording:
 * @camera: A #UcaCamera object
 * @error: Location to store a #UcaCameraError error or %NULL
 *
 * Initiate recording of frames. If UcaCamera:grab-asynchronous is %TRUE and a
 * #UcaCameraGrabFunc callback is set, frames are automatically transfered to
 * the client program, otherwise you must use uca_camera_grab().
 */
void
uca_camera_start_recording (UcaCamera *camera, GError **error)
{
    UcaCameraClass *klass;
    UcaCameraPrivate *priv;
    GError *tmp_error = NULL;
    static GStaticMutex mutex = G_STATIC_MUTEX_INIT;

    g_return_if_fail (UCA_IS_CAMERA (camera));

    klass = UCA_CAMERA_GET_CLASS (camera);

    g_return_if_fail (klass != NULL);
    g_return_if_fail (klass->start_recording != NULL);

    priv = camera->priv;

    g_static_mutex_lock (&mutex);

    if (priv->is_recording) {
        g_set_error (error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_RECORDING,
                     "Camera is already recording");
        goto start_recording_unlock;
    }

    if (priv->transfer_async && (camera->grab_func == NULL)) {
        g_set_error (error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_NO_GRAB_FUNC,
                     "No grab callback function set");
        goto start_recording_unlock;
    }

    g_static_mutex_lock (&access_lock);
    (*klass->start_recording)(camera, &tmp_error);
    g_static_mutex_unlock (&access_lock);

    if (tmp_error == NULL) {
        priv->is_readout = FALSE;
        priv->is_recording = TRUE;
        priv->cancelling_recording = FALSE;

        /* TODO: we should depend on GLib 2.26 and use g_object_notify_by_pspec */
        g_object_notify (G_OBJECT (camera), "is-recording");
    }
    else
        g_propagate_error (error, tmp_error);

    if (priv->buffered) {
        guint width, height, bitdepth;
        guint pixel_size;

        g_object_get (camera,
                      "roi-width", &width,
                      "roi-height", &height,
                      "sensor-bitdepth", &bitdepth,
                      NULL);

        pixel_size = bitdepth <= 8 ? 1 : 2;
        priv->ring_buffer = uca_ring_buffer_new (width * height * pixel_size,
                                                         priv->num_buffers);

        /* Let's read out the frames from another thread */
        priv->read_thread = g_thread_new ("read-thread", (GThreadFunc) buffer_thread, camera);
    }

start_recording_unlock:
    g_static_mutex_unlock (&mutex);
}
static void
gimp_perspective_clone_paint (GimpPaintCore    *paint_core,
                              GimpDrawable     *drawable,
                              GimpPaintOptions *paint_options,
                              GimpSymmetry     *sym,
                              GimpPaintState    paint_state,
                              guint32           time)
{
  GimpSourceCore       *source_core   = GIMP_SOURCE_CORE (paint_core);
  GimpPerspectiveClone *clone         = GIMP_PERSPECTIVE_CLONE (paint_core);
  GimpContext          *context       = GIMP_CONTEXT (paint_options);
  GimpCloneOptions     *clone_options = GIMP_CLONE_OPTIONS (paint_options);
  GimpSourceOptions    *options       = GIMP_SOURCE_OPTIONS (paint_options);
  const GimpCoords     *coords;

  /* The source is based on the original stroke */
  coords = gimp_symmetry_get_origin (sym);

  switch (paint_state)
    {
    case GIMP_PAINT_STATE_INIT:
      if (source_core->set_source)
        {
          g_object_set (source_core, "src-drawable", drawable, NULL);

          source_core->src_x = coords->x;
          source_core->src_y = coords->y;

          /* get source coordinates in front view perspective */
          gimp_matrix3_transform_point (&clone->transform_inv,
                                        source_core->src_x,
                                        source_core->src_y,
                                        &clone->src_x_fv,
                                        &clone->src_y_fv);

          source_core->first_stroke = TRUE;
        }
      else
        {
          GeglBuffer *orig_buffer = NULL;
          GeglNode   *tile        = NULL;
          GeglNode   *src_node;

          if (options->align_mode == GIMP_SOURCE_ALIGN_NO)
            {
              source_core->orig_src_x = source_core->src_x;
              source_core->orig_src_y = source_core->src_y;

              source_core->first_stroke = TRUE;
            }

          clone->node = gegl_node_new ();

          g_object_set (clone->node,
                        "dont-cache", TRUE,
                        NULL);

          switch (clone_options->clone_type)
            {
            case GIMP_CLONE_IMAGE:
              {
                GimpPickable *src_pickable;
                GimpImage    *src_image;
                GimpImage    *dest_image;

                /*  If the source image is different from the
                 *  destination, then we should copy straight from the
                 *  source image to the canvas.
                 *  Otherwise, we need a call to get_orig_image to make sure
                 *  we get a copy of the unblemished (offset) image
                 */
                src_pickable = GIMP_PICKABLE (source_core->src_drawable);
                src_image    = gimp_pickable_get_image (src_pickable);

                if (options->sample_merged)
                  src_pickable = GIMP_PICKABLE (src_image);

                dest_image = gimp_item_get_image (GIMP_ITEM (drawable));

                if ((options->sample_merged &&
                     (src_image != dest_image)) ||
                    (! options->sample_merged &&
                     (source_core->src_drawable != drawable)))
                  {
                    orig_buffer = gimp_pickable_get_buffer (src_pickable);
                  }
                else
                  {
                    if (options->sample_merged)
                      orig_buffer = gimp_paint_core_get_orig_proj (paint_core);
                    else
                      orig_buffer = gimp_paint_core_get_orig_image (paint_core);
                  }
              }
              break;

            case GIMP_CLONE_PATTERN:
              {
                GimpPattern *pattern = gimp_context_get_pattern (context);

                orig_buffer = gimp_pattern_create_buffer (pattern);

                tile = gegl_node_new_child (clone->node,
                                            "operation", "gegl:tile",
                                            NULL);
                clone->crop = gegl_node_new_child (clone->node,
                                                   "operation", "gegl:crop",
                                                   NULL);
              }
              break;
            }

          src_node = gegl_node_new_child (clone->node,
                                          "operation", "gegl:buffer-source",
                                          "buffer",    orig_buffer,
                                          NULL);

          clone->transform_node =
            gegl_node_new_child (clone->node,
                                 "operation", "gegl:transform",
                                 "sampler",    GIMP_INTERPOLATION_LINEAR,
                                 NULL);

          clone->dest_node =
            gegl_node_new_child (clone->node,
                                 "operation", "gegl:write-buffer",
                                 NULL);

          if (tile)
            {
              gegl_node_link_many (src_node,
                                   tile,
                                   clone->crop,
                                   clone->transform_node,
                                   clone->dest_node,
                                   NULL);

              g_object_unref (orig_buffer);
            }
          else
            {
              gegl_node_link_many (src_node,
                                   clone->transform_node,
                                   clone->dest_node,
                                   NULL);
            }
        }
      break;

    case GIMP_PAINT_STATE_MOTION:
      if (source_core->set_source)
        {
          /*  If the control key is down, move the src target and return */

          source_core->src_x = coords->x;
          source_core->src_y = coords->y;

          /* get source coordinates in front view perspective */
          gimp_matrix3_transform_point (&clone->transform_inv,
                                        source_core->src_x,
                                        source_core->src_y,
                                        &clone->src_x_fv,
                                        &clone->src_y_fv);

          source_core->first_stroke = TRUE;
        }
      else
        {
          /*  otherwise, update the target  */

          gint dest_x;
          gint dest_y;
          gint n_strokes;
          gint i;

          n_strokes = gimp_symmetry_get_size (sym);
          for (i = 0; i < n_strokes; i++)
            {
              coords = gimp_symmetry_get_coords (sym, i);

              dest_x = coords->x;
              dest_y = coords->y;

              if (options->align_mode == GIMP_SOURCE_ALIGN_REGISTERED)
                {
                  source_core->offset_x = 0;
                  source_core->offset_y = 0;
                }
              else if (options->align_mode == GIMP_SOURCE_ALIGN_FIXED)
                {
                  source_core->offset_x = source_core->src_x - dest_x;
                  source_core->offset_y = source_core->src_y - dest_y;
                }
              else if (source_core->first_stroke)
                {
                  source_core->offset_x = source_core->src_x - dest_x;
                  source_core->offset_y = source_core->src_y - dest_y;

                  /* get destination coordinates in front view perspective */
                  gimp_matrix3_transform_point (&clone->transform_inv,
                                                dest_x,
                                                dest_y,
                                                &clone->dest_x_fv,
                                                &clone->dest_y_fv);

                  source_core->first_stroke = FALSE;
                }
            }

          gimp_source_core_motion (source_core, drawable, paint_options, sym);
        }
      break;

    case GIMP_PAINT_STATE_FINISH:
      if (clone->node)
        {
          g_object_unref (clone->node);
          clone->node           = NULL;
          clone->crop           = NULL;
          clone->transform_node = NULL;
          clone->dest_node      = NULL;
        }
      break;

    default:
      break;
    }

  g_object_notify (G_OBJECT (clone), "src-x");
  g_object_notify (G_OBJECT (clone), "src-y");
}
Exemple #17
0
void
gimp_levels_config_stretch_channel (GimpLevelsConfig     *config,
                                    GimpHistogram        *histogram,
                                    GimpHistogramChannel  channel)
{
  gdouble count;
  gint    i;

  g_return_if_fail (GIMP_IS_LEVELS_CONFIG (config));
  g_return_if_fail (histogram != NULL);

  g_object_freeze_notify (G_OBJECT (config));

  config->gamma[channel]       = 1.0;
  config->low_output[channel]  = 0.0;
  config->high_output[channel] = 1.0;

  count = gimp_histogram_get_count (histogram, channel, 0, 255);

  if (count == 0.0)
    {
      config->low_input[channel]  = 0.0;
      config->high_input[channel] = 0.0;
    }
  else
    {
      gdouble new_count;
      gdouble percentage;
      gdouble next_percentage;

      /*  Set the low input  */
      new_count = 0.0;

      for (i = 0; i < 255; i++)
        {
          new_count += gimp_histogram_get_value (histogram, channel, i);
          percentage = new_count / count;
          next_percentage = (new_count +
                             gimp_histogram_get_value (histogram,
                                                       channel,
                                                       i + 1)) / count;

          if (fabs (percentage - 0.006) < fabs (next_percentage - 0.006))
            {
              config->low_input[channel] = (gdouble) (i + 1) / 255.0;
              break;
            }
        }

      /*  Set the high input  */
      new_count = 0.0;

      for (i = 255; i > 0; i--)
        {
          new_count += gimp_histogram_get_value (histogram, channel, i);
          percentage = new_count / count;
          next_percentage = (new_count +
                             gimp_histogram_get_value (histogram,
                                                       channel,
                                                       i - 1)) / count;

          if (fabs (percentage - 0.006) < fabs (next_percentage - 0.006))
            {
              config->high_input[channel] = (gdouble) (i - 1) / 255.0;
              break;
            }
        }
    }

  g_object_notify (G_OBJECT (config), "gamma");
  g_object_notify (G_OBJECT (config), "low-input");
  g_object_notify (G_OBJECT (config), "high-input");
  g_object_notify (G_OBJECT (config), "low-output");
  g_object_notify (G_OBJECT (config), "high-output");

  g_object_thaw_notify (G_OBJECT (config));
}
static void
gst_droidcamsrc_dev_compressed_image_callback (void *user, DroidMediaData * mem)
{
  GstDroidCamSrcDev *dev = (GstDroidCamSrcDev *) user;
  GstDroidCamSrc *src = GST_DROIDCAMSRC (GST_PAD_PARENT (dev->imgsrc->pad));
  size_t size = mem->size;
  void *data = mem->data;
  GstBuffer *buffer;
  GstTagList *tags;
  GstEvent *event = NULL;
  void *d;

  GST_DEBUG_OBJECT (src, "dev compressed image callback");

  if (!data) {
    GST_ERROR_OBJECT (src, "invalid memory from camera hal");
    return;
  }

  /* TODO: research a way to get rid of the memcpy */
  d = g_malloc (size);
  memcpy (d, data, size);
  buffer = gst_buffer_new_wrapped (d, size);
  if (!dev->img->image_preview_sent) {
    gst_droidcamsrc_post_message (src,
        gst_structure_new_empty (GST_DROIDCAMSRC_CAPTURE_END));
    /* TODO: generate and send preview if we don't get it from HAL */
    dev->img->image_preview_sent = TRUE;
  }

  gst_droidcamsrc_timestamp (src, buffer);

  tags = gst_droidcamsrc_exif_tags_from_jpeg_data (d, size);
  if (tags) {
    GST_INFO_OBJECT (src, "pushing tags %" GST_PTR_FORMAT, tags);
    event = gst_event_new_tag (tags);
  }

  g_mutex_lock (&dev->imgsrc->lock);

  // TODO: get the correct lock
  if (event) {
    src->imgsrc->pending_events =
        g_list_append (src->imgsrc->pending_events, event);
  }

  g_queue_push_tail (dev->imgsrc->queue, buffer);
  g_cond_signal (&dev->imgsrc->cond);
  g_mutex_unlock (&dev->imgsrc->lock);

  /* we need to start restart the preview
   * android demands this but GStreamer does not know about it.
   */
  g_rec_mutex_lock (dev->lock);
  dev->running = FALSE;
  g_rec_mutex_unlock (dev->lock);

  gst_droidcamsrc_dev_start (dev, TRUE);

  g_mutex_lock (&src->capture_lock);
  --src->captures;
  g_mutex_unlock (&src->capture_lock);

  g_object_notify (G_OBJECT (src), "ready-for-capture");
}
Exemple #19
0
gboolean
gimp_levels_config_load_cruft (GimpLevelsConfig  *config,
                               gpointer           fp,
                               GError           **error)
{
  FILE    *file = fp;
  gint     low_input[5];
  gint     high_input[5];
  gint     low_output[5];
  gint     high_output[5];
  gdouble  gamma[5];
  gint     i;
  gint     fields;
  gchar    buf[50];
  gchar   *nptr;

  g_return_val_if_fail (GIMP_IS_LEVELS_CONFIG (config), FALSE);
  g_return_val_if_fail (file != NULL, FALSE);
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

  if (! fgets (buf, sizeof (buf), file) ||
      strcmp (buf, "# GIMP Levels File\n") != 0)
    {
      g_set_error_literal (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE,
			   _("not a GIMP Levels file"));
      return FALSE;
    }

  for (i = 0; i < 5; i++)
    {
      fields = fscanf (file, "%d %d %d %d ",
                       &low_input[i],
                       &high_input[i],
                       &low_output[i],
                       &high_output[i]);

      if (fields != 4)
        goto error;

      if (! fgets (buf, 50, file))
        goto error;

      gamma[i] = g_ascii_strtod (buf, &nptr);

      if (buf == nptr || errno == ERANGE)
        goto error;
    }

  g_object_freeze_notify (G_OBJECT (config));

  for (i = 0; i < 5; i++)
    {
      config->low_input[i]   = low_input[i]   / 255.0;
      config->high_input[i]  = high_input[i]  / 255.0;
      config->low_output[i]  = low_output[i]  / 255.0;
      config->high_output[i] = high_output[i] / 255.0;
      config->gamma[i]       = gamma[i];
    }

  g_object_notify (G_OBJECT (config), "gamma");
  g_object_notify (G_OBJECT (config), "low-input");
  g_object_notify (G_OBJECT (config), "high-input");
  g_object_notify (G_OBJECT (config), "low-output");
  g_object_notify (G_OBJECT (config), "high-output");

  g_object_thaw_notify (G_OBJECT (config));

  return TRUE;

 error:
  g_set_error_literal (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE,
		       _("parse error"));
  return FALSE;
}
Exemple #20
0
static void
gwy_3d_setup_clone(GObject *source,
                   GObject *copy)
{
    Gwy3DSetup *setup, *clone;

    g_return_if_fail(GWY_IS_3D_SETUP(source));
    g_return_if_fail(GWY_IS_3D_SETUP(copy));

    setup = GWY_3D_SETUP(source);
    clone = GWY_3D_SETUP(copy);

    g_object_freeze_notify(copy);

    if (clone->projection != setup->projection) {
        clone->projection = setup->projection;
        g_object_notify(copy, "projection");
    }
    if (clone->visualization != setup->visualization) {
        clone->visualization = setup->visualization;
        g_object_notify(copy, "visualization");
    }

    if (clone->axes_visible != setup->axes_visible) {
        clone->axes_visible = setup->axes_visible;
        g_object_notify(copy, "axes-visible");
    }
    if (clone->labels_visible != setup->labels_visible) {
        clone->labels_visible = setup->labels_visible;
        g_object_notify(copy, "labels-visible");
    }

    if (clone->rotation_x != setup->rotation_x) {
        clone->rotation_x = setup->rotation_x;
        g_object_notify(copy, "rotation-x");
    }
    if (clone->rotation_y != setup->rotation_y) {
        clone->rotation_y = setup->rotation_y;
        g_object_notify(copy, "rotation-y");
    }

    if (clone->scale != setup->scale) {
        clone->scale = setup->scale;
        g_object_notify(copy, "scale");
    }
    if (clone->z_scale != setup->z_scale) {
        clone->z_scale = setup->z_scale;
        g_object_notify(copy, "z-scale");
    }

    if (clone->light_phi != setup->light_phi) {
        clone->light_phi = setup->light_phi;
        g_object_notify(copy, "light-phi");
    }
    if (clone->light_theta != setup->light_theta) {
        clone->light_theta = setup->light_theta;
        g_object_notify(copy, "light-theta");
    }

    g_object_thaw_notify(copy);
}
/**
 * gvir_config_domain_set_description:
 * @domain: a #GVirConfigDomain
 * @description: (allow-none):
 */
void gvir_config_domain_set_description(GVirConfigDomain *domain, const char *description)
{
    gvir_config_object_set_node_content(GVIR_CONFIG_OBJECT(domain),
                                        "description", description);
    g_object_notify(G_OBJECT(domain), "description");
}
Exemple #22
0
static GConverterResult
g_zlib_decompressor_convert (GConverter *converter,
			     const void *inbuf,
			     gsize       inbuf_size,
			     void       *outbuf,
			     gsize       outbuf_size,
			     GConverterFlags flags,
			     gsize      *bytes_read,
			     gsize      *bytes_written,
			     GError    **error)
{
  GZlibDecompressor *decompressor;
  int res;

  decompressor = G_ZLIB_DECOMPRESSOR (converter);

  decompressor->zstream.next_in = (void *)inbuf;
  decompressor->zstream.avail_in = inbuf_size;

  decompressor->zstream.next_out = outbuf;
  decompressor->zstream.avail_out = outbuf_size;

  res = inflate (&decompressor->zstream, Z_NO_FLUSH);

  if (res == Z_DATA_ERROR || res == Z_NEED_DICT)
    {
      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA,
			   _("Invalid compressed data"));
      return G_CONVERTER_ERROR;
    }

  if (res == Z_MEM_ERROR)
    {
      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
			   _("Not enough memory"));
      return G_CONVERTER_ERROR;
    }

    if (res == Z_STREAM_ERROR)
    {
      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
		   _("Internal error: %s"), decompressor->zstream.msg);
      return G_CONVERTER_ERROR;
    }

    if (res == Z_BUF_ERROR)
      {
	if (flags & G_CONVERTER_FLUSH)
	  return G_CONVERTER_FLUSHED;

	/* Z_FINISH not set, so this means no progress could be made */
	/* We do have output space, so this should only happen if we
	   have no input but need some */

	g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_PARTIAL_INPUT,
			     _("Need more input"));
	return G_CONVERTER_ERROR;
      }

  g_assert (res == Z_OK || res == Z_STREAM_END);

  *bytes_read = inbuf_size - decompressor->zstream.avail_in;
  *bytes_written = outbuf_size - decompressor->zstream.avail_out;

#if !defined (G_OS_WIN32) || ZLIB_VERNUM >= 0x1240
  if (decompressor->header_data != NULL &&
      decompressor->header_data->gzheader.done == 1)
    {
      HeaderData *data = decompressor->header_data;

      /* So we don't notify again */
      data->gzheader.done = 2;

      data->file_info = g_file_info_new ();
      g_file_info_set_attribute_uint64 (data->file_info,
                                        G_FILE_ATTRIBUTE_TIME_MODIFIED,
                                        data->gzheader.time);
      g_file_info_set_attribute_uint32 (data->file_info,
                                        G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC,
                                        0);

      if (data->filename[0] != '\0')
        g_file_info_set_attribute_byte_string (data->file_info,
                                               G_FILE_ATTRIBUTE_STANDARD_NAME,
                                               data->filename);

      g_object_notify (G_OBJECT (decompressor), "file-info");
    }
#endif /* !G_OS_WIN32 || ZLIB >= 1.2.4 */

  if (res == Z_STREAM_END)
    return G_CONVERTER_FINISHED;
  return G_CONVERTER_CONVERTED;
}
void gvir_config_domain_set_vcpus(GVirConfigDomain *domain, guint64 vcpu_count)
{
    gvir_config_object_set_node_content_uint64(GVIR_CONFIG_OBJECT(domain),
                                               "vcpu", vcpu_count);
    g_object_notify(G_OBJECT(domain), "vcpu");
}
static void
browse_cb (GrlMediaSource *source,
           guint           browse_id,
           GrlMedia       *media,
           guint           remaining,
           gpointer        userdata,
           const GError   *error)
{
  MexGriloFeed *feed = (MexGriloFeed *) userdata;
  MexGriloFeedPrivate *priv = feed->priv;
  MexGriloProgram *program;

  if (error) {
    g_warning ("Error browsing: %s", error->message);
    return;
  }

  if (priv->op == NULL) {
    g_warning ("No operation found");
    return;
  }

  if (priv->op->op_id != browse_id)
    return;

  if (media) {
    /*
     * FIXME: talk to thomas/lionel/grilo guys about that crasher. We are
     * being called with what seems to be an invalid media when cancelled.
     * this is obviously temporary to enable people to work in the meantime
     */
    gconstpointer foo = grl_media_get_id (media);
    if (!foo) {
      const gchar *source_name;

      source_name =
        grl_metadata_source_get_name (GRL_METADATA_SOURCE (priv->source));
      g_warning ("FIXME: oh no, a grilo bug! (on the '%s' source)",
                 source_name);
      return;
    }

    program = MEX_GRILO_PROGRAM (mex_feed_lookup (MEX_FEED (feed),
                                                  grl_media_get_id (media)));
    if (program != NULL) {
      mex_grilo_program_set_grilo_media (program, media);
      return;
    } else {
      emit_media_added (feed, media);
      g_object_unref (media);
    }
  }

  priv->op->count++;

  if (remaining == 0) {
    priv->op->op_id = 0;

    /* Emit completed signal */
    priv->completed = TRUE;
    g_object_notify (G_OBJECT (feed), "completed");
  }
}
/**
 * gimp_number_pair_entry_set_values:
 * @entry: A #GimpNumberPairEntry widget.
 * @left:  Left number in the entry.
 * @right: Right number in the entry.
 *
 * Forces setting the numbers displayed by a #GimpNumberPairEntry,
 * ignoring if the user has set his/her own value. The state of
 * user-override will not be changed.
 *
 * Since: GIMP 2.4
 **/
void
gimp_number_pair_entry_set_values (GimpNumberPairEntry *entry,
                                   gdouble              left,
                                   gdouble              right)
{
  GimpNumberPairEntryPrivate *priv;
  GimpAspectType              old_aspect;
  gdouble                     old_ratio;
  gdouble                     old_left_number;
  gdouble                     old_right_number;
  gboolean                    numbers_changed = FALSE;
  gboolean                    ratio_changed   = FALSE;

  g_return_if_fail (GIMP_IS_NUMBER_PAIR_ENTRY (entry));

  priv = GIMP_NUMBER_PAIR_ENTRY_GET_PRIVATE (entry);

  /* Store current values */

  old_left_number  = priv->left_number;
  old_right_number = priv->right_number;
  old_ratio        = gimp_number_pair_entry_get_ratio (entry);
  old_aspect       = gimp_number_pair_entry_get_aspect (entry);


  /* Freeze notification */

  g_object_freeze_notify (G_OBJECT (entry));


  /* Set the new numbers and update the entry */

  priv->left_number  = left;
  priv->right_number = right;

  g_object_notify (G_OBJECT (entry), "left-number");
  g_object_notify (G_OBJECT (entry), "right-number");

  gimp_number_pair_entry_update_text (entry);


  /* Find out what has changed */

  if (fabs (old_ratio - gimp_number_pair_entry_get_ratio (entry)) > EPSILON)
    {
      g_object_notify (G_OBJECT (entry), "ratio");

      ratio_changed = TRUE;

      if (old_aspect != gimp_number_pair_entry_get_aspect (entry))
        g_object_notify (G_OBJECT (entry), "aspect");
    }

  if (old_left_number  != priv->left_number ||
      old_right_number != priv->right_number)
    {
      numbers_changed = TRUE;
    }


  /* Thaw */

  g_object_thaw_notify (G_OBJECT (entry));


  /* Emit relevant signals */

  if (numbers_changed)
    g_signal_emit (entry, entry_signals[NUMBERS_CHANGED], 0);

  if (ratio_changed)
    g_signal_emit (entry, entry_signals[RATIO_CHANGED], 0);
}
Exemple #26
0
static void
gtk_cell_view_set_property (GObject      *object,
                            guint         param_id,
                            const GValue *value,
                            GParamSpec   *pspec)
{
  GtkCellView *view = GTK_CELL_VIEW (object);
  GtkCellViewPrivate *priv = view->priv;
  GtkCellArea *area;
  GtkCellAreaContext *context;

  switch (param_id)
    {
    case PROP_ORIENTATION:
      priv->orientation = g_value_get_enum (value);
      if (priv->context)
        gtk_cell_area_context_reset (priv->context);

      _gtk_orientable_set_style_classes (GTK_ORIENTABLE (object));
      break;
    case PROP_BACKGROUND:
      {
        GdkRGBA color;

	if (!g_value_get_string (value))
          gtk_cell_view_set_background_rgba (view, NULL);
	else if (gdk_rgba_parse (&color, g_value_get_string (value)))
          gtk_cell_view_set_background_rgba (view, &color);
	else
	  g_warning ("Don't know color `%s'", g_value_get_string (value));

        g_object_notify (object, "background-rgba");
        g_object_notify (object, "background-gdk");
      }
      break;
    case PROP_BACKGROUND_GDK:
      {
        GdkColor *color;
        GdkRGBA rgba;

        color = g_value_get_boxed (value);

        rgba.red = color->red / 65535.0;
        rgba.green = color->green / 65535.0;
        rgba.blue = color->blue / 65535.0;
        rgba.alpha = 1.0;

        gtk_cell_view_set_background_rgba (view, &rgba);
      }
      break;
    case PROP_BACKGROUND_RGBA:
      gtk_cell_view_set_background_rgba (view, g_value_get_boxed (value));
      break;
    case PROP_BACKGROUND_SET:
      view->priv->background_set = g_value_get_boolean (value);
      break;
    case PROP_MODEL:
      gtk_cell_view_set_model (view, g_value_get_object (value));
      break;
    case PROP_CELL_AREA:
      /* Construct-only, can only be assigned once */
      area = g_value_get_object (value);

      if (area)
        {
          if (priv->area != NULL)
            {
              g_warning ("cell-area has already been set, ignoring construct property");
              g_object_ref_sink (area);
              g_object_unref (area);
            }
          else
            priv->area = g_object_ref_sink (area);
        }
      break;
    case PROP_CELL_AREA_CONTEXT:
      /* Construct-only, can only be assigned once */
      context = g_value_get_object (value);

      if (context)
        {
          if (priv->context != NULL)
            {
              g_warning ("cell-area-context has already been set, ignoring construct property");
              g_object_ref_sink (context);
              g_object_unref (context);
            }
          else
            priv->context = g_object_ref (context);
        }
      break;

    case PROP_DRAW_SENSITIVE:
      gtk_cell_view_set_draw_sensitive (view, g_value_get_boolean (value));
      break;

    case PROP_FIT_MODEL:
      gtk_cell_view_set_fit_model (view, g_value_get_boolean (value));
      break;

    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
        break;
    }
}
void gnomenu_global_menu_item_set_per_monitor_mode (GnomenuGlobalMenuItem* self, gboolean value) {
	g_return_if_fail (self != NULL);
	gnomenu_monitor_set_per_monitor_mode (self->priv->active_window_monitor, value);
	g_object_notify ((GObject *) self, "per-monitor-mode");
}
static void
goo_canvas_polyline_set_common_property (GObject              *object,
					 GooCanvasPolylineData *polyline_data,
					 guint                 prop_id,
					 const GValue         *value,
					 GParamSpec           *pspec)
{
  GooCanvasPoints *points;
  GooCanvasBounds  extent;
  gdouble x_offset, y_offset, x_scale, y_scale;
  guint i;

  switch (prop_id)
    {
    case PROP_POINTS:
      points = g_value_get_boxed (value);

      if (polyline_data->coords)
	{
	  g_slice_free1 (polyline_data->num_points * 2 * sizeof (double), polyline_data->coords);
	  polyline_data->coords = NULL;
	}

      if (!points)
	{
	  polyline_data->num_points = 0;
	}
      else
	{
	  polyline_data->num_points = points->num_points;
	  polyline_data->coords = g_slice_alloc (polyline_data->num_points * 2 * sizeof (double));
	  memcpy (polyline_data->coords, points->coords,
		  polyline_data->num_points * 2 * sizeof (double));
	}
      polyline_data->reconfigure_arrows = TRUE;
      g_object_notify (object, "x");
      g_object_notify (object, "y");
      g_object_notify (object, "width");
      g_object_notify (object, "height");
      break;
    case PROP_CLOSE_PATH:
      polyline_data->close_path = g_value_get_boolean (value);
      polyline_data->reconfigure_arrows = TRUE;
      break;
    case PROP_START_ARROW:
      polyline_data->start_arrow = g_value_get_boolean (value);
      polyline_data->reconfigure_arrows = TRUE;
      break;
    case PROP_END_ARROW:
      polyline_data->end_arrow = g_value_get_boolean (value);
      polyline_data->reconfigure_arrows = TRUE;
      break;
    case PROP_ARROW_LENGTH:
      ensure_arrow_data (polyline_data);
      polyline_data->arrow_data->arrow_length = g_value_get_double (value);
      polyline_data->reconfigure_arrows = TRUE;
      break;
    case PROP_ARROW_WIDTH:
      ensure_arrow_data (polyline_data);
      polyline_data->arrow_data->arrow_width = g_value_get_double (value);
      polyline_data->reconfigure_arrows = TRUE;
      break;
    case PROP_ARROW_TIP_LENGTH:
      ensure_arrow_data (polyline_data);
      polyline_data->arrow_data->arrow_tip_length = g_value_get_double (value);
      polyline_data->reconfigure_arrows = TRUE;
      break;
    case PROP_X:
      if (polyline_data->num_points > 0)
        {
	  /* Calculate the x offset from the current position. */
          goo_canvas_polyline_get_extent (polyline_data, &extent);
          x_offset = g_value_get_double (value) - extent.x1;

	  /* Add the offset to all the x coordinates. */
          for (i = 0; i < polyline_data->num_points; i++)
            polyline_data->coords[2 * i] += x_offset;

          g_object_notify (object, "points");
        }
      break;
    case PROP_Y:
      if (polyline_data->num_points > 0)
        {
	  /* Calculate the y offset from the current position. */
          goo_canvas_polyline_get_extent (polyline_data, &extent);
          y_offset = g_value_get_double (value) - extent.y1;

	  /* Add the offset to all the y coordinates. */
          for (i = 0; i < polyline_data->num_points; i++)
            polyline_data->coords[2 * i + 1] += y_offset;

          g_object_notify (object, "points");
        }
      break;
    case PROP_WIDTH:
      if (polyline_data->num_points >= 2)
        {
          goo_canvas_polyline_get_extent (polyline_data, &extent);
          if (extent.x2 - extent.x1 != 0.0)
            {
	      /* Calculate the amount to scale the polyline. */
              x_scale = g_value_get_double (value) / (extent.x2 - extent.x1);

	      /* Scale the x coordinates, relative to the left-most point. */
              for (i = 0; i < polyline_data->num_points; i++)
                polyline_data->coords[2 * i] = extent.x1 + (polyline_data->coords[2 * i] - extent.x1) * x_scale;

              g_object_notify (object, "points");
            }
        }
      break;
    case PROP_HEIGHT:
      if (polyline_data->num_points >= 2)
        {
          goo_canvas_polyline_get_extent (polyline_data, &extent);
          if (extent.y2 - extent.y1 != 0.0)
            {
	      /* Calculate the amount to scale the polyline. */
              y_scale = g_value_get_double (value) / (extent.y2 - extent.y1);

	      /* Scale the y coordinates, relative to the top-most point. */
              for (i = 0; i < polyline_data->num_points; i++)
                polyline_data->coords[2 * i + 1] = extent.y1 + (polyline_data->coords[2 * i + 1] - extent.y1) * y_scale;

              g_object_notify (object, "points");
            }
        }
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
  }
}
static GstFlowReturn
gst_selector_pad_chain (GstPad * pad, GstBuffer * buf)
{
  GstInputSelector *sel;
  GstFlowReturn res;
  GstPad *active_sinkpad;
  GstPad *prev_active_sinkpad;
  GstSelectorPad *selpad;
  GstClockTime start_time;
  GstSegment *seg;
  GstEvent *close_event = NULL, *start_event = NULL;
  GstCaps *caps;

  sel = GST_INPUT_SELECTOR (gst_pad_get_parent (pad));
  selpad = GST_SELECTOR_PAD_CAST (pad);
  seg = &selpad->segment;

  GST_INPUT_SELECTOR_LOCK (sel);
  /* wait or check for flushing */
  if (gst_input_selector_wait (sel, pad))
    goto flushing;

  GST_LOG_OBJECT (pad, "getting active pad");

  prev_active_sinkpad = sel->active_sinkpad;
  active_sinkpad = gst_input_selector_activate_sinkpad (sel, pad);

  /* update the segment on the srcpad */
  start_time = GST_BUFFER_TIMESTAMP (buf);
  if (GST_CLOCK_TIME_IS_VALID (start_time)) {
    GST_LOG_OBJECT (pad, "received start time %" GST_TIME_FORMAT,
        GST_TIME_ARGS (start_time));
    if (GST_BUFFER_DURATION_IS_VALID (buf))
      GST_LOG_OBJECT (pad, "received end time %" GST_TIME_FORMAT,
          GST_TIME_ARGS (start_time + GST_BUFFER_DURATION (buf)));

    GST_OBJECT_LOCK (pad);
    gst_segment_set_last_stop (seg, seg->format, start_time);
    GST_OBJECT_UNLOCK (pad);
  }

  /* Ignore buffers from pads except the selected one */
  if (pad != active_sinkpad)
    goto ignore;

  if (G_UNLIKELY (sel->pending_close)) {
    GstSegment *cseg = &sel->segment;

    GST_DEBUG_OBJECT (sel,
        "pushing close NEWSEGMENT update %d, rate %lf, applied rate %lf, "
        "format %d, "
        "%" G_GINT64_FORMAT " -- %" G_GINT64_FORMAT ", time %"
        G_GINT64_FORMAT, TRUE, cseg->rate, cseg->applied_rate, cseg->format,
        cseg->start, cseg->stop, cseg->time);

    /* create update segment */
    close_event = gst_event_new_new_segment_full (TRUE, cseg->rate,
        cseg->applied_rate, cseg->format, cseg->start, cseg->stop, cseg->time);

    sel->pending_close = FALSE;
  }
  /* if we have a pending segment, push it out now */
  if (G_UNLIKELY (selpad->segment_pending)) {
    GST_DEBUG_OBJECT (pad,
        "pushing pending NEWSEGMENT update %d, rate %lf, applied rate %lf, "
        "format %d, "
        "%" G_GINT64_FORMAT " -- %" G_GINT64_FORMAT ", time %"
        G_GINT64_FORMAT, FALSE, seg->rate, seg->applied_rate, seg->format,
        seg->start, seg->stop, seg->time);

    start_event = gst_event_new_new_segment_full (FALSE, seg->rate,
        seg->applied_rate, seg->format, seg->start, seg->stop, seg->time);

    selpad->segment_pending = FALSE;
  }
  GST_INPUT_SELECTOR_UNLOCK (sel);

  if (prev_active_sinkpad != active_sinkpad && pad == active_sinkpad)
    g_object_notify (G_OBJECT (sel), "active-pad");

  if (close_event)
    gst_pad_push_event (sel->srcpad, close_event);

  if (start_event)
    gst_pad_push_event (sel->srcpad, start_event);

  if (selpad->discont) {
    buf = gst_buffer_make_metadata_writable (buf);

    GST_DEBUG_OBJECT (pad, "Marking discont buffer %p", buf);
    GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
    selpad->discont = FALSE;
  }

  /* forward */
  GST_LOG_OBJECT (pad, "Forwarding buffer %p", buf);

  if ((caps = GST_BUFFER_CAPS (buf))) {
    if (GST_PAD_CAPS (sel->srcpad) != caps)
      gst_pad_set_caps (sel->srcpad, caps);
  }

  res = gst_pad_push (sel->srcpad, buf);

done:
  gst_object_unref (sel);
  return res;

  /* dropped buffers */
ignore:
  {
    GST_DEBUG_OBJECT (pad, "Pad not active, discard buffer %p", buf);
    /* when we drop a buffer, we're creating a discont on this pad */
    selpad->discont = TRUE;
    GST_INPUT_SELECTOR_UNLOCK (sel);
    gst_buffer_unref (buf);

    /* figure out what to return upstream */
    GST_OBJECT_LOCK (selpad);
    if (selpad->always_ok)
      res = GST_FLOW_OK;
    else
      res = GST_FLOW_NOT_LINKED;
    GST_OBJECT_UNLOCK (selpad);

    goto done;
  }
flushing:
  {
    GST_DEBUG_OBJECT (pad, "We are flushing, discard buffer %p", buf);
    GST_INPUT_SELECTOR_UNLOCK (sel);
    gst_buffer_unref (buf);
    res = GST_FLOW_WRONG_STATE;
    goto done;
  }
}
Exemple #30
0
gboolean
gimp_levels_config_load_cruft (GimpLevelsConfig  *config,
                               GInputStream      *input,
                               GError           **error)
{
  GDataInputStream *data_input;
  gint              low_input[5];
  gint              high_input[5];
  gint              low_output[5];
  gint              high_output[5];
  gdouble           gamma[5];
  gchar            *line;
  gsize             line_len;
  gint              i;

  g_return_val_if_fail (GIMP_IS_LEVELS_CONFIG (config), FALSE);
  g_return_val_if_fail (G_IS_INPUT_STREAM (input), FALSE);
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

  data_input = g_data_input_stream_new (input);

  line_len = 64;
  line = g_data_input_stream_read_line (data_input, &line_len,
                                        NULL, error);
  if (! line)
    return FALSE;

  if (strcmp (line, "# GIMP Levels File") != 0)
    {
      g_set_error_literal (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE,
                           _("not a GIMP Levels file"));
      g_object_unref (data_input);
      g_free (line);
      return FALSE;
    }

  g_free (line);

  for (i = 0; i < 5; i++)
    {
      gchar  float_buf[32];
      gchar *endp;
      gint   fields;

      line_len = 64;
      line = g_data_input_stream_read_line (data_input, &line_len,
                                            NULL, error);
      if (! line)
        {
          g_object_unref (data_input);
          return FALSE;
        }

      fields = sscanf (line, "%d %d %d %d %31s",
                       &low_input[i],
                       &high_input[i],
                       &low_output[i],
                       &high_output[i],
                       float_buf);

      g_free (line);

      if (fields != 5)
        goto error;

      gamma[i] = g_ascii_strtod (float_buf, &endp);

      if (endp == float_buf || errno == ERANGE)
        goto error;
    }

  g_object_unref (data_input);

  g_object_freeze_notify (G_OBJECT (config));

  for (i = 0; i < 5; i++)
    {
      config->low_input[i]   = low_input[i]   / 255.0;
      config->high_input[i]  = high_input[i]  / 255.0;
      config->low_output[i]  = low_output[i]  / 255.0;
      config->high_output[i] = high_output[i] / 255.0;
      config->gamma[i]       = gamma[i];
    }

  g_object_notify (G_OBJECT (config), "gamma");
  g_object_notify (G_OBJECT (config), "low-input");
  g_object_notify (G_OBJECT (config), "high-input");
  g_object_notify (G_OBJECT (config), "low-output");
  g_object_notify (G_OBJECT (config), "high-output");

  g_object_thaw_notify (G_OBJECT (config));

  return TRUE;

 error:
  g_object_unref (data_input);

  g_set_error_literal (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE,
                       _("parse error"));
  return FALSE;
}