static void
remove_tag_cb (GbColorPickerDocumentMonitor *self,
               GtkTextTag                   *tag,
               GtkTextIter                  *start,
               GtkTextIter                  *end,
               GtkTextBuffer                *buffer)
{
  GtkTextTagTable *tag_table;
  g_autofree gchar *name = NULL;
  Position spos;
  Position epos;

  g_assert (GB_IS_COLOR_PICKER_DOCUMENT_MONITOR (self));
  g_assert (GTK_IS_TEXT_BUFFER (buffer));
  g_assert (GTK_IS_TEXT_TAG (tag));

  position_save (&spos, start);
  position_save (&epos, end);

  tag_table = gtk_text_buffer_get_tag_table (GTK_TEXT_BUFFER (self->buffer));
  g_object_get (G_OBJECT (tag), "name", &name, NULL);

  if (!dzl_str_empty0 (name) &&
      g_str_has_prefix (name, COLOR_TAG_PREFIX) &&
      gtk_text_tag_table_lookup (tag_table, name))
    gtk_text_tag_table_remove (tag_table, tag);

  position_restore (&spos, buffer, start);
  position_restore (&epos, buffer, end);
}
예제 #2
0
guint
gbp_spell_navigator_get_count (GbpSpellNavigator *self,
                               const gchar       *word)
{
  g_assert (GBP_IS_SPELL_NAVIGATOR (self));

  if (self->words_count == NULL || dzl_str_empty0 (word))
    return 0;
  else
    return GPOINTER_TO_UINT (g_hash_table_lookup (self->words_count, word));
}
static void
collect_tag_names (GtkTextTag *tag,
                   GPtrArray  *taglist)
{
  g_autofree gchar *name = NULL;

  g_assert (GTK_IS_TEXT_TAG (tag));
  g_assert (taglist != NULL);

  g_object_get (G_OBJECT (tag), "name", &name, NULL);
  if (!dzl_str_empty0 (name) && g_str_has_prefix (name, COLOR_TAG_PREFIX))
    g_ptr_array_add (taglist, g_steal_pointer (&name));
}
예제 #4
0
static gboolean
gb_vim_command_tabe (GtkWidget      *active_widget,
                     const gchar    *command,
                     const gchar    *options,
                     GError        **error)
{
  g_assert (GTK_IS_WIDGET (active_widget));

  if (!dzl_str_empty0 (options))
    return gb_vim_command_edit (active_widget, command, options, error);

  dzl_gtk_widget_action (GTK_WIDGET (active_widget), "editor", "new-file", NULL);

  return TRUE;
}
예제 #5
0
static gboolean
ide_terminal_copy_link_address (IdeTerminal *self)
{
  IdeTerminalPrivate *priv = ide_terminal_get_instance_private (self);

  g_assert (IDE_IS_TERMINAL (self));
  g_assert (priv->url != NULL);

  if (dzl_str_empty0 (priv->url))
    return FALSE;

  gtk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (self), GDK_SELECTION_CLIPBOARD),
                          priv->url, strlen (priv->url));

  return TRUE;
}
예제 #6
0
static gboolean
gb_vim_command_edit (GtkWidget      *active_widget,
                     const gchar    *command,
                     const gchar    *options,
                     GError        **error)
{
  IdeWorkbench *workbench;
  IdeContext *context;
  IdeVcs *vcs;
  GFile *workdir;
  GFile *file = NULL;

  g_assert (GTK_IS_WIDGET (active_widget));

  if (dzl_str_empty0 (options))
    {
      dzl_gtk_widget_action (GTK_WIDGET (active_widget), "win", "open-with-dialog", NULL);
      return TRUE;
    }

  if (!(workbench = ide_widget_get_workbench (active_widget)) ||
      !(context = ide_workbench_get_context (workbench)) ||
      !(vcs = ide_context_get_vcs (context)) ||
      !(workdir = ide_vcs_get_working_directory (vcs)))
    {
      g_set_error (error,
                   GB_VIM_ERROR,
                   GB_VIM_ERROR_NOT_SOURCE_VIEW,
                   _("Failed to locate working directory"));
      return FALSE;
    }

  if (g_path_is_absolute (options))
    file = g_file_new_for_path (options);
  else
    file = g_file_get_child (workdir, options);

  ide_workbench_open_files_async (workbench, &file, 1, "editor", IDE_WORKBENCH_OPEN_FLAGS_NONE, NULL, NULL, NULL);

  g_clear_object (&file);

  return TRUE;
}
예제 #7
0
const gchar *
list_get_attribute (const guchar **attributes,
                    const gchar  *name)
{
  const guchar **l = attributes;

  g_return_val_if_fail (!dzl_str_empty0 (name), NULL);

  if (attributes == NULL)
    return NULL;

  while (l [0] != NULL)
    {
      if (dzl_str_equal0 (name, l [0]))
        return (const gchar *)l [1];

      l += 2;
    }

  return NULL;
}
예제 #8
0
static gboolean
ide_terminal_open_link (IdeTerminal *self)
{
  IdeTerminalPrivate *priv = ide_terminal_get_instance_private (self);
  GtkApplication *app;
  GtkWindow *focused_window;

  g_assert (IDE_IS_TERMINAL (self));
  g_assert (priv->url != NULL);

  if (dzl_str_empty0 (priv->url))
    return FALSE;

  if (NULL != (app = GTK_APPLICATION (g_application_get_default ())) &&
      NULL != (focused_window = gtk_application_get_active_window (app)))
    return gtk_show_uri_on_window (focused_window,
                                   priv->url,
                                   gtk_get_current_event_time (),
                                   NULL);

  return FALSE;
}
예제 #9
0
static gboolean
gb_vim_command_vsplit (GtkWidget    *active_widget,
                       const gchar  *command,
                       const gchar  *options,
                       GError      **error)
{
  GVariant *variant;

  g_assert (GTK_IS_WIDGET (active_widget));

  if (!IDE_IS_LAYOUT_VIEW (active_widget))
    return gb_vim_set_no_view_error (error);

  if (dzl_str_empty0 (options))
    {
      variant = g_variant_new_string ("");
      dzl_gtk_widget_action (GTK_WIDGET (active_widget), "layoutstack", "open-in-new-frame", variant);

      return TRUE;
    }
  else
    return load_split_async (active_widget, options, gb_vim_command_vsplit_cb, error);
}
예제 #10
0
static void
gbp_flatpak_download_stage_query (IdeBuildStage    *stage,
                                  IdeBuildPipeline *pipeline,
                                  GCancellable     *cancellable)
{
  GbpFlatpakDownloadStage *self = (GbpFlatpakDownloadStage *)stage;
  IdeConfiguration *config;
  GNetworkMonitor *monitor;
  g_autofree gchar *staging_dir = NULL;
  g_autofree gchar *manifest_path = NULL;
  g_autofree gchar *stop_at_option = NULL;
  const gchar *src_dir;
  const gchar *primary_module;

  g_assert (GBP_IS_FLATPAK_DOWNLOAD_STAGE (self));
  g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
  g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));

  config = ide_build_pipeline_get_configuration (pipeline);
  if (!GBP_IS_FLATPAK_CONFIGURATION (config))
    {
      ide_build_stage_set_completed (stage, TRUE);
      return;
    }

  if (self->invalid)
    {
      g_autoptr(IdeSubprocessLauncher) launcher = NULL;

      primary_module = gbp_flatpak_configuration_get_primary_module (GBP_FLATPAK_CONFIGURATION (config));
      manifest_path = gbp_flatpak_configuration_get_manifest_path (GBP_FLATPAK_CONFIGURATION (config));
      staging_dir = gbp_flatpak_get_staging_dir (config);
      src_dir = ide_build_pipeline_get_srcdir (pipeline);

      launcher = ide_subprocess_launcher_new (G_SUBPROCESS_FLAGS_STDOUT_PIPE |
                                              G_SUBPROCESS_FLAGS_STDERR_PIPE);

      ide_subprocess_launcher_set_run_on_host (launcher, TRUE);
      ide_subprocess_launcher_set_clear_env (launcher, FALSE);
      ide_subprocess_launcher_set_cwd (launcher, src_dir);

      ide_subprocess_launcher_push_argv (launcher, "flatpak-builder");
      ide_subprocess_launcher_push_argv (launcher, "--ccache");
      ide_subprocess_launcher_push_argv (launcher, "--force-clean");
      if (!dzl_str_empty0 (self->state_dir))
        {
          ide_subprocess_launcher_push_argv (launcher, "--state-dir");
          ide_subprocess_launcher_push_argv (launcher, self->state_dir);
        }
      ide_subprocess_launcher_push_argv (launcher, "--download-only");
      if (!self->force_update)
        ide_subprocess_launcher_push_argv (launcher, "--disable-updates");
      stop_at_option = g_strdup_printf ("--stop-at=%s", primary_module);
      ide_subprocess_launcher_push_argv (launcher, stop_at_option);
      ide_subprocess_launcher_push_argv (launcher, staging_dir);
      ide_subprocess_launcher_push_argv (launcher, manifest_path);

      ide_build_stage_launcher_set_launcher (IDE_BUILD_STAGE_LAUNCHER (self), launcher);
      ide_build_stage_set_completed (stage, FALSE);

      self->invalid = FALSE;
      self->force_update = FALSE;
    }

  /* Ignore downloads if there is no connection */
  monitor = g_network_monitor_get_default ();
  if (!g_network_monitor_get_network_available (monitor))
    {
      ide_build_stage_log (stage,
                           IDE_BUILD_LOG_STDOUT,
                           _("Network is not available, skipping downloads"),
                           -1);
      ide_build_stage_set_completed (stage, TRUE);
    }
}