Exemplo n.º 1
0
static void
gvc_balance_bar_set_control (GvcBalanceBar *bar, MateMixerStreamControl *control)
{
        g_return_if_fail (GVC_BALANCE_BAR (bar));
        g_return_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control));

        if (bar->priv->control != NULL) {
                g_signal_handlers_disconnect_by_func (G_OBJECT (bar->priv->control),
                                                      on_balance_value_changed,
                                                      bar);
                g_object_unref (bar->priv->control);
        }

        bar->priv->control = g_object_ref (control);

        if (bar->priv->btype == BALANCE_TYPE_LFE) {
                gdouble minimum;
                gdouble maximum;

                minimum = mate_mixer_stream_control_get_min_volume (bar->priv->control);
                maximum = mate_mixer_stream_control_get_normal_volume (bar->priv->control);

                /* Configure the adjustment for the volume limits of the current
                 * stream.
                 * Only subwoofer scale uses volume, balance and fade use fixed
                 * limits which do not need to be updated as balance type is
                 * only set during construction. */
                gtk_adjustment_configure (GTK_ADJUSTMENT (bar->priv->adjustment),
                                          gtk_adjustment_get_value (bar->priv->adjustment),
                                          minimum,
                                          maximum,
                                          (maximum - minimum) / 100.0,
                                          (maximum - minimum) / 10.0,
                                          0.0);

                bar->priv->lfe_channel = find_stream_lfe_channel (bar->priv->control);

                if (G_LIKELY (bar->priv->lfe_channel > -1))
                        g_debug ("Found LFE channel at position %d", bar->priv->lfe_channel);
                else
                        g_warn_if_reached ();
        } else
                bar->priv->lfe_channel = -1;

        switch (bar->priv->btype) {
        case BALANCE_TYPE_RL:
                g_signal_connect (G_OBJECT (bar->priv->control),
                                  "notify::balance",
                                  G_CALLBACK (on_balance_value_changed),
                                  bar);
                break;
        case BALANCE_TYPE_FR:
                g_signal_connect (G_OBJECT (bar->priv->control),
                                  "notify::fade",
                                  G_CALLBACK (on_balance_value_changed),
                                  bar);
                break;
        case BALANCE_TYPE_LFE:
                g_signal_connect (G_OBJECT (bar->priv->control),
                                  "notify::volume",
                                  G_CALLBACK (on_balance_value_changed),
                                  bar);
                break;
        }

        update_balance_value (bar);
        update_scale_marks (bar);

        g_object_notify_by_pspec (G_OBJECT (bar), properties[PROP_CONTROL]);
}
Exemplo n.º 2
0
void
gimp_viewable_dialog_set_viewable (GimpViewableDialog *dialog,
                                   GimpViewable       *viewable,
                                   GimpContext        *context)
{
  g_return_if_fail (GIMP_IS_VIEWABLE_DIALOG (dialog));
  g_return_if_fail (viewable == NULL || GIMP_IS_VIEWABLE (viewable));
  g_return_if_fail (context == NULL || GIMP_IS_CONTEXT (context));

  dialog->context = context;

  if (dialog->view)
    {
      GimpViewable *old_viewable = GIMP_VIEW (dialog->view)->viewable;

      if (viewable == old_viewable)
        {
          gimp_view_renderer_set_context (GIMP_VIEW (dialog->view)->renderer,
                                          context);
          return;
        }

      gtk_widget_destroy (dialog->view);

      if (old_viewable)
        {
          g_signal_handlers_disconnect_by_func (old_viewable,
                                                gimp_viewable_dialog_name_changed,
                                                dialog);

          g_signal_handlers_disconnect_by_func (old_viewable,
                                                gimp_viewable_dialog_close,
                                                dialog);
        }
    }

  if (viewable)
    {
      GtkWidget *box;

      g_signal_connect_object (viewable,
                               GIMP_VIEWABLE_GET_CLASS (viewable)->name_changed_signal,
                               G_CALLBACK (gimp_viewable_dialog_name_changed),
                               dialog,
                               0);

      box = gtk_widget_get_parent (dialog->icon);

      dialog->view = gimp_view_new (context, viewable, 32, 1, TRUE);
      gtk_box_pack_end (GTK_BOX (box), dialog->view, FALSE, FALSE, 2);
      gtk_widget_show (dialog->view);

      g_object_add_weak_pointer (G_OBJECT (dialog->view),
                                 (gpointer) &dialog->view);

      gimp_viewable_dialog_name_changed (GIMP_OBJECT (viewable), dialog);

      if (GIMP_IS_ITEM (viewable))
        {
          g_signal_connect_object (viewable, "removed",
                                   G_CALLBACK (gimp_viewable_dialog_close),
                                   dialog,
                                   G_CONNECT_SWAPPED);
        }
      else
        {
          g_signal_connect_object (viewable, "disconnect",
                                   G_CALLBACK (gimp_viewable_dialog_close),
                                   dialog,
                                   G_CONNECT_SWAPPED);
        }
    }
}
Exemplo n.º 3
0
static void
gdaui_cloud_set_property (GObject *object,
			  guint param_id,
			  const GValue *value,
			  GParamSpec *pspec)
{
	GdauiCloud *cloud;
	GdaDataModel *model;
	
	cloud = GDAUI_CLOUD (object);
	
	switch (param_id) {
	case PROP_MODEL:
		model = (GdaDataModel*) g_value_get_object (value);
		if (cloud->priv->model != model) {
			if (cloud->priv->iter) {
				g_object_unref (cloud->priv->iter);
				cloud->priv->iter = NULL;
			}
			if (cloud->priv->model) {
				g_signal_handlers_disconnect_by_func (cloud->priv->model,
								      G_CALLBACK (model_reset_cb), cloud);
				g_object_unref (cloud->priv->model);
			}
			cloud->priv->model = model;
			if (model) {
				g_signal_connect (model, "reset",
						  G_CALLBACK (model_reset_cb), cloud);
				g_object_ref (G_OBJECT (model));
			}
			update_display (cloud);
		}
		break;
	case PROP_LABEL_COLUMN:
		if (cloud->priv->label_column !=  g_value_get_int (value)) {
			cloud->priv->label_column = g_value_get_int (value);
			update_display (cloud);
		}
		break;
	case PROP_WEIGHT_COLUMN:
		if (cloud->priv->weight_column !=  g_value_get_int (value)) {
			cloud->priv->weight_column = g_value_get_int (value);
			update_display (cloud);
		}
		break;
	case PROP_MIN_SCALE:
		if (cloud->priv->min_scale !=  g_value_get_double (value)) {
			cloud->priv->min_scale = g_value_get_double (value);
			update_display (cloud);
		}
		break;
	case PROP_MAX_SCALE:
		if (cloud->priv->max_scale !=  g_value_get_double (value)) {
			cloud->priv->max_scale = g_value_get_double (value);
			update_display (cloud);
		}
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
		break;
	}
}
Exemplo n.º 4
0
static void
g_union_volume_monitor_remove_monitor (GUnionVolumeMonitor *union_monitor,
                                       GVolumeMonitor      *child_monitor)
{
  GList *l;

  l = g_list_find (union_monitor->monitors, child_monitor);
  if (l == NULL)
    return;

  union_monitor->monitors = g_list_delete_link (union_monitor->monitors, l);

  g_signal_handlers_disconnect_by_func (child_monitor, child_volume_added, union_monitor);
  g_signal_handlers_disconnect_by_func (child_monitor, child_volume_removed, union_monitor);
  g_signal_handlers_disconnect_by_func (child_monitor, child_volume_changed, union_monitor);
  g_signal_handlers_disconnect_by_func (child_monitor, child_mount_added, union_monitor);
  g_signal_handlers_disconnect_by_func (child_monitor, child_mount_removed, union_monitor);
  g_signal_handlers_disconnect_by_func (child_monitor, child_mount_pre_unmount, union_monitor);
  g_signal_handlers_disconnect_by_func (child_monitor, child_mount_changed, union_monitor);
  g_signal_handlers_disconnect_by_func (child_monitor, child_drive_connected, union_monitor);
  g_signal_handlers_disconnect_by_func (child_monitor, child_drive_disconnected, union_monitor);
  g_signal_handlers_disconnect_by_func (child_monitor, child_drive_changed, union_monitor);
  g_signal_handlers_disconnect_by_func (child_monitor, child_drive_eject_button, union_monitor);
  g_signal_handlers_disconnect_by_func (child_monitor, child_drive_stop_button, union_monitor);
}
/*
 * Create a demux element, run a test using the input data and check
 * the output data
 */
void
gst_adaptive_demux_test_run (const gchar * element_name,
    const gchar * manifest_uri,
    const GstAdaptiveDemuxTestCallbacks * callbacks, gpointer user_data)
{
  GstBus *bus;
  GstElement *demux;
  GstElement *manifest_source;
  gboolean ret;
  GstStateChangeReturn stateChange;
  GstAdaptiveDemuxTestEnginePrivate *priv;

  priv = g_slice_new0 (GstAdaptiveDemuxTestEnginePrivate);
  priv->engine.output_streams =
      g_ptr_array_new_with_free_func
      (adaptive_demux_engine_stream_state_finalize);
  g_mutex_init (&priv->engine.lock);
  priv->callbacks = callbacks;
  priv->user_data = user_data;
  priv->engine.loop = g_main_loop_new (NULL, TRUE);
  fail_unless (priv->engine.loop != NULL);
  GST_TEST_LOCK (priv);
  priv->engine.pipeline = gst_pipeline_new ("pipeline");
  fail_unless (priv->engine.pipeline != NULL);
  GST_DEBUG ("created pipeline %" GST_PTR_FORMAT, priv->engine.pipeline);

  /* register a callback to listen for error messages */
  bus = gst_pipeline_get_bus (GST_PIPELINE (priv->engine.pipeline));
  gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH);
  g_signal_connect (bus, "message::error",
      G_CALLBACK (on_ErrorMessageOnBus), priv);

  manifest_source =
      gst_element_make_from_uri (GST_URI_SRC, manifest_uri, NULL, NULL);
  fail_unless (manifest_source != NULL);
  priv->engine.manifest_source = manifest_source;

  demux = gst_check_setup_element (element_name);
  fail_unless (demux != NULL);
  priv->engine.demux = demux;
  GST_DEBUG ("created demux %" GST_PTR_FORMAT, demux);

  g_signal_connect (demux, "element-added", G_CALLBACK (on_demuxElementAdded),
      priv);
  g_signal_connect (demux, "pad-added", G_CALLBACK (on_demuxNewPad), priv);
  g_signal_connect (demux, "pad-removed",
      G_CALLBACK (on_demuxPadRemoved), priv);

  gst_bin_add_many (GST_BIN (priv->engine.pipeline), manifest_source, demux,
      NULL);
  ASSERT_OBJECT_REFCOUNT (manifest_source, element_name, 1);
  ASSERT_OBJECT_REFCOUNT (demux, element_name, 1);

  ret = gst_element_link (manifest_source, demux);
  fail_unless_equals_int (ret, TRUE);

  priv->engine.clock = gst_system_clock_obtain ();
  if (GST_IS_TEST_CLOCK (priv->engine.clock)) {
    /*
     * live tests will want to manipulate the clock, so they will register a
     * gst_test_clock as the system clock.
     * The on demand tests do not care about the clock, so they will let the
     * system clock to the default one.
     * If a gst_test_clock was installed as system clock, we register a
     * periodic callback to update its value.
     */
    priv->clock_update_id =
        g_timeout_add (100, gst_adaptive_demux_update_test_clock, priv);
  }

  /* call a test callback before we start the pipeline */
  if (callbacks->pre_test)
    (*callbacks->pre_test) (&priv->engine, priv->user_data);

  GST_TEST_UNLOCK (priv);

  GST_DEBUG ("Starting pipeline");
  stateChange = gst_element_set_state (priv->engine.pipeline, GST_STATE_PAUSED);
  fail_unless (stateChange != GST_STATE_CHANGE_FAILURE);
  /* wait for completion of the move to PAUSED */
  stateChange = gst_element_get_state (priv->engine.pipeline, NULL, NULL,
      GST_CLOCK_TIME_NONE);
  fail_unless (stateChange != GST_STATE_CHANGE_FAILURE);

  g_idle_add ((GSourceFunc) start_pipeline_playing, priv);

  /* block until a callback calls g_main_loop_quit (engine.loop) */
  GST_DEBUG ("main thread waiting for streams to finish");
  g_main_loop_run (priv->engine.loop);
  GST_DEBUG ("main thread finished. Stopping pipeline");

  /* no need to use gst_element_get_state as the move the GST_STATE_NULL
     is always synchronous */
  stateChange = gst_element_set_state (priv->engine.pipeline, GST_STATE_NULL);
  fail_unless (stateChange != GST_STATE_CHANGE_FAILURE);

  GST_TEST_LOCK (priv);

  /* call a test callback after the stop of the pipeline */
  if (callbacks->post_test)
    (*callbacks->post_test) (&priv->engine, priv->user_data);

  g_signal_handlers_disconnect_by_func (bus,
      G_CALLBACK (on_ErrorMessageOnBus), priv);
  gst_bus_remove_signal_watch (bus);
  g_signal_handlers_disconnect_by_func (demux, G_CALLBACK (on_demuxNewPad),
      priv);
  g_signal_handlers_disconnect_by_func (demux, G_CALLBACK (on_demuxPadRemoved),
      priv);

  GST_DEBUG ("main thread pipeline stopped");
  if (priv->clock_update_id != 0)
    g_source_remove (priv->clock_update_id);
  gst_object_unref (priv->engine.clock);
  gst_object_unref (priv->engine.pipeline);
  priv->engine.pipeline = NULL;
  g_main_loop_unref (priv->engine.loop);
  g_ptr_array_unref (priv->engine.output_streams);
  gst_object_unref (bus);

  GST_TEST_UNLOCK (priv);
  g_mutex_clear (&priv->engine.lock);
  g_slice_free (GstAdaptiveDemuxTestEnginePrivate, priv);
}
static void
hippo_canvas_block_netflix_movie_set_block(HippoCanvasBlock *canvas_block,
                                           HippoBlock       *block)
{
    HippoCanvasBlockNetflixMovie *block_netflix = HIPPO_CANVAS_BLOCK_NETFLIX_MOVIE(canvas_block);

    if (block == canvas_block->block)
        return;

    if (canvas_block->block != NULL) {
        g_signal_handlers_disconnect_by_func(G_OBJECT(canvas_block->block),
                                             G_CALLBACK(on_user_changed),
                                             canvas_block);
        g_signal_handlers_disconnect_by_func(G_OBJECT(canvas_block->block),
                                             G_CALLBACK(on_block_description_changed),
                                             canvas_block);                                             
        g_signal_handlers_disconnect_by_func(G_OBJECT(canvas_block->block),
                                             G_CALLBACK(on_block_chat_id_changed),
                                             canvas_block);
        g_signal_handlers_disconnect_by_func(G_OBJECT(canvas_block->block),
                                             G_CALLBACK(on_block_queue_changed),
                                             canvas_block);
        g_signal_handlers_disconnect_by_func(G_OBJECT(canvas_block->block),
                                             G_CALLBACK(on_block_image_url_changed),
                                             canvas_block);
        g_signal_handlers_disconnect_by_func(G_OBJECT(canvas_block->block),
                                             G_CALLBACK(on_block_title_changed),
                                             canvas_block);
        g_signal_handlers_disconnect_by_func(G_OBJECT(canvas_block->block),
                                             G_CALLBACK(on_block_title_link_changed),
                                             canvas_block);
        g_signal_handlers_disconnect_by_func(G_OBJECT(canvas_block->block),
                                             G_CALLBACK(on_block_icon_url_changed),
                                             canvas_block);
        set_person(HIPPO_CANVAS_BLOCK_NETFLIX_MOVIE(canvas_block), NULL);
    }

    /* Chain up to get the block really changed */
    HIPPO_CANVAS_BLOCK_CLASS(hippo_canvas_block_netflix_movie_parent_class)->set_block(canvas_block, block);

    g_object_set(block_netflix->quipper,
                 "block", canvas_block->block,
                 NULL);
    g_object_set(block_netflix->last_message_preview,
                 "block", canvas_block->block,
                 NULL);
    g_object_set(block_netflix->chat_preview,
                 "block", canvas_block->block,
                 NULL);
    
    if (canvas_block->block != NULL) {
        g_signal_connect(G_OBJECT(canvas_block->block),
                         "notify::user",
                         G_CALLBACK(on_user_changed),
                         canvas_block);
        g_signal_connect(G_OBJECT(canvas_block->block),
                         "notify::description",
                         G_CALLBACK(on_block_description_changed),
                         canvas_block);                         
        g_signal_connect(G_OBJECT(canvas_block->block),
                         "notify::chat-id",
                         G_CALLBACK(on_block_chat_id_changed),
                         canvas_block);
        g_signal_connect(G_OBJECT(canvas_block->block),
                         "notify::queue",
                         G_CALLBACK(on_block_queue_changed),
                         canvas_block);
        g_signal_connect(G_OBJECT(canvas_block->block),
                         "notify::image-url",
                         G_CALLBACK(on_block_image_url_changed),
                         canvas_block);
        g_signal_connect(G_OBJECT(canvas_block->block),
                         "notify::title",
                         G_CALLBACK(on_block_title_changed),
                         canvas_block);
        g_signal_connect(G_OBJECT(canvas_block->block),
                         "notify::title-link",
                         G_CALLBACK(on_block_title_link_changed),
                         canvas_block);
        g_signal_connect(G_OBJECT(canvas_block->block),
                         "notify::icon-url",
                         G_CALLBACK(on_block_icon_url_changed),
                         canvas_block);
    }

    on_user_changed(canvas_block->block, NULL, block_netflix);
    on_block_description_changed(canvas_block->block, NULL, block_netflix);
    on_block_chat_id_changed(canvas_block->block, NULL, block_netflix);
    on_block_queue_changed(canvas_block->block, NULL, block_netflix);
    on_block_image_url_changed(canvas_block->block, NULL, block_netflix);
    on_block_title_changed(canvas_block->block, NULL, block_netflix);
    on_block_title_link_changed(canvas_block->block, NULL, block_netflix);
    on_block_icon_url_changed(canvas_block->block, NULL, block_netflix);
}
Exemplo n.º 7
0
static void
process_config_entries (GoaDaemon  *daemon,
                        GHashTable *group_name_to_key_file_data)
{
  GHashTableIter iter;
  const gchar *id;
  KeyFileData *key_file_data;
  GList *existing_object_paths;
  GList *config_object_paths;
  GList *added;
  GList *removed;
  GList *unchanged;
  GList *l;

  existing_object_paths = NULL;
  {
    GList *existing_objects;
    existing_objects = g_dbus_object_manager_get_objects (G_DBUS_OBJECT_MANAGER (daemon->object_manager));
    for (l = existing_objects; l != NULL; l = l->next)
      {
        GoaObject *object = GOA_OBJECT (l->data);
        const gchar *object_path;
        object_path = g_dbus_object_get_object_path (G_DBUS_OBJECT (object));
        if (g_str_has_prefix (object_path, "/org/gnome/OnlineAccounts/Accounts/"))
          existing_object_paths = g_list_prepend (existing_object_paths, g_strdup (object_path));
      }
    g_list_foreach (existing_objects, (GFunc) g_object_unref, NULL);
    g_list_free (existing_objects);
  }

  config_object_paths = NULL;
  g_hash_table_iter_init (&iter, group_name_to_key_file_data);
  while (g_hash_table_iter_next (&iter, (gpointer*) &id, (gpointer*) &key_file_data))
    {
      gchar *object_path;

      /* create and validate object path */
      object_path = g_strdup_printf ("/org/gnome/OnlineAccounts/Accounts/%s", id + sizeof "Account " - 1);
      if (strstr (id + sizeof "Account " - 1, "/") != NULL || !g_variant_is_object_path (object_path))
        {
          g_warning ("`%s' is not a valid account identifier", id);
          g_free (object_path);
          continue;
        }
      /* steals object_path variable */
      config_object_paths = g_list_prepend (config_object_paths, object_path);
    }

  existing_object_paths = g_list_sort (existing_object_paths, (GCompareFunc) g_strcmp0);
  config_object_paths = g_list_sort (config_object_paths, (GCompareFunc) g_strcmp0);
  diff_sorted_lists (existing_object_paths,
                     config_object_paths,
                     (GCompareFunc) g_strcmp0,
                     &added,
                     &removed,
                     &unchanged);

  for (l = removed; l != NULL; l = l->next)
    {
      const gchar *object_path = l->data;
      GoaObject *object;
      object = GOA_OBJECT (g_dbus_object_manager_get_object (G_DBUS_OBJECT_MANAGER (daemon->object_manager), object_path));
      g_warn_if_fail (object != NULL);
      g_signal_handlers_disconnect_by_func (goa_object_peek_account (object),
                                            G_CALLBACK (on_account_handle_remove),
                                            daemon);
      g_debug ("removing %s", object_path);
      g_warn_if_fail (g_dbus_object_manager_server_unexport (daemon->object_manager, object_path));
    }
  for (l = added; l != NULL; l = l->next)
    {
      const gchar *object_path = l->data;
      GoaObjectSkeleton *object;
      gchar *group;

      g_debug ("adding %s", object_path);

      group = object_path_to_group (object_path);
      key_file_data = g_hash_table_lookup (group_name_to_key_file_data, group);
      g_warn_if_fail (key_file_data != NULL);

      object = goa_object_skeleton_new (object_path);
      if (update_account_object (daemon,
                                 object,
                                 key_file_data->path,
                                 group,
                                 key_file_data->key_file,
                                 TRUE))
        {
          g_dbus_object_manager_server_export (daemon->object_manager, G_DBUS_OBJECT_SKELETON (object));
          g_signal_connect (goa_object_peek_account (GOA_OBJECT (object)),
                            "handle-remove",
                            G_CALLBACK (on_account_handle_remove),
                            daemon);
          g_signal_connect (goa_object_peek_account (GOA_OBJECT (object)),
                            "handle-ensure-credentials",
                            G_CALLBACK (on_account_handle_ensure_credentials),
                            daemon);
        }
      g_object_unref (object);
      g_free (group);
    }
  for (l = unchanged; l != NULL; l = l->next)
    {
      const gchar *object_path = l->data;
      GoaObject *object;
      gchar *group;

      g_debug ("unchanged %s", object_path);

      group = object_path_to_group (object_path);
      key_file_data = g_hash_table_lookup (group_name_to_key_file_data, group);
      g_warn_if_fail (key_file_data != NULL);

      object = GOA_OBJECT (g_dbus_object_manager_get_object (G_DBUS_OBJECT_MANAGER (daemon->object_manager), object_path));
      g_warn_if_fail (object != NULL);
      if (!update_account_object (daemon,
                                  GOA_OBJECT_SKELETON (object),
                                  key_file_data->path,
                                  group,
                                  key_file_data->key_file,
                                  FALSE))
        {
          g_signal_handlers_disconnect_by_func (goa_object_peek_account (object),
                                                G_CALLBACK (on_account_handle_remove),
                                                daemon);
          g_signal_handlers_disconnect_by_func (goa_object_peek_account (object),
                                                G_CALLBACK (on_account_handle_ensure_credentials),
                                                daemon);
          g_warn_if_fail (g_dbus_object_manager_server_unexport (daemon->object_manager, object_path));
        }
      g_object_unref (object);
      g_free (group);
    }

  g_list_free (removed);
  g_list_free (added);
  g_list_free (unchanged);
  g_list_foreach (existing_object_paths, (GFunc) g_free, NULL);
  g_list_free (existing_object_paths);
  g_list_foreach (config_object_paths, (GFunc) g_free, NULL);
  g_list_free (config_object_paths);
}
Exemplo n.º 8
0
static gboolean on_focus_out( GtkWidget *entry, GdkEventFocus* evt, gpointer user_data )
{
    g_signal_handlers_disconnect_by_func( entry, (void*)on_changed, NULL );
    gtk_entry_set_completion( GTK_ENTRY(entry), NULL );
    return FALSE;
}
Exemplo n.º 9
0
EditorClient::~EditorClient()
{
    WebKitWebViewPrivate* priv = m_webView->priv;
    g_signal_handlers_disconnect_by_func(priv->imContext.get(), (gpointer)imContextCommitted, this);
    g_signal_handlers_disconnect_by_func(priv->imContext.get(), (gpointer)imContextPreeditChanged, this);
}
Exemplo n.º 10
0
void
gimp_display_shell_disconnect (GimpDisplayShell *shell)
{
  GimpImage         *image;
  GimpDisplayConfig *display_config;

  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
  g_return_if_fail (GIMP_IS_DISPLAY (shell->display));
  g_return_if_fail (GIMP_IS_IMAGE (shell->display->image));

  image = shell->display->image;

  display_config = GIMP_DISPLAY_CONFIG (image->gimp->config);

  if (shell->icon_idle_id)
    {
      g_source_remove (shell->icon_idle_id);
      shell->icon_idle_id = 0;
    }

  if (shell->grid_gc)
    {
      g_object_unref (shell->grid_gc);
      shell->grid_gc = NULL;
    }

  if (shell->pen_gc)
    {
      g_object_unref (shell->pen_gc);
      shell->pen_gc = NULL;
    }

  g_signal_handlers_disconnect_by_func (image->gimp->config,
                                        gimp_display_shell_quality_notify_handler,
                                        shell);
  g_signal_handlers_disconnect_by_func (image->gimp->config,
                                        gimp_display_shell_ants_speed_notify_handler,
                                        shell);
  g_signal_handlers_disconnect_by_func (display_config->default_fullscreen_view,
                                        gimp_display_shell_padding_notify_handler,
                                        shell);
  g_signal_handlers_disconnect_by_func (display_config->default_view,
                                        gimp_display_shell_padding_notify_handler,
                                        shell);
  g_signal_handlers_disconnect_by_func (image->gimp->config,
                                        gimp_display_shell_monitor_res_notify_handler,
                                        shell);
  g_signal_handlers_disconnect_by_func (image->gimp->config,
                                        gimp_display_shell_nav_size_notify_handler,
                                        shell);
  g_signal_handlers_disconnect_by_func (image->gimp->config,
                                        gimp_display_shell_title_notify_handler,
                                        shell);
  g_signal_handlers_disconnect_by_func (image->gimp->config,
                                        gimp_display_shell_check_notify_handler,
                                        shell);

  g_signal_handlers_disconnect_by_func (image->vectors,
                                        gimp_display_shell_vectors_remove_handler,
                                        shell);
  g_signal_handlers_disconnect_by_func (image->vectors,
                                        gimp_display_shell_vectors_add_handler,
                                        shell);

  gimp_container_remove_handler (image->vectors,
                                 shell->vectors_visible_handler);
  gimp_container_remove_handler (image->vectors,
                                 shell->vectors_thaw_handler);
  gimp_container_remove_handler (image->vectors,
                                 shell->vectors_freeze_handler);

  g_signal_handlers_disconnect_by_func (image,
                                        gimp_display_shell_profile_changed_handler,
                                        shell);
  g_signal_handlers_disconnect_by_func (image,
                                        gimp_display_shell_invalidate_preview_handler,
                                        shell);
  g_signal_handlers_disconnect_by_func (image,
                                        gimp_display_shell_update_guide_handler,
                                        shell);
  g_signal_handlers_disconnect_by_func (image,
                                        gimp_display_shell_update_sample_point_handler,
                                        shell);
  g_signal_handlers_disconnect_by_func (image,
                                        gimp_display_shell_quick_mask_changed_handler,
                                        shell);
  g_signal_handlers_disconnect_by_func (image,
                                        gimp_display_shell_resolution_changed_handler,
                                        shell);
  g_signal_handlers_disconnect_by_func (image,
                                        gimp_display_shell_size_changed_handler,
                                        shell);
  g_signal_handlers_disconnect_by_func (image,
                                        gimp_display_shell_selection_control_handler,
                                        shell);
  g_signal_handlers_disconnect_by_func (image,
                                        gimp_display_shell_name_changed_handler,
                                        shell);
  g_signal_handlers_disconnect_by_func (image->grid,
                                        gimp_display_shell_grid_notify_handler,
                                        shell);
  g_signal_handlers_disconnect_by_func (image,
                                        gimp_display_shell_undo_event_handler,
                                        shell);
  g_signal_handlers_disconnect_by_func (image,
                                        gimp_display_shell_clean_dirty_handler,
                                        shell);
}
Exemplo n.º 11
0
static void fm_folder_finalize(GObject *object)
{
    FmFolder *self;
    g_return_if_fail(object != NULL);
    g_return_if_fail(FM_IS_FOLDER(object));

    self = FM_FOLDER(object);

    if(self->job)
    {
        g_signal_handlers_disconnect_by_func(self->job, on_job_finished, self);
        g_signal_handlers_disconnect_by_func(self->job, on_job_err, self);
        fm_job_cancel(FM_JOB(self->job)); /* FIXME: is this ok? */
        /* the job will be freed automatically in idle handler. */
    }

    if(self->pending_jobs)
    {
        GSList* l;
        for(l = self->pending_jobs;l;l=l->next)
        {
            FmJob* job = FM_JOB(l->data);
            g_signal_handlers_disconnect_by_func(job, on_job_finished, self);
            fm_job_cancel(job);
            /* the job will be freed automatically in idle handler. */
        }
    }

    /* remove from hash table */
    g_hash_table_remove(hash, self->dir_path);
    if(self->dir_path)
        fm_path_unref(self->dir_path);

    if(self->dir_fi)
        fm_file_info_unref(self->dir_fi);

    if(self->gf)
        g_object_unref(self->gf);

    if(self->mon)
    {
        g_signal_handlers_disconnect_by_func(self->mon, on_folder_changed, self);
        g_object_unref(self->mon);
    }

    if(self->idle_handler)
    {
        g_source_remove(self->idle_handler);
        if(self->files_to_add)
        {
            g_slist_foreach(self->files_to_add, (GFunc)g_free, NULL);
            g_slist_free(self->files_to_add);
        }
        if(self->files_to_update)
        {
            g_slist_foreach(self->files_to_update, (GFunc)g_free, NULL);
            g_slist_free(self->files_to_update);
        }
        if(self->files_to_del)
            g_slist_free(self->files_to_del);
    }

    fm_list_unref(self->files);

    if (G_OBJECT_CLASS(fm_folder_parent_class)->finalize)
        (* G_OBJECT_CLASS(fm_folder_parent_class)->finalize)(object);
}
Exemplo n.º 12
0
/**
 * mx_list_view_set_model:
 * @list_view: An #MxListView
 * @model: A #ClutterModel
 *
 * Set the model used by the #MxListView
 */
void
mx_list_view_set_model (MxListView   *list_view,
                        ClutterModel *model)
{
  MxListViewPrivate *priv;

  g_return_if_fail (MX_IS_LIST_VIEW (list_view));
  g_return_if_fail (model == NULL || CLUTTER_IS_MODEL (model));

  priv = list_view->priv;

  if (priv->model)
    {
      g_signal_handlers_disconnect_by_func (priv->model,
                                            (GCallback) model_changed_cb,
                                            list_view);
      g_signal_handlers_disconnect_by_func (priv->model,
                                            (GCallback) row_changed_cb,
                                            list_view);
      g_signal_handlers_disconnect_by_func (priv->model,
                                            (GCallback) row_removed_cb,
                                            list_view);
      g_object_unref (priv->model);

      priv->model = NULL;
    }

  if (model)
    {
      g_return_if_fail (CLUTTER_IS_MODEL (model));

      priv->model = g_object_ref (model);

      priv->filter_changed = g_signal_connect (priv->model,
                                               "filter-changed",
                                               G_CALLBACK (model_changed_cb),
                                               list_view);

      priv->row_added = g_signal_connect (priv->model,
                                          "row-added",
                                          G_CALLBACK (row_changed_cb),
                                          list_view);

      priv->row_changed = g_signal_connect (priv->model,
                                            "row-changed",
                                            G_CALLBACK (row_changed_cb),
                                            list_view);

      /*
       * model_changed_cb (called from row_changed_cb) expect the row to already
       * have been removed, thus we need to use _after
       */
      priv->row_removed = g_signal_connect_after (priv->model,
                                                  "row-removed",
                                                  G_CALLBACK (row_removed_cb),
                                                  list_view);

      priv->sort_changed = g_signal_connect (priv->model,
                                             "sort-changed",
                                             G_CALLBACK (model_changed_cb),
                                             list_view);

      /*
       * Only do this inside this block, setting the model to NULL should have
       * the effect of preserving the view; just disconnect the handlers
       */
      model_changed_cb (priv->model, list_view);
    }
}
Exemplo n.º 13
0
void
mnb_zones_preview_change_workspace (MnbZonesPreview *preview,
                                    gint             workspace)
{
  gboolean reset_anim;
  MnbZonesPreviewPrivate *priv = preview->priv;

  /* If we're already going towards this workspace, ignore */
  if ((priv->dest_workspace == workspace) && priv->anim_phase)
    return;

  /* Figure out what we need to be doing with this animation */
  switch (priv->anim_phase)
    {
    default:
    case MNB_ZP_STATIC:
      /* We weren't animating, start a new one */
      reset_anim = TRUE;
      break;

    case MNB_ZP_ZOOM_OUT:
      /* If we're on the right workspace, zoom in and finish, otherwise
       * continue the animation like normal.
       */
      if (priv->dest_workspace == workspace)
        {
          priv->anim_phase = MNB_ZP_PAN;
          reset_anim = TRUE;
        }
      else
        reset_anim = FALSE;
      break;

    case MNB_ZP_PAN:
      /* If we're heading towards the right workspace, continue the
       * animation, otherwise change direction.
       */
      if (priv->dest_workspace != workspace)
        {
          priv->anim_phase = MNB_ZP_ZOOM_OUT;
          reset_anim = TRUE;
        }
      else
        reset_anim = FALSE;
      break;

    case MNB_ZP_ZOOM_IN:
      /* Restart the animation if we're not heading towards the right
       * workspace.
       */
      if (priv->dest_workspace != workspace)
        {
          priv->anim_phase = MNB_ZP_STATIC;
          reset_anim = TRUE;
        }
      else
        reset_anim = FALSE;
      break;
    }

  priv->dest_workspace = workspace;
  if (reset_anim)
    {
      ClutterAnimation *animation =
        clutter_actor_get_animation (CLUTTER_ACTOR (preview));

      if (animation)
        g_signal_handlers_disconnect_by_func (animation,
                                              mnb_zones_preview_completed_cb,
                                              preview);

      mnb_zones_preview_completed_cb (animation, preview);
    }
}
Exemplo n.º 14
0
/**
* widget: BastileWidget that is used for display
* op: BastileOperation to disconnect
*
* Disconnect the operation_progress and the operation_done functions from the
* operation
*
**/
static void
disconnect_progress (BastileWidget *widget, BastileOperation *op)
{
    g_signal_handlers_disconnect_by_func (op, operation_progress, widget);
    g_signal_handlers_disconnect_by_func (op, operation_done, widget);
}
Exemplo n.º 15
0
/**
 * gimp_scale_entry_set_logarithmic:
 * @adjustment:  a  #GtkAdjustment as returned by gimp_scale_entry_new()
 * @logarithmic: a boolean value to set or reset logarithmic behaviour
 *               of the scale widget
 *
 * Sets whether the scale_entry's scale widget will behave in a linear
 * or logharithmic fashion. Useful when an entry has to attend large
 * ranges, but smaller selections on that range require a finer
 * adjustment.
 *
 * Since: GIMP 2.2
 **/
void
gimp_scale_entry_set_logarithmic (GtkObject *adjustment,
                                  gboolean   logarithmic)
{
  GtkAdjustment *adj;
  GtkAdjustment *scale_adj;

  g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));

  adj       = GTK_ADJUSTMENT (adjustment);
  scale_adj = GIMP_SCALE_ENTRY_SCALE_ADJ (adjustment);

  if (logarithmic == gimp_scale_entry_get_logarithmic (adjustment))
    return;

  if (logarithmic)
    {
      gdouble correction;
      gdouble log_value, log_lower, log_upper;
      gdouble log_step_increment, log_page_increment;

      correction = (gtk_adjustment_get_lower (scale_adj) > 0 ?
                    0 : 0.1 + - gtk_adjustment_get_lower (scale_adj));

      log_value = log (gtk_adjustment_get_value (scale_adj) + correction);
      log_lower = log (gtk_adjustment_get_lower (scale_adj) + correction);
      log_upper = log (gtk_adjustment_get_upper (scale_adj) + correction);
      log_step_increment =
        (log_upper - log_lower) / ((gtk_adjustment_get_upper (scale_adj) -
                                    gtk_adjustment_get_lower (scale_adj)) /
                                   gtk_adjustment_get_step_increment (scale_adj));
      log_page_increment =
        (log_upper - log_lower) / ((gtk_adjustment_get_upper (scale_adj) -
                                    gtk_adjustment_get_lower (scale_adj)) /
                                   gtk_adjustment_get_page_increment (scale_adj));

      if (scale_adj == adj)
        {
          GtkObject *new_adj;

          new_adj = gtk_adjustment_new (gtk_adjustment_get_value (scale_adj),
                                        gtk_adjustment_get_lower (scale_adj),
                                        gtk_adjustment_get_upper (scale_adj),
                                        gtk_adjustment_get_step_increment (scale_adj),
                                        gtk_adjustment_get_page_increment (scale_adj),
                                        0.0);
          gtk_range_set_adjustment (GTK_RANGE (GIMP_SCALE_ENTRY_SCALE (adj)),
                                    GTK_ADJUSTMENT (new_adj));

          scale_adj = (GtkAdjustment *) new_adj;
        }
      else
        {
          g_signal_handlers_disconnect_by_func (adj,
                                                gimp_scale_entry_unconstrained_adjustment_callback,
                                                scale_adj);

          g_signal_handlers_disconnect_by_func (scale_adj,
                                                gimp_scale_entry_unconstrained_adjustment_callback,
                                                adj);
        }

      gtk_adjustment_configure (scale_adj,
                                log_value, log_lower, log_upper,
                                log_step_increment, log_page_increment, 0.0);

      g_signal_connect (scale_adj, "value-changed",
                        G_CALLBACK (gimp_scale_entry_exp_adjustment_callback),
                        adj);

      g_signal_connect (adj, "value-changed",
                        G_CALLBACK (gimp_scale_entry_log_adjustment_callback),
                        scale_adj);

      g_object_set_data (G_OBJECT (adjustment),
                         "logarithmic", GINT_TO_POINTER (TRUE));
    }
  else
    {
      gdouble lower, upper;

      g_signal_handlers_disconnect_by_func (adj,
                                            gimp_scale_entry_log_adjustment_callback,
                                            scale_adj);

      g_signal_handlers_disconnect_by_func (scale_adj,
                                            gimp_scale_entry_exp_adjustment_callback,
                                            adj);

      lower = exp (gtk_adjustment_get_lower (scale_adj));
      upper = exp (gtk_adjustment_get_upper (scale_adj));

      if (gtk_adjustment_get_lower (adj) <= 0.0)
        {
          lower += - 0.1 + gtk_adjustment_get_lower (adj);
          upper += - 0.1 + gtk_adjustment_get_lower (adj);
        }

      gtk_adjustment_configure (scale_adj,
                                gtk_adjustment_get_value (adj),
                                lower, upper,
                                gtk_adjustment_get_step_increment (adj),
                                gtk_adjustment_get_page_increment (adj),
                                0.0);

      g_signal_connect (scale_adj, "value-changed",
                        G_CALLBACK (gimp_scale_entry_unconstrained_adjustment_callback),
                        adj);

      g_signal_connect (adj, "value-changed",
                        G_CALLBACK (gimp_scale_entry_unconstrained_adjustment_callback),
                        scale_adj);

      g_object_set_data (G_OBJECT (adjustment),
                         "logarithmic", GINT_TO_POINTER (FALSE));
    }
}
/* key routine that hooks up a background and location */
void
nautilus_connect_background_to_file_metadata (GtkWidget    *widget,
                                              NautilusFile *file,
                                              GdkDragAction default_drag_action)
{
	EelBackground *background;
	gpointer old_file;

	/* Get at the background object we'll be connecting. */
	background = eel_get_widget_background (widget);

	/* Check if it is already connected. */
	old_file = g_object_get_data (G_OBJECT (background), "eel_background_file");
	if (old_file == file) {
		return;
	}

	/* Disconnect old signal handlers. */
	if (old_file != NULL) {
		g_assert (NAUTILUS_IS_FILE (old_file));
		g_signal_handlers_disconnect_by_func
                        (background,
                         G_CALLBACK (background_changed_callback), old_file);
		g_signal_handlers_disconnect_by_func
                        (background,
                         G_CALLBACK (background_destroyed_callback), old_file);
		g_signal_handlers_disconnect_by_func
                        (background,
                         G_CALLBACK (background_reset_callback), old_file);
		g_signal_handlers_disconnect_by_func
                        (old_file,
                         G_CALLBACK (saved_settings_changed_callback), background);
		nautilus_file_monitor_remove (old_file, background);
		eel_preferences_remove_callback (NAUTILUS_PREFERENCES_THEME,
                                                 nautilus_file_background_theme_changed,
                                                 background);
		eel_preferences_remove_callback (NAUTILUS_PREFERENCES_BACKGROUND_SET,
                                                 nautilus_file_background_theme_changed,
                                                 background);
		eel_preferences_remove_callback (NAUTILUS_PREFERENCES_BACKGROUND_COLOR,
                                                 nautilus_file_background_theme_changed,
                                                 background);
		eel_preferences_remove_callback (NAUTILUS_PREFERENCES_BACKGROUND_FILENAME,
                                                 nautilus_file_background_theme_changed,
                                                 background);

	}

        /* Attach the new directory. */
        nautilus_file_ref (file);
        g_object_set_data_full (G_OBJECT (background), "eel_background_file",
                                file, (GDestroyNotify) nautilus_file_unref);

        g_object_set_data (G_OBJECT (background), "default_drag_action", GINT_TO_POINTER (default_drag_action));

        /* Connect new signal handlers. */
        if (file != NULL) {
                g_signal_connect_object (background, "settings_changed",
                                         G_CALLBACK (background_changed_callback), file, 0);
                g_signal_connect_object (background, "destroy",
                                         G_CALLBACK (background_destroyed_callback), file, 0);
                g_signal_connect_object (background, "reset",
                                         G_CALLBACK (background_reset_callback), file, 0);
		g_signal_connect_object (file, "changed",
                                         G_CALLBACK (saved_settings_changed_callback), background, 0);
        	
		/* arrange to receive file metadata */
		nautilus_file_monitor_add (file,
                                           background,
                                           NAUTILUS_FILE_ATTRIBUTE_INFO);

		/* arrange for notification when the theme changes */
		eel_preferences_add_callback (NAUTILUS_PREFERENCES_THEME,
                                              nautilus_file_background_theme_changed, background);
		eel_preferences_add_callback (NAUTILUS_PREFERENCES_BACKGROUND_SET,
                                              nautilus_file_background_theme_changed, background);
		eel_preferences_add_callback (NAUTILUS_PREFERENCES_BACKGROUND_COLOR,
                                              nautilus_file_background_theme_changed, background);
		eel_preferences_add_callback (NAUTILUS_PREFERENCES_BACKGROUND_FILENAME,
                                              nautilus_file_background_theme_changed, background);
	}

        /* Update the background based on the file metadata. */
        initialize_background_from_settings (file, background);
}
static void
carrick_list_set_model (CarrickList         *list,
                        CarrickNetworkModel *model)
{
  CarrickListPrivate *priv = list->priv;

  if (priv->model)
    {
      g_signal_handlers_disconnect_by_func (priv->model,
                                            _row_inserted_cb,
                                            list);
      g_signal_handlers_disconnect_by_func (priv->model,
                                            _row_deleted_cb,
                                            list);
      g_signal_handlers_disconnect_by_func (priv->model,
                                            _row_changed_cb,
                                            list);
      g_signal_handlers_disconnect_by_func (priv->model,
                                            _rows_reordered_cb,
                                            list);

      g_object_unref (priv->model);
      priv->model = NULL;
    }

  if (model)
    {
      DBusGProxy *manager;

      priv->model = g_object_ref (model);

      /* Keep track of OfflineMode, AvailableTechnologies and 
       * EnabledTechnologies using connman.Manager */
      manager = carrick_network_model_get_proxy (priv->model);
      dbus_g_proxy_connect_signal (manager,
                                   "PropertyChanged",
                                   G_CALLBACK (_mngr_property_changed_cb),
                                   list, NULL);
      net_connman_Manager_get_properties_async (manager,
                                                _mngr_get_properties_cb,
                                                list);

      gtk_tree_model_foreach (GTK_TREE_MODEL (model),
                              _create_service_item,
                              NULL);

      /* connect signals for changes in model */
      g_signal_connect (priv->model,
                        "row-inserted",
                        G_CALLBACK (_row_inserted_cb),
                        list);
      g_signal_connect (priv->model,
                        "row-deleted",
                        G_CALLBACK (_row_deleted_cb),
                        list);
      g_signal_connect (priv->model,
                        "row-changed",
                        G_CALLBACK (_row_changed_cb),
                        list);
      g_signal_connect (priv->model,
                        "rows-reordered",
                        G_CALLBACK (_rows_reordered_cb),
                        list);
    }
}
static void detach(SoupSessionFeature* manager, SoupSession* session)
{
    g_signal_handlers_disconnect_by_func(session, session_authenticate, manager);
}
Exemplo n.º 19
0
void vfs_dir_finalize( GObject *obj )
{
    VFSDir * dir = VFS_DIR( obj );
//printf("vfs_dir_finalize  %s\n", dir->path );
    do{}
    while( g_source_remove_by_user_data( dir ) );

    if( G_UNLIKELY( dir->task ) )
    {
        g_signal_handlers_disconnect_by_func( dir->task, on_list_task_finished, dir );
        /* FIXME: should we generate a "file-list" signal to indicate the dir loading was cancelled? */
//printf("spacefm: vfs_dir_finalize -> vfs_async_task_cancel\n");
        vfs_async_task_cancel( dir->task );
        g_object_unref( dir->task );
        dir->task = NULL;
    }
    if ( dir->monitor )
    {
        vfs_file_monitor_remove( dir->monitor,
                                 vfs_dir_monitor_callback,
                                 dir );
    }
    if ( dir->path )
    {
        if( G_LIKELY( dir_hash ) )
        {
            g_hash_table_remove( dir_hash, dir->path );

            /* There is no VFSDir instance */
            if ( 0 == g_hash_table_size( dir_hash ) )
            {
                g_hash_table_destroy( dir_hash );
                dir_hash = NULL;

                vfs_mime_type_remove_reload_cb( mime_cb );
                mime_cb = NULL;

                if( change_notify_timeout )
                {
                    g_source_remove( change_notify_timeout );
                    change_notify_timeout = 0;
                }

                g_signal_handler_disconnect( gtk_icon_theme_get_default(),
                                                                theme_change_notify );
                theme_change_notify = 0;
            }
        }
        g_free( dir->path );
        g_free( dir->disp_path );
        dir->path = dir->disp_path = NULL;
    }
    /* g_debug( "dir->thumbnail_loader: %p", dir->thumbnail_loader ); */
    if( G_UNLIKELY( dir->thumbnail_loader ) )
    {
        /* g_debug( "FREE THUMBNAIL LOADER IN VFSDIR" ); */
        vfs_thumbnail_loader_free( dir->thumbnail_loader );
        dir->thumbnail_loader = NULL;
    }

    if ( dir->file_list )
    {
        g_list_foreach( dir->file_list, ( GFunc ) vfs_file_info_unref, NULL );
        g_list_free( dir->file_list );
        dir->file_list = NULL;
        dir->n_files = 0;
    }

    if( dir->changed_files )
    {
        g_slist_foreach( dir->changed_files, (GFunc)vfs_file_info_unref, NULL );
        g_slist_free( dir->changed_files );
        dir->changed_files = NULL;
    }

    if( dir->created_files )
    {
        g_slist_foreach( dir->created_files, (GFunc)g_free, NULL );
        g_slist_free( dir->created_files );
        dir->created_files = NULL;
    }

    g_mutex_free( dir->mutex );
    G_OBJECT_CLASS( parent_class ) ->finalize( obj );
}
static void
app_load_events (App *app)
{
  GList *clients;
  GList *l;
  GList *ll;
  gchar *since_iso8601;
  gchar *until_iso8601;

  /* out with the old */
  g_hash_table_remove_all (app->appointments);
  /* nuke existing views */
  for (ll = app->live_views; ll != NULL; ll = ll->next)
    {
      ECalClientView *view = E_CAL_CLIENT_VIEW (ll->data);
      g_signal_handlers_disconnect_by_func (view, on_objects_added, app);
      g_signal_handlers_disconnect_by_func (view, on_objects_modified, app);
      g_signal_handlers_disconnect_by_func (view, on_objects_removed, app);
      e_cal_client_view_stop (view, NULL);
      g_object_unref (view);
    }
  g_list_free (app->live_views);
  app->live_views = NULL;

  /* timezone could have changed */
  app_update_timezone (app);

  since_iso8601 = isodate_from_time_t (app->since);
  until_iso8601 = isodate_from_time_t (app->until);

  print_debug ("Loading events since %s until %s",
               since_iso8601,
               until_iso8601);

  clients = calendar_sources_get_appointment_clients (app->sources);
  for (l = clients; l != NULL; l = l->next)
    {
      ECalClient *cal = E_CAL_CLIENT (l->data);
      GError *error;
      gchar *query;
      GSList *objects, *j;
      ECalClientView *view;

      e_cal_client_set_default_timezone (cal, app->zone);

      error = NULL;
      if (!e_client_open_sync (E_CLIENT (cal), TRUE, NULL, &error))
        {
          ESource *source = e_client_get_source (E_CLIENT (cal));
          g_warning ("Error opening calendar %s: %s\n",
		     e_source_get_uid (source), error->message);
          g_error_free (error);
          continue;
        }

      query = g_strdup_printf ("occur-in-time-range? (make-time \"%s\") "
                               "(make-time \"%s\")",
                               since_iso8601,
                               until_iso8601);
      error = NULL;
      objects = NULL;
      if (!e_cal_client_get_object_list_sync (cal,
					      query,
					      &objects,
					      NULL, /* cancellable */
					      &error))
        {
          ESource *source = e_client_get_source (E_CLIENT (cal));
          g_warning ("Error querying calendar %s: %s\n",
		     e_source_get_uid (source), error->message);
          g_error_free (error);
          g_free (query);
          continue;
        }

      for (j = objects; j != NULL; j = j->next)
        {
          icalcomponent *ical = j->data;
          CalendarAppointment *appointment;

          appointment = calendar_appointment_new (ical, cal, app->zone);
          if (appointment == NULL)
            continue;

          calendar_appointment_generate_occurrences (appointment,
                                                     ical,
                                                     cal,
                                                     app->since,
                                                     app->until,
                                                     app->zone);
          g_hash_table_insert (app->appointments, g_strdup (appointment->uid), appointment);
        }

      e_cal_client_free_icalcomp_slist (objects);

      error = NULL;
      if (!e_cal_client_get_view_sync (cal,
				       query,
				       &view,
				       NULL, /* cancellable */
				       &error))
        {
          g_warning ("Error setting up live-query on calendar: %s\n", error->message);
          g_error_free (error);
        }
      else
        {
          g_signal_connect (view,
                            "objects-added",
                            G_CALLBACK (on_objects_added),
                            app);
          g_signal_connect (view,
                            "objects-modified",
                            G_CALLBACK (on_objects_modified),
                            app);
          g_signal_connect (view,
                            "objects-removed",
                            G_CALLBACK (on_objects_removed),
                            app);
          e_cal_client_view_start (view, NULL);
          app->live_views = g_list_prepend (app->live_views, view);
        }

      g_free (query);
    }
  g_list_free (clients);
  g_free (since_iso8601);
  g_free (until_iso8601);
  app->cache_invalid = FALSE;
}
Exemplo n.º 21
0
static void           
gtk_layout_set_adjustments (GtkLayout     *layout,
			    GtkAdjustment *hadj,
			    GtkAdjustment *vadj)
{
  gboolean need_adjust = FALSE;

  g_return_if_fail (GTK_IS_LAYOUT (layout));

  if (hadj)
    g_return_if_fail (GTK_IS_ADJUSTMENT (hadj));
  else if (layout->hadjustment)
    hadj = new_default_adjustment ();
  if (vadj)
    g_return_if_fail (GTK_IS_ADJUSTMENT (vadj));
  else if (layout->vadjustment)
    vadj = new_default_adjustment ();
  
  if (layout->hadjustment && (layout->hadjustment != hadj))
    {
      g_signal_handlers_disconnect_by_func (layout->hadjustment,
					    gtk_layout_adjustment_changed,
					    layout);
      g_object_unref (layout->hadjustment);
    }
  
  if (layout->vadjustment && (layout->vadjustment != vadj))
    {
      g_signal_handlers_disconnect_by_func (layout->vadjustment,
					    gtk_layout_adjustment_changed,
					    layout);
      g_object_unref (layout->vadjustment);
    }
  
  if (layout->hadjustment != hadj)
    {
      layout->hadjustment = hadj;
      g_object_ref_sink (layout->hadjustment);
      gtk_layout_set_adjustment_upper (layout->hadjustment, layout->width, FALSE);
      
      g_signal_connect (layout->hadjustment, "value-changed",
			G_CALLBACK (gtk_layout_adjustment_changed),
			layout);
      need_adjust = TRUE;
    }
  
  if (layout->vadjustment != vadj)
    {
      layout->vadjustment = vadj;
      g_object_ref_sink (layout->vadjustment);
      gtk_layout_set_adjustment_upper (layout->vadjustment, layout->height, FALSE);
      
      g_signal_connect (layout->vadjustment, "value-changed",
			G_CALLBACK (gtk_layout_adjustment_changed),
			layout);
      need_adjust = TRUE;
    }

  /* vadj or hadj can be NULL while constructing; don't emit a signal
     then */
  if (need_adjust && vadj && hadj)
    gtk_layout_adjustment_changed (NULL, layout);
}
Exemplo n.º 22
0
static gint _cookie_permission_manager_ask_for_policy(CookiePermissionManager *self,
														MidoriView *inView,
														SoupMessage *inMessage,
														GSList *inUnknownCookies)
{
	/* Ask user for policy of unkndown domains in an undistracting way.
	 * The idea is to put the message not in a modal window but into midori's info bar.
	 * Then we'll set up our own GMainLoop to simulate a modal info bar. We need to
	 * connect to all possible signals of info bar, web view and so on to handle user's
	 * decision and to get out of our own GMainLoop. After that webkit resumes processing
	 * data.
	 */
	CookiePermissionManagerPrivate			*priv=self->priv;
	GtkWidget								*infobar;
/* FIXME: Find a way to add "details" widget */
#ifndef NO_INFOBAR_DETAILS
	GtkWidget								*widget;
	GtkWidget								*contentArea;
	GtkWidget								*vbox, *hbox;
	GtkWidget								*expander;
	GtkListStore							*listStore;
	GtkTreeIter								listIter;
	GtkWidget								*scrolled;
	GtkWidget								*list;
	GtkCellRenderer							*renderer;
	GtkTreeViewColumn						*column;
#endif
	gchar									*text;
	gint									numberDomains, numberCookies;
	GSList									*sortedCookies, *cookies;
	WebKitWebView							*webkitView;
	CookiePermissionManagerModalInfobar		*modalInfo;

	/* Get webkit view of midori view */
	webkitView=WEBKIT_WEB_VIEW(midori_view_get_web_view(inView));
	modalInfo=g_new0(CookiePermissionManagerModalInfobar, 1);

	/* Create a copy of cookies and sort them */
	sortedCookies=_cookie_permission_manager_get_number_domains_and_cookies(self,
																			inUnknownCookies,
																			&numberDomains,
																			&numberCookies);

/* FIXME: Find a way to add "details" widget */
#ifndef NO_INFOBAR_DETAILS
	/* Create list model and fill in data */
	listStore=gtk_list_store_new(N_COLUMN,
									G_TYPE_STRING,	/* DOMAIN_COLUMN */
									G_TYPE_STRING,	/* PATH_COLUMN */
									G_TYPE_STRING,	/* NAME_COLUMN */
									G_TYPE_STRING,	/* VALUE_COLUMN */
									G_TYPE_STRING	/* EXPIRE_DATE_COLUMN */);

	for(cookies=sortedCookies; cookies; cookies=cookies->next)
	{
		SoupCookie				*cookie=(SoupCookie*)cookies->data;
		SoupDate				*cookieDate=soup_cookie_get_expires(cookie);

		if(cookieDate) text=soup_date_to_string(cookieDate, SOUP_DATE_HTTP);
			else text=g_strdup(_("Till session end"));

		gtk_list_store_append(listStore, &listIter);
		gtk_list_store_set(listStore,
							&listIter,
							DOMAIN_COLUMN, soup_cookie_get_domain(cookie),
							PATH_COLUMN, soup_cookie_get_path(cookie),
							NAME_COLUMN, soup_cookie_get_name(cookie),
							VALUE_COLUMN, soup_cookie_get_value(cookie),
							EXPIRE_DATE_COLUMN, text,
							-1);

		g_free(text);
	}
#endif

	/* Create description text */
	if(numberDomains==1)
	{
		const gchar					*cookieDomain=soup_cookie_get_domain((SoupCookie*)sortedCookies->data);

		if(*cookieDomain=='.') cookieDomain++;
		
		if(numberCookies>1)
			text=g_strdup_printf(_("The website %s wants to store %d cookies."), cookieDomain, numberCookies);
		else
			text=g_strdup_printf(_("The website %s wants to store a cookie."), cookieDomain);
	}
		else
		{
			text=g_strdup_printf(_("Multiple websites want to store %d cookies in total."), numberCookies);
		}

	/* Create info bar message and buttons */
	infobar=midori_view_add_info_bar(inView,
										GTK_MESSAGE_QUESTION,
										text,
										G_CALLBACK(_cookie_permission_manager_on_infobar_policy_decision),
										NULL,
										_("_Accept"), COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT,
										_("Accept for this _session"), COOKIE_PERMISSION_MANAGER_POLICY_ACCEPT_FOR_SESSION,
										_("De_ny"), COOKIE_PERMISSION_MANAGER_POLICY_BLOCK,
										_("Deny _this time"), COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED,
										NULL);
	g_free(text);

	/* midori_view_add_info_bar() in version 0.4.8 expects a GObject as user data
	 * but I don't want to create an GObject just for a simple struct. So set object
	 * data by our own
	 */
	g_object_set_data_full(G_OBJECT(infobar), "cookie-permission-manager-infobar-data", modalInfo, (GDestroyNotify)g_free);

/* FIXME: Find a way to add "details" widget */
#ifndef NO_INFOBAR_DETAILS
	/* Get content area of infobar */
	contentArea=gtk_info_bar_get_content_area(GTK_INFO_BAR(infobar));

	/* Create list and set up columns of list */
	list=gtk_tree_view_new_with_model(GTK_TREE_MODEL(listStore));
#ifndef HAVE_GTK3
	gtk_widget_set_size_request(list, -1, 100);
#endif

	renderer=gtk_cell_renderer_text_new();
	column=gtk_tree_view_column_new_with_attributes(_("Domain"),
													renderer,
													"text", DOMAIN_COLUMN,
													NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);

	renderer=gtk_cell_renderer_text_new();
	column=gtk_tree_view_column_new_with_attributes(_("Path"),
													renderer,
													"text", PATH_COLUMN,
													NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);

	renderer=gtk_cell_renderer_text_new();
	column=gtk_tree_view_column_new_with_attributes(_("Name"),
													renderer,
													"text", NAME_COLUMN,
													NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);

	renderer=gtk_cell_renderer_text_new();
	column=gtk_tree_view_column_new_with_attributes(_("Value"),
													renderer,
													"text", VALUE_COLUMN,
													NULL);
	g_object_set(G_OBJECT(renderer),
					"ellipsize", PANGO_ELLIPSIZE_END,
					"width-chars", 30,
					NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);

	renderer=gtk_cell_renderer_text_new();
	column=gtk_tree_view_column_new_with_attributes(_("Expire date"),
													renderer,
													"text", EXPIRE_DATE_COLUMN,
													NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);

	scrolled=gtk_scrolled_window_new(NULL, NULL);
#ifdef HAVE_GTK3
	gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(scrolled), 100);
#endif
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_container_add(GTK_CONTAINER(scrolled), list);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
	gtk_container_add(GTK_CONTAINER(expander), scrolled);

	gtk_widget_show_all(vbox);
	gtk_container_add(GTK_CONTAINER(contentArea), vbox);

	/* Set state of expander based on config 'show-details-when-ask' */
	gtk_expander_set_expanded(GTK_EXPANDER(expander),
								midori_extension_get_boolean(priv->extension, "show-details-when-ask"));
	g_signal_connect_swapped(expander, "notify::expanded", G_CALLBACK(_cookie_permission_manager_when_ask_expander_changed), self);
#endif

	/* Show all widgets of info bar */
	gtk_widget_show_all(infobar);

	/* Connect signals to quit main loop */
	g_signal_connect(webkitView, "navigation-policy-decision-requested", G_CALLBACK(_cookie_permission_manager_on_infobar_webview_navigate), infobar);
	g_signal_connect(infobar, "destroy", G_CALLBACK(_cookie_permission_manager_on_infobar_destroy), modalInfo);

	/* Let info bar be modal and set response to default */
	modalInfo->response=COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED;
	modalInfo->mainLoop=g_main_loop_new(NULL, FALSE);

	GDK_THREADS_LEAVE();
	g_main_loop_run(modalInfo->mainLoop);
	GDK_THREADS_ENTER();

	g_main_loop_unref(modalInfo->mainLoop);

	modalInfo->mainLoop=NULL;

	/* Disconnect signal handler to webkit's web view  */
	g_signal_handlers_disconnect_by_func(webkitView, G_CALLBACK(_cookie_permission_manager_on_infobar_webview_navigate), infobar);

	/* Store user's decision in database if it is not a temporary block.
	 * We use the already sorted list of cookies to prevent multiple
	 * updates of database for the same domain. This sorted list is a copy
	 * to avoid a reorder of cookies
	 */
	if(modalInfo->response!=COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED)
	{
		const gchar					*lastDomain=NULL;

		/* Iterate through cookies and store decision for each domain once */
		for(cookies=sortedCookies; cookies; cookies=cookies->next)
		{
			SoupCookie				*cookie=(SoupCookie*)cookies->data;
			const gchar				*cookieDomain=soup_cookie_get_domain(cookie);

			if(*cookieDomain=='.') cookieDomain++;

			/* Store decision if new domain found while iterating through cookies */
			if(!lastDomain || g_ascii_strcasecmp(lastDomain, cookieDomain)!=0)
			{
				gchar	*sql;
				gchar	*error=NULL;
				gint	success;

				sql=sqlite3_mprintf("INSERT OR REPLACE INTO policies (domain, value) VALUES ('%q', %d);",
										cookieDomain,
										modalInfo->response);
				success=sqlite3_exec(priv->database, sql, NULL, NULL, &error);
				if(success!=SQLITE_OK) g_warning(_("SQL fails: %s"), error);
				if(error) sqlite3_free(error);
				sqlite3_free(sql);

				lastDomain=cookieDomain;
			}
		}
	}

	/* Free up allocated resources */
	g_slist_free(sortedCookies);

	/* Return response */
	return(modalInfo->response==COOKIE_PERMISSION_MANAGER_POLICY_UNDETERMINED ?
			COOKIE_PERMISSION_MANAGER_POLICY_BLOCK : modalInfo->response);
}
Exemplo n.º 23
0
void wxAnyButton::DoSetBitmap(const wxBitmap& bitmap, State which)
{
    switch ( which )
    {
        case State_Normal:
            if ( DontShowLabel() )
            {
                // we only have the bitmap in this button, never remove it but
                // do invalidate the best size when the bitmap (and presumably
                // its size) changes
                InvalidateBestSize();
            }
#ifdef __WXGTK26__
            // normal image is special: setting it enables images for the button and
            // resetting it to nothing disables all of them
            else if ( !gtk_check_version(2,6,0) )
            {
                GtkWidget *image = gtk_button_get_image(GTK_BUTTON(m_widget));
                if ( image && !bitmap.IsOk() )
                {
                    gtk_container_remove(GTK_CONTAINER(m_widget), image);
                }
                else if ( !image && bitmap.IsOk() )
                {
                    image = gtk_image_new();
                    gtk_button_set_image(GTK_BUTTON(m_widget), image);
                }
                else // image presence or absence didn't change
                {
                    // don't invalidate best size below
                    break;
                }

                InvalidateBestSize();
            }
#endif // GTK+ 2.6+
            break;

        case State_Pressed:
            if ( bitmap.IsOk() )
            {
                if ( !m_bitmaps[which].IsOk() )
                {
                    // we need to install the callbacks to be notified about
                    // the button pressed state change
                    g_signal_connect
                    (
                        m_widget,
                        "pressed",
                        G_CALLBACK(wxgtk_button_press_callback),
                        this
                    );

                    g_signal_connect
                    (
                        m_widget,
                        "released",
                        G_CALLBACK(wxgtk_button_released_callback),
                        this
                    );
                }
            }
            else // no valid bitmap
            {
                if ( m_bitmaps[which].IsOk() )
                {
                    // we don't need to be notified about the button pressed
                    // state changes any more
                    g_signal_handlers_disconnect_by_func
                    (
                        m_widget,
                        (gpointer)wxgtk_button_press_callback,
                        this
                    );

                    g_signal_handlers_disconnect_by_func
                    (
                        m_widget,
                        (gpointer)wxgtk_button_released_callback,
                        this
                    );

                    // also make sure we don't remain stuck in pressed state
                    if ( m_isPressed )
                    {
                        m_isPressed = false;
                        GTKUpdateBitmap();
                    }
                }
            }
            break;

        case State_Current:
            // the logic here is the same as above for State_Pressed: we need
            // to connect the handlers if we must be notified about the changes
            // in the button current state and we disconnect them when/if we
            // don't need them any more
            if ( bitmap.IsOk() )
            {
                if ( !m_bitmaps[which].IsOk() )
                {
                    g_signal_connect
                    (
                        m_widget,
                        "enter",
                        G_CALLBACK(wxgtk_button_enter_callback),
                        this
                    );

                    g_signal_connect
                    (
                        m_widget,
                        "leave",
                        G_CALLBACK(wxgtk_button_leave_callback),
                        this
                    );
                }
            }
            else // no valid bitmap
            {
                if ( m_bitmaps[which].IsOk() )
                {
                    g_signal_handlers_disconnect_by_func
                    (
                        m_widget,
                        (gpointer)wxgtk_button_enter_callback,
                        this
                    );

                    g_signal_handlers_disconnect_by_func
                    (
                        m_widget,
                        (gpointer)wxgtk_button_leave_callback,
                        this
                    );

                    if ( m_isCurrent )
                    {
                        m_isCurrent = false;
                        GTKUpdateBitmap();
                    }
                }
            }
            break;

        case State_Focused:
            if ( bitmap.IsOk() )
            {
                Connect(wxEVT_SET_FOCUS,
                        wxFocusEventHandler(wxAnyButton::GTKOnFocus));
                Connect(wxEVT_KILL_FOCUS,
                        wxFocusEventHandler(wxAnyButton::GTKOnFocus));
            }
            else // no valid focused bitmap
            {
                Disconnect(wxEVT_SET_FOCUS,
                           wxFocusEventHandler(wxAnyButton::GTKOnFocus));
                Disconnect(wxEVT_KILL_FOCUS,
                           wxFocusEventHandler(wxAnyButton::GTKOnFocus));
            }
            break;

        default:
            // no callbacks to connect/disconnect
            ;
    }

    m_bitmaps[which] = bitmap;

    // update the bitmap immediately if necessary, otherwise it will be done
    // when the bitmap for the corresponding state is needed the next time by
    // GTKUpdateBitmap()
    if ( bitmap.IsOk() && which == GTKGetCurrentState() )
    {
        GTKDoShowBitmap(bitmap);
    }
}
Exemplo n.º 24
0
static void
marlin_text_renderer_set_widget (MarlinTextRenderer *text_renderer,
                                 GtkWidget          *widget)
{
    PangoFontMetrics *metrics;
    PangoContext *context;
    gint focus_padding;
    gint focus_line_width;
    const PangoFontDescription *font_desc;

    if (G_LIKELY (widget == text_renderer->widget))
        return;

    /* disconnect from the previously set widget */
    if (G_UNLIKELY (text_renderer->widget != NULL))
    {
        g_signal_handlers_disconnect_by_func (G_OBJECT (text_renderer->widget), marlin_text_renderer_invalidate, text_renderer);
        g_object_unref (G_OBJECT (text_renderer->layout));
        g_object_unref (G_OBJECT (text_renderer->widget));
    }

    /* activate the new widget */
    text_renderer->widget = widget;

    /* connect to the new widget */
    if (G_LIKELY (widget != NULL))
    {
        /* take a reference on the widget */
        g_object_ref (G_OBJECT (widget));

        /* we need to recalculate the metrics when a new style (and thereby a new font) is set */
        g_signal_connect_swapped (G_OBJECT (text_renderer->widget), "destroy", G_CALLBACK (marlin_text_renderer_invalidate), text_renderer);
        g_signal_connect_swapped (G_OBJECT (text_renderer->widget), "style-set", G_CALLBACK (marlin_text_renderer_invalidate), text_renderer);

        /* allocate a new pango layout for this widget */
        context = gtk_widget_get_pango_context (widget);
        text_renderer->layout = pango_layout_new (context);

        /* disable automatic text direction, but use the direction specified by Gtk+ */
        pango_layout_set_auto_dir (text_renderer->layout, FALSE);

        /* we don't want to interpret line separators in file names */
        pango_layout_set_single_paragraph_mode (text_renderer->layout, TRUE);

        font_desc = pango_layout_get_font_description (text_renderer->layout);

        /* calculate the average character dimensions */
        metrics = pango_context_get_metrics (context, font_desc, pango_context_get_language (context));

        text_renderer->char_width = PANGO_PIXELS (pango_font_metrics_get_approximate_char_width (metrics));
        text_renderer->char_height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) + pango_font_metrics_get_descent (metrics));
        pango_font_metrics_unref (metrics);

        /* tell the cell renderer about the fixed height if we're not wrapping text */
        if (G_LIKELY (text_renderer->wrap_width < 0))
            gtk_cell_renderer_set_fixed_size (GTK_CELL_RENDERER (text_renderer), -1, text_renderer->char_height);

        /* determine the focus-padding and focus-line-width style properties from the widget */
        gtk_widget_style_get (widget, "focus-padding", &focus_padding, "focus-line-width", &focus_line_width, NULL);
        text_renderer->focus_width = focus_padding + focus_line_width;
    }
    else
    {
        text_renderer->layout = NULL;
        text_renderer->char_width = 0;
        text_renderer->char_height = 0;
    }
}
Exemplo n.º 25
0
static void
panel_applet_destroy (GtkWidget  *widget,
		      AppletInfo *info)
{
	GList *l;

	g_return_if_fail (info != NULL);

	info->widget = NULL;

	registered_applets = g_slist_remove (registered_applets, info);

	queued_position_saves =
		g_slist_remove (queued_position_saves, info);

	if (info->menu) {
		if (gtk_widget_get_visible (info->menu))
			gtk_menu_shell_deactivate (GTK_MENU_SHELL (info->menu));

                g_signal_handlers_disconnect_by_func (info->menu,
						      G_CALLBACK (applet_menu_show), info);
                g_signal_handlers_disconnect_by_func (info->menu,
						      G_CALLBACK (applet_menu_deactivate), info);
		g_object_unref (info->menu);
        }
	info->menu = NULL;

	if (info->edit_menu) {
		if (gtk_widget_get_visible (info->edit_menu))
			gtk_menu_shell_deactivate (GTK_MENU_SHELL (info->edit_menu));

                g_signal_handlers_disconnect_by_func (info->edit_menu,
						      G_CALLBACK (applet_menu_show), info);
                g_signal_handlers_disconnect_by_func (info->edit_menu,
						      G_CALLBACK (applet_menu_deactivate), info);
		g_object_unref (info->edit_menu);
        }
	info->edit_menu = NULL;

	if (info->data_destroy)
		info->data_destroy (info->data);
	info->data = NULL;

	for (l = info->user_menu; l != NULL; l = l->next) {
		AppletUserMenu *umenu = l->data;

		g_free (umenu->name);
		g_free (umenu->stock_item);
		g_free (umenu->text);

		g_free (umenu);
	}

	g_list_free (info->user_menu);
	info->user_menu = NULL;

	if (info->settings)
		g_object_unref (info->settings);
	info->settings = NULL;

	g_free (info->id);
	info->id = NULL;

	g_free (info);
}
Exemplo n.º 26
0
static void
dbus_daemon_notify_bus_address_cb (GObject *gobject, GParamSpec *pspec, MainData *data)
{
	GPtrArray/*<string>*/ *test_program_envp;
	gchar *envp_pair;

	g_assert (data->dbus_address == NULL);
	data->dbus_address = g_strdup (dsim_dbus_daemon_get_bus_address (data->dbus_daemon));

	g_message (_("Note: Simulated bus has address: %s"), data->dbus_address);

	/* Set up the test program ready for spawning. */
	test_program_envp = g_ptr_array_new_with_free_func (g_free);

	if (pass_through_environment == FALSE) {
		guint i;

		/* Set up a minimal environment with just the necessary environment variables required for things to function.
		 * Note that this list of necessary environment variables is probably incomplete, and is built on the basis of
		 * trial and error rather than research or standards. */
		const gchar *forward_variables[] = {
			"DISPLAY",
			"XDG_DATA_HOME",
			"XDG_CONFIG_HOME",
			"XDG_DATA_DIRS",
			"XDG_CONFIG_DIRS",
			"XDG_CACHE_HOME",
			"XDG_RUNTIME_DIR",
			"HOME",
			"USER",
			"HOSTNAME",
			"SSH_CLIENT",
			"SSH_TTY",
			"SSH_CONNECTION",
		};

		for (i = 0; i < G_N_ELEMENTS (forward_variables); i++) {
			forward_envp_pair (test_program_envp, forward_variables[i]);
		}
	} else {
		/* Forward everything from the simulator's environment to the test program's environment. This might make the test
		 * results slightly less reliable. */
		gchar **env_variable_names;
		const gchar * const *i;

		env_variable_names = g_listenv ();

		for (i = (const gchar * const *) env_variable_names; *i != NULL; i++) {
			forward_envp_pair (test_program_envp, *i);
		}

		g_strfreev (env_variable_names);
	}

	if (system_bus) {
		envp_pair = g_strdup_printf ("DBUS_SYSTEM_BUS_ADDRESS=%s", data->dbus_address);
	} else {
		envp_pair = g_strdup_printf ("DBUS_SESSION_BUS_ADDRESS=%s", data->dbus_address);
	}
	g_ptr_array_add (test_program_envp, envp_pair);

	/* Copy the environment pairs set on the command line. */
	if (test_program_environment != NULL) {
		guint i;

		for (i = 0; i < test_program_environment->len; i++) {
			envp_pair = g_ptr_array_index (test_program_environment, i);
			g_ptr_array_add (test_program_envp, g_strdup (envp_pair));
		}
	}

	data->test_program = dsim_test_program_new (data->working_directory_file, data->test_program_name, data->test_program_argv, test_program_envp);

	g_ptr_array_unref (test_program_envp);

	/* Start building a D-Bus connection with our new bus address. */
	g_dbus_connection_new_for_address (data->dbus_address,
	                                   G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT | G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION, NULL, NULL,
	                                   (GAsyncReadyCallback) connection_created_cb, data);

	/* We don't want this to fire again. */
	g_signal_handlers_disconnect_by_func (gobject, dbus_daemon_notify_bus_address_cb, data);
}
Exemplo n.º 27
0
static void
device_state_changed (NMActiveConnection *active,
                      NMDevice *device,
                      NMDeviceState new_state,
                      NMDeviceState old_state)
{
	NMActiveConnectionState cur_ac_state = nm_active_connection_get_state (active);
	NMActiveConnectionState ac_state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN;

	/* Decide which device state changes to handle when this active connection
	 * is not the device's current request.  Two cases here: (a) the AC is
	 * pending and not yet active, and (b) the AC was active but the device is
	 * entering DISCONNECTED state (which clears the device's current AC before
	 * emitting the state change signal).
	 */
	if (NM_ACTIVE_CONNECTION (nm_device_get_act_request (device)) != active) {
		/* Some other request is activating; this one must be pending */
		if (new_state >= NM_DEVICE_STATE_PREPARE)
			return;
		else if (new_state == NM_DEVICE_STATE_DISCONNECTED) {
			/* This request hasn't started activating yet; the device is
			 * disconnecting and cleaning up a previous activation request.
			 */
			if (cur_ac_state < NM_ACTIVE_CONNECTION_STATE_ACTIVATING)
				return;

			/* Catch device disconnections after this request has been active */
		}

		/* All states < DISCONNECTED are fatal and handled */
	}

	/* Set NMActiveConnection state based on the device's state */
	switch (new_state) {
	case NM_DEVICE_STATE_PREPARE:
	case NM_DEVICE_STATE_CONFIG:
	case NM_DEVICE_STATE_NEED_AUTH:
	case NM_DEVICE_STATE_IP_CONFIG:
	case NM_DEVICE_STATE_IP_CHECK:
	case NM_DEVICE_STATE_SECONDARIES:
		ac_state = NM_ACTIVE_CONNECTION_STATE_ACTIVATING;
		break;
	case NM_DEVICE_STATE_ACTIVATED:
		ac_state = NM_ACTIVE_CONNECTION_STATE_ACTIVATED;

		g_signal_connect (device, "notify::" NM_DEVICE_IP4_CONFIG,
		                  G_CALLBACK (device_notify), active);
		g_signal_connect (device, "notify::" NM_DEVICE_DHCP4_CONFIG,
		                  G_CALLBACK (device_notify), active);
		g_signal_connect (device, "notify::" NM_DEVICE_IP6_CONFIG,
		                  G_CALLBACK (device_notify), active);
		g_signal_connect (device, "notify::" NM_DEVICE_DHCP6_CONFIG,
		                  G_CALLBACK (device_notify), active);
		break;
	case NM_DEVICE_STATE_DEACTIVATING:
		ac_state = NM_ACTIVE_CONNECTION_STATE_DEACTIVATING;
		break;
	case NM_DEVICE_STATE_FAILED:
	case NM_DEVICE_STATE_DISCONNECTED:
	case NM_DEVICE_STATE_UNMANAGED:
	case NM_DEVICE_STATE_UNAVAILABLE:
		ac_state = NM_ACTIVE_CONNECTION_STATE_DEACTIVATED;

		g_signal_handlers_disconnect_by_func (device, G_CALLBACK (device_notify), active);
		break;
	default:
		break;
	}

	if (   ac_state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED
	    || ac_state == NM_ACTIVE_CONNECTION_STATE_UNKNOWN) {
		nm_active_connection_set_default (active, FALSE);
		nm_active_connection_set_default6 (active, FALSE);
	}

	nm_active_connection_set_state (active, ac_state);
}
Exemplo n.º 28
0
static void
gtk_tooltip_show_tooltip (GdkDisplay *display)
{
  gint x, y;
  GdkScreen *screen;

  GdkWindow *window;
  GtkWidget *tooltip_widget;
  GtkTooltip *tooltip;
  gboolean has_tooltip;
  gboolean return_value = FALSE;

  tooltip = g_object_get_data (G_OBJECT (display),
                               "gdk-display-current-tooltip");

  if (tooltip->keyboard_mode_enabled)
    {
      x = y = -1;
      tooltip_widget = tooltip->keyboard_widget;
    }
  else
    {
      GdkDevice *device;
      gint tx, ty;

      window = tooltip->last_window;

      if (!GDK_IS_WINDOW (window))
        return;

      device = gdk_device_manager_get_client_pointer (gdk_display_get_device_manager (display));

      gdk_window_get_device_position (window, device, &x, &y, NULL);

      gdk_window_get_root_coords (window, x, y, &tx, &ty);
      tooltip->last_x = tx;
      tooltip->last_y = ty;

      tooltip_widget = _gtk_widget_find_at_coords (window, x, y, &x, &y);
    }

  if (!tooltip_widget)
    return;

  g_object_get (tooltip_widget, "has-tooltip", &has_tooltip, NULL);

  return_value = gtk_tooltip_run_requery (&tooltip_widget, tooltip, &x, &y);
  if (!return_value)
    return;

  if (!tooltip->current_window)
    {
      if (gtk_widget_get_tooltip_window (tooltip_widget))
        tooltip->current_window = gtk_widget_get_tooltip_window (tooltip_widget);
      else
        tooltip->current_window = GTK_WINDOW (GTK_TOOLTIP (tooltip)->window);
    }

  screen = gtk_widget_get_screen (tooltip_widget);

  /* FIXME: should use tooltip->current_window iso tooltip->window */
  if (screen != gtk_widget_get_screen (tooltip->window))
    {
      g_signal_handlers_disconnect_by_func (display,
                                            gtk_tooltip_display_closed,
                                            tooltip);

      gtk_window_set_screen (GTK_WINDOW (tooltip->window), screen);

      g_signal_connect (display, "closed",
                        G_CALLBACK (gtk_tooltip_display_closed), tooltip);
    }

  gtk_tooltip_position (tooltip, display, tooltip_widget);

  /* Now a tooltip is visible again on the display, make sure browse
   * mode is enabled.
   */
  tooltip->browse_mode_enabled = TRUE;
  if (tooltip->browse_mode_timeout_id)
    {
      g_source_remove (tooltip->browse_mode_timeout_id);
      tooltip->browse_mode_timeout_id = 0;
    }
}
Exemplo n.º 29
0
static void
on_pkg_config_exit (AnjutaLauncher * launcher, int child_pid,
				   int exit_status, gulong time_taken_in_seconds,
				   gpointer user_data)
{
	SymbolDBSystem *sdbs;
	SymbolDBSystemPriv *priv;
	SingleScanData *ss_data;
	GList *cflags = NULL;
	
	ss_data = (SingleScanData *)user_data;
	sdbs = ss_data->sdbs;
	priv = sdbs->priv;	
		
	/* first of all disconnect the signals */
	g_signal_handlers_disconnect_by_func (launcher, on_pkg_config_exit,
										  user_data);
	
	if (ss_data->contents != NULL && strlen (ss_data->contents) > 0)
	{		
		cflags = sdb_system_get_normalized_cflags (ss_data->contents);
	}	
	
	/* check our ss_data struct. If it has a != null callback then we should
	 * call it right now..
	 */
	if (ss_data->parseable_cb != NULL)
	{
		DEBUG_PRINT ("%s", "on_pkg_config_exit parseable activated");
		ss_data->parseable_cb (sdbs, cflags == NULL ? FALSE : TRUE, 
							   ss_data->parseable_data);
	}

	/* no callback to call. Just parse the package on */
	if (ss_data->engine_scan == TRUE && cflags != NULL)
	{
		EngineScanData *es_data;
		
		es_data = g_new0 (EngineScanData, 1);
		es_data->sdbs = sdbs;
		es_data->cflags = cflags;
		es_data->package_name = g_strdup (ss_data->package_name);
		es_data->special_abort_scan = FALSE;
			
		/* is the engine queue already full && working? */
		if (g_queue_get_length (priv->engine_queue) > 0) 
		{
			/* just push the tail waiting for a later processing [i.e. after
			 * a scan-end received 
			 */
			DEBUG_PRINT ("pushing on engine queue [length %d] %s", 
						 g_queue_get_length (priv->engine_queue),
						 es_data->package_name);
			g_queue_push_tail (priv->engine_queue, es_data);
		}
		else
		{
			/* push the tail to signal a 'working engine' */
			DEBUG_PRINT ("scanning with engine queue [length %d] %s", 
						 g_queue_get_length (priv->engine_queue),
						 es_data->package_name);
			
			g_queue_push_tail (priv->engine_queue, es_data);
			
			sdb_system_do_engine_scan (sdbs, es_data);
		}
	}
	
	/* destroys, after popping, the ss_data from the queue */
	g_queue_remove (priv->sscan_queue, ss_data);
	destroy_single_scan_data (ss_data);
	
	/* proceed with another scan */	
	sdb_system_do_scan_next_package (sdbs);	
}
Exemplo n.º 30
0
static void
goa_daemon_update_notifications (GoaDaemon *daemon)
{
  gboolean show_notification;
  GList *objects;
  GList *l;

  show_notification = FALSE;
  objects = g_dbus_object_manager_get_objects (G_DBUS_OBJECT_MANAGER (daemon->object_manager));
  for (l = objects; l != NULL; l = l->next)
    {
      GoaObject *object = GOA_OBJECT (l->data);
      GoaAccount *account;
      account = goa_object_peek_account (object);
      if (account != NULL)
        {
          if (goa_account_get_attention_needed (account))
            {
              show_notification = TRUE;
              break;
            }
        }
    }

  if (show_notification)
    {
      if (daemon->notification == NULL)
        {
          GError *error;

          daemon->notification = notify_notification_new (_("An online account needs attention"),
                                                          NULL,
                                                          NULL);
          notify_notification_set_timeout (daemon->notification, NOTIFY_EXPIRES_NEVER);
          g_object_set (daemon->notification, "icon-name", "gtk-dialog-error", NULL);
          notify_notification_add_action (daemon->notification,
                                          "open-online-accounts",
                                          _("Open Online Accounts..."),
                                          notification_cb,
                                          daemon,
                                          NULL); /* GFreeFunc */

          error = NULL;
          if (!notify_notification_show (daemon->notification, &error))
            {
              goa_warning ("Error showing notification: %s (%s, %d)",
                           error->message, g_quark_to_string (error->domain), error->code);
              g_error_free (error);
              g_object_unref (daemon->notification);
              daemon->notification = NULL;
            }
          else
            {
              g_signal_connect (daemon->notification,
                                "closed",
                                G_CALLBACK (on_notification_closed),
                                daemon);
            }
        }
    }
  else
    {
      if (daemon->notification != NULL)
        {
          GError *error;
          error = NULL;
          if (!notify_notification_close (daemon->notification, &error))
            {
              goa_warning ("Error closing notification: %s (%s, %d)",
                           error->message, g_quark_to_string (error->domain), error->code);
              g_error_free (error);
            }
          g_signal_handlers_disconnect_by_func (daemon->notification,
                                                G_CALLBACK (on_notification_closed),
                                                daemon);
          g_object_unref (daemon->notification);
          daemon->notification = NULL;
        }
    }

  g_list_foreach (objects, (GFunc) g_object_unref, NULL);
  g_list_free (objects);
}