Esempio n. 1
0
void
git_ivcs_add (IAnjutaVcs *obj, GList *files, AnjutaAsyncNotify *notify,
			  GError **err)
{
	gchar *project_root_directory;
	GList *path_list;
	GitAddCommand *add_command;
	
	project_root_directory = ANJUTA_PLUGIN_GIT (obj)->project_root_directory;
	
	if (project_root_directory)
	{
		path_list = anjuta_util_convert_gfile_list_to_relative_path_list (files,
		                                                                  project_root_directory);
		add_command = git_add_command_new_list (project_root_directory,
		                                        path_list, FALSE);
		
		anjuta_util_glist_strings_free (path_list);
		
		g_signal_connect (G_OBJECT (add_command), "command-finished", 
		                  G_CALLBACK (g_object_unref), 
		                  NULL);
		
		if (notify)
		{
			g_signal_connect_swapped (G_OBJECT (add_command), "command-finished",
			                          G_CALLBACK (anjuta_async_notify_notify_finished),
			                          notify);
		}
		
		anjuta_command_start (ANJUTA_COMMAND (add_command));
	}
	
}
Esempio n. 2
0
static void
on_ok_button_clicked (GtkButton *button, GitCheckoutPane *self)
{
	Git *plugin;
	GtkToggleButton *force_check;
	GList *paths;
	GitCheckoutFilesCommand *checkout_command;

	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
	force_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
	                                                         "force_check"));

	paths = git_status_pane_get_selected_not_updated_items (GIT_STATUS_PANE (plugin->status_pane),
	                                                        ANJUTA_VCS_STATUS_ALL);
	checkout_command = git_checkout_files_command_new (plugin->project_root_directory,
	                                                   paths,
	                                                   gtk_toggle_button_get_active (force_check));

	anjuta_util_glist_strings_free (paths);

	g_signal_connect (G_OBJECT (checkout_command), "command-finished",
	                  G_CALLBACK (git_pane_report_errors),
	                  plugin);

	g_signal_connect (G_OBJECT (checkout_command), "command-finished",
	                  G_CALLBACK (g_object_unref),
	                  NULL);

	anjuta_command_start (ANJUTA_COMMAND (checkout_command));

	git_pane_remove_from_dock (GIT_PANE (self));
	                            
}
Esempio n. 3
0
static void
on_ok_action_activated (GtkAction *action, GitRemoveFilesPane *self)
{
	Git *plugin;
	AnjutaFileList *remove_file_list;
	GtkToggleAction *force_action;
	GList *paths;
	GitRemoveCommand *remove_command;

	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
	remove_file_list = ANJUTA_FILE_LIST (gtk_builder_get_object (self->priv->builder,
	                                                  			 "remove_file_list"));
	force_action = GTK_TOGGLE_ACTION (gtk_builder_get_object (self->priv->builder,
	                                                          "force_action"));
	paths = anjuta_file_list_get_paths (remove_file_list);
	remove_command = git_remove_command_new_list (plugin->project_root_directory,
	                                              paths,
	                                              gtk_toggle_action_get_active (force_action));

	anjuta_util_glist_strings_free (paths);

	g_signal_connect (G_OBJECT (remove_command), "command-finished",
	                  G_CALLBACK (git_pane_report_errors),
	                  plugin);


	g_signal_connect (G_OBJECT (remove_command), "command-finished",
	                  G_CALLBACK (g_object_unref),
	                  NULL);

	anjuta_command_start (ANJUTA_COMMAND (remove_command));

	git_pane_remove_from_dock (GIT_PANE (self));
}
Esempio n. 4
0
static void
git_status_pane_refresh (AnjutaDockPane *pane)
{
	Git *plugin;

	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (pane));

	anjuta_command_start (ANJUTA_COMMAND (plugin->commit_status_command));
	
}
Esempio n. 5
0
void
git_pane_remove_from_dock (GitPane *self)
{
	Git *plugin;

	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));

	anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock), 
	                         ANJUTA_DOCK_PANE (self));
}
Esempio n. 6
0
static void
on_log_command_finished (AnjutaCommand *command, guint return_code, 
						 GitLogPane *self)
{
	GtkTreeView *log_view;
	GQueue *queue;
	GtkTreeIter iter;
	GitRevision *revision;

	/* Show the actual log view */
	git_log_pane_set_view_mode (self, LOG_VIEW_NORMAL);

	log_view = GTK_TREE_VIEW (gtk_builder_get_object (self->priv->builder, 
	                                                  "log_view"));
	
	if (return_code != 0)
	{
		/* Don't report erros in the log view as this is usually no user requested
		 * operation and thus error messages are confusing instead just show an
		 * empty log.
		 */
#if 0
		git_pane_report_errors (command, return_code,
		                        ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self))));
#endif
		goto out;
	}
	
	queue = git_log_command_get_output_queue (GIT_LOG_COMMAND (command));
	
	while (g_queue_peek_head (queue))
	{
		revision = g_queue_pop_head (queue);
		
		gtk_list_store_append (self->priv->log_model, &iter);
		gtk_list_store_set (self->priv->log_model, &iter, LOG_COL_REVISION, 
		                    revision, -1);

		g_object_unref (revision);
	}
	
	giggle_graph_renderer_validate_model (GIGGLE_GRAPH_RENDERER (self->priv->graph_renderer),
										  GTK_TREE_MODEL (self->priv->log_model),
										  0);
	gtk_tree_view_set_model (GTK_TREE_VIEW (log_view), 
							 GTK_TREE_MODEL (self->priv->log_model));

out:
	g_clear_object (&self->priv->log_command);
}
Esempio n. 7
0
void
git_ivcs_checkout (IAnjutaVcs *obj, 
				   const gchar *repository_location, GFile *dest,
				   GCancellable *cancel,
				   AnjutaAsyncNotify *notify, GError **err)
{
	GFile *parent;
	gchar *path, *dir_name;
	GitCloneCommand *clone_command;
	Git *plugin;

	parent = g_file_get_parent (dest);
	path = g_file_get_path (parent);
	dir_name = g_file_get_basename (dest);
	
	clone_command = git_clone_command_new (path, repository_location, dir_name);
	plugin = ANJUTA_PLUGIN_GIT (obj);

	g_object_unref (parent);
	g_free (path);
	g_free (dir_name);

	git_pane_create_message_view (plugin);

	g_signal_connect (G_OBJECT (clone_command), "data-arrived",
	                  G_CALLBACK (git_pane_on_command_info_arrived),
	                  plugin);

	g_signal_connect (G_OBJECT (clone_command), "command-finished",
	                  G_CALLBACK (g_object_unref),
	                  NULL);

	if (cancel)
	{
		g_signal_connect_swapped (G_OBJECT (cancel), "cancelled",
		                          G_CALLBACK (anjuta_command_cancel),
		                          clone_command);
	}

	if (notify)
	{
		g_signal_connect_swapped (G_OBJECT (clone_command), 
		                          "command-finished",
		                          G_CALLBACK (anjuta_async_notify_notify_finished),
		                          notify);
	}

	anjuta_command_start (ANJUTA_COMMAND (clone_command));
}
Esempio n. 8
0
static void
on_log_command_finished (AnjutaCommand *command, guint return_code, 
						 GitLogPane *self)
{
	GtkTreeView *log_view;
	GQueue *queue;
	GtkTreeIter iter;
	GitRevision *revision;

	/* Show the actual log view */
	git_log_pane_set_view_mode (self, LOG_VIEW_NORMAL);
	
	if (return_code != 0)
	{
		git_pane_report_errors (command, return_code,
		                        ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self))));
		g_object_unref (command);
		
		return;
	}
	
	log_view = GTK_TREE_VIEW (gtk_builder_get_object (self->priv->builder, 
	                                                  "log_view"));
	
	g_object_ref (self->priv->log_model);
	gtk_tree_view_set_model (GTK_TREE_VIEW (log_view), NULL);
	
	queue = git_log_command_get_output_queue (GIT_LOG_COMMAND (command));
	
	while (g_queue_peek_head (queue))
	{
		revision = g_queue_pop_head (queue);
		
		gtk_list_store_append (self->priv->log_model, &iter);
		gtk_list_store_set (self->priv->log_model, &iter, LOG_COL_REVISION, 
		                    revision, -1);

		g_object_unref (revision);
	}
	
	giggle_graph_renderer_validate_model (GIGGLE_GRAPH_RENDERER (self->priv->graph_renderer),
										  GTK_TREE_MODEL (self->priv->log_model),
										  0);
	gtk_tree_view_set_model (GTK_TREE_VIEW (log_view), 
							 GTK_TREE_MODEL (self->priv->log_model));
	g_object_unref (self->priv->log_model);
	
	g_object_unref (command);
}
Esempio n. 9
0
void 
git_ivcs_diff (IAnjutaVcs *obj, GFile* file,  
			   IAnjutaVcsDiffCallback callback, gpointer user_data,  
			   GCancellable* cancel, AnjutaAsyncNotify *notify,
			   GError **err)
{
	gchar *project_root_directory;
	GitDiffCommand *diff_command;
	
	project_root_directory = ANJUTA_PLUGIN_GIT (obj)->project_root_directory;
	
	if (project_root_directory)
	{
		diff_command = git_diff_command_new (project_root_directory);
		
		g_object_set_data_full (G_OBJECT (diff_command), "file", 
		                        g_object_ref (file),
		                        (GDestroyNotify) g_object_unref);
		g_object_set_data (G_OBJECT (diff_command), "user-data", user_data);
		
		g_signal_connect (G_OBJECT (diff_command), "command-finished", 
		                  G_CALLBACK (g_object_unref),
		                  NULL);
		
		g_signal_connect (G_OBJECT (diff_command), "data-arrived",
		                  G_CALLBACK (on_diff_command_data_arrived),
		                  callback);
		
/* FIXME: Reenable when canceling is implemented. */
#if 0
		if (cancel)
		{
			g_signal_connect_swapped (G_OBJECT (cancel), "cancelled",
			                          G_CALLBACK (anjuta_command_cancel),
			                          diff_command);
		}
#endif
		
		if (notify)
		{
			g_signal_connect_swapped (G_OBJECT (diff_command), "command-finished",
			                          G_CALLBACK (anjuta_async_notify_notify_finished),
			                          notify);
		}
		
		anjuta_command_start (ANJUTA_COMMAND (diff_command));
	}
}
Esempio n. 10
0
static void
on_ok_action_activated (GtkAction *action, GitResetPane *self)
{
	Git *plugin;
	AnjutaEntry *reset_revision_entry;
	GtkToggleButton *mixed_radio;
	GtkToggleButton *soft_radio;
	const gchar *revision;
	GitResetTreeMode mode;
	GitResetTreeCommand *reset_command;

	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
	reset_revision_entry = ANJUTA_ENTRY (gtk_builder_get_object (self->priv->builder,
	                                                   			 "reset_revision_entry"));
	mixed_radio = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
	                                                         "mixed_radio"));
	soft_radio = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
	                                                        "soft_radio"));

	revision = anjuta_entry_get_text (reset_revision_entry);

	if (g_utf8_strlen (revision, -1) == 0)
		revision = GIT_RESET_TREE_PREVIOUS;

	if (gtk_toggle_button_get_active (mixed_radio))
		mode = GIT_RESET_TREE_MODE_MIXED;
	else if (gtk_toggle_button_get_active (soft_radio))
		mode = GIT_RESET_TREE_MODE_SOFT;
	else
		mode = GIT_RESET_TREE_MODE_HARD;

	reset_command = git_reset_tree_command_new (plugin->project_root_directory,
	                                            revision, mode);

	g_signal_connect (G_OBJECT (reset_command), "command-finished",
	                  G_CALLBACK (git_pane_report_errors),
	                  plugin);


	g_signal_connect (G_OBJECT (reset_command), "command-finished",
	                  G_CALLBACK (g_object_unref),
	                  NULL);

	anjuta_command_start (ANJUTA_COMMAND (reset_command));


	git_pane_remove_from_dock (GIT_PANE (self));
}
Esempio n. 11
0
static void
refresh_log (GitLogPane *self)
{
	Git *plugin;
	GtkTreeView *log_view;
	GtkTreeViewColumn *graph_column;

	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
	log_view = GTK_TREE_VIEW (gtk_builder_get_object (self->priv->builder,
	                                                  "log_view"));
	graph_column = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (self->priv->builder,
	                                                             "graph_column"));

	/* Unref the previous command if it's still running. */
	if (self->priv->log_command)
		g_object_unref (self->priv->log_command);

	gtk_tree_view_set_model (log_view, NULL);

	/* We don't support filters for now */
	self->priv->log_command = git_log_command_new (plugin->project_root_directory,
	                                               self->priv->selected_branch,
	                                               self->priv->path,
	                                               NULL,
	                                               NULL,
	                                               NULL,
	                                               NULL,
	                                               NULL,
	                                               NULL);

	/* Hide the graph column if we're looking at the log of a path. The graph
	 * won't be correct in this case. */
	if (self->priv->path)
		gtk_tree_view_column_set_visible (graph_column, FALSE);
	else
		gtk_tree_view_column_set_visible (graph_column, TRUE);

	g_signal_connect_object (G_OBJECT (self->priv->log_command), "command-finished",
	                         G_CALLBACK (on_log_command_finished),
	                         self, 0);

	gtk_list_store_clear (self->priv->log_model);

	/* Show the loading spinner */
	git_log_pane_set_view_mode (self, LOG_VIEW_LOADING);

	anjuta_command_start (ANJUTA_COMMAND (self->priv->log_command));
}
Esempio n. 12
0
static void
git_push_pane_dispose (GObject *object)
{
    GitPushPane *self;
    Git *plugin;

    self = GIT_PUSH_PANE (object);
    plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (object)));

    g_signal_handlers_disconnect_by_func (plugin->remotes_pane,
                                          on_remote_selected,
                                          self->priv->repository_selector);

    G_OBJECT_CLASS (git_push_pane_parent_class)->dispose (object);

}
Esempio n. 13
0
void 
git_ivcs_query_status (IAnjutaVcs *obj, GFile *file, 
					   IAnjutaVcsStatusCallback callback,
					   gpointer user_data, GCancellable *cancel,
					   AnjutaAsyncNotify *notify, GError **err)
{
	gchar *path;
	GitStatusCommand *status_command;

	path = g_file_get_path (file);
	status_command = git_status_command_new (path, ~0);

	g_free (path);

	g_object_set_data (G_OBJECT (status_command), "user-data", user_data);
	g_object_set_data_full (G_OBJECT (status_command), "working-directory",
	                        g_file_get_path (file),
	                        (GDestroyNotify) g_free);

	g_signal_connect (G_OBJECT (status_command), "data-arrived",
	                  G_CALLBACK (on_status_command_data_arrived),
	                  callback);

	g_signal_connect (G_OBJECT (status_command), "command-finished",
	                  G_CALLBACK (g_object_unref),
	                  NULL);

#if 0
	if (cancel)
	{
		g_signal_connect_swapped (G_OBJECT (cancel), "cancelled",
		                          G_CALLBACK (anjuta_command_cancel),
		                          status_command);
	}
#endif

	if (notify)
	{
		g_signal_connect_swapped (G_OBJECT (status_command), "command-finished",
		                          G_CALLBACK (anjuta_async_notify_notify_finished),
		                          notify);
	}

	anjuta_command_queue_push (ANJUTA_PLUGIN_GIT (obj)->command_queue,
	                           ANJUTA_COMMAND (status_command));
}
Esempio n. 14
0
static void
on_ok_action_activated (GtkAction *action, GitStashChangesPane *self)
{
	Git *plugin;
	AnjutaColumnTextView *message_view;
	GtkToggleButton *stash_index_check;
	gchar *message;
	GitStashSaveCommand *save_command;

	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
	message_view = ANJUTA_COLUMN_TEXT_VIEW (gtk_builder_get_object (self->priv->builder,
	                                                                "message_view"));
	stash_index_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
	                                                               "stash_index_check"));
	message = anjuta_column_text_view_get_text (message_view);

	/* Don't pass an empty message */
	if (!g_utf8_strlen (message, -1))
	{
		g_free (message);
		message = NULL;
	}

	save_command = git_stash_save_command_new (plugin->project_root_directory,
	                                           gtk_toggle_button_get_active (stash_index_check),
	                                           message);

	g_free (message);

	g_signal_connect (G_OBJECT (save_command), "command-finished",
	                  G_CALLBACK (git_pane_report_errors),
	                  plugin);


	g_signal_connect (G_OBJECT (save_command), "command-finished",
	                  G_CALLBACK (g_object_unref),
	                  NULL);

	anjuta_command_start (ANJUTA_COMMAND (save_command));
	

	git_pane_remove_from_dock (GIT_PANE (self));
	                            
}
Esempio n. 15
0
static gboolean
on_log_view_row_selected (GtkTreeSelection *selection, 
                          GtkTreeModel *model,
                          GtkTreePath *path, 
                          gboolean path_currently_selected,
                          GitLogPane *self)
{
	Git *plugin;
	GtkTreeIter iter;
	GitRevision *revision;
	gchar *sha;
	
	if (!path_currently_selected)
	{
		plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));

		gtk_tree_model_get_iter (model, &iter, path);
		gtk_tree_model_get (model, &iter, LOG_COL_REVISION, &revision, -1);
		sha = git_revision_get_sha (revision);

		/* Unref the previous command if it's still running. */
		if (self->priv->log_message_command)
			g_object_unref (self->priv->log_message_command);

		self->priv->log_message_command =
			git_log_message_command_new (plugin->project_root_directory, sha);
		
		g_free (sha);
		g_object_unref (revision);
		
		g_signal_connect_object (G_OBJECT (self->priv->log_message_command), "command-finished",
		                         G_CALLBACK (on_log_message_command_finished),
		                         self, 0);
		
		anjuta_command_start (ANJUTA_COMMAND (self->priv->log_message_command));
	}
	
	return TRUE;
}
Esempio n. 16
0
static void
git_log_pane_finalize (GObject *object)
{
	GitLogPane *self;
	Git *plugin;

	self = GIT_LOG_PANE (object);

	/* Disconnect signal handler from ref_command. */
	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
	g_signal_handlers_disconnect_by_func (G_OBJECT (plugin->ref_command),
	                                      on_ref_command_finished, self);

	g_clear_object (&self->priv->branch_list_command);
	g_clear_object (&self->priv->log_message_command);
	g_clear_object (&self->priv->log_command);

	/* Remove spin timer source. */
	if (self->priv->spin_timer_id > 0)
		g_source_remove (self->priv->spin_timer_id);

	g_object_unref (self->priv->builder);
	g_object_unref (self->priv->log_model);
	g_free (self->priv->path);
	g_hash_table_destroy (self->priv->branches_table);

	if (self->priv->refs)
		g_hash_table_unref (self->priv->refs);

	g_free (self->priv->selected_branch);

	if (self->priv->active_branch_path != NULL)
		gtk_tree_path_free (self->priv->active_branch_path);
	
	g_free (self->priv);

	G_OBJECT_CLASS (git_log_pane_parent_class)->finalize (object);
}
Esempio n. 17
0
static void
on_ref_command_finished (AnjutaCommand *command, guint return_code,
                         GitLogPane *self)
{
	Git *plugin;

	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));

	if (self->priv->refs)
		g_hash_table_unref (self->priv->refs);

	self->priv->refs = git_ref_command_get_refs (GIT_REF_COMMAND (command));

	/* Unref the previous command if it's still running. */
	if (self->priv->branch_list_command)
		g_object_unref (self->priv->branch_list_command);
	
	/* Refresh the branch display after the refs get updated */
	self->priv->branch_list_command =
		git_branch_list_command_new (plugin->project_root_directory,
		                             GIT_BRANCH_TYPE_ALL);

	g_signal_connect_object (G_OBJECT (self->priv->branch_list_command), "command-started",
	                         G_CALLBACK (on_branch_list_command_started),
	                         self, 0);

	g_signal_connect_object (G_OBJECT (self->priv->branch_list_command), "command-finished",
	                         G_CALLBACK (on_branch_list_command_finished),
	                         self, 0);

	g_signal_connect_object (G_OBJECT (self->priv->branch_list_command), "data-arrived",
	                         G_CALLBACK (on_branch_list_command_data_arrived),
	                         self, 0);

	anjuta_command_start (ANJUTA_COMMAND (self->priv->branch_list_command));
}
Esempio n. 18
0
static void
on_ok_action_activated (GtkAction *action, GitMergePane *self)
{
	Git *plugin;
	GtkEditable *merge_revision_entry;
	GtkToggleAction *no_commit_action;
	GtkToggleAction *squash_action;
	GtkToggleButton *use_custom_log_check;
	gchar *revision;
	gchar *log;
	AnjutaColumnTextView *merge_log_view;
	GitMergeCommand *merge_command;

	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
	merge_revision_entry = GTK_EDITABLE (gtk_builder_get_object (self->priv->builder,
	                                                   			 "merge_revision_entry"));
	no_commit_action = GTK_TOGGLE_ACTION (gtk_builder_get_object (self->priv->builder, 
	                                                              "no_commit_action"));
	squash_action = GTK_TOGGLE_ACTION (gtk_builder_get_object (self->priv->builder,
	                                                           "squash_action"));
	use_custom_log_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
	                                                                  "use_custom_log_check"));
	revision = gtk_editable_get_chars (merge_revision_entry, 0, -1);
	log = NULL;

	if (!git_pane_check_input (GTK_WIDGET (ANJUTA_PLUGIN (plugin)->shell),
	                           GTK_WIDGET (merge_revision_entry), revision,
	                           _("Please enter a revision.")))
	{
		g_free (revision);
		return;
	}

	if (gtk_toggle_button_get_active (use_custom_log_check))
	{
		merge_log_view = ANJUTA_COLUMN_TEXT_VIEW (gtk_builder_get_object (self->priv->builder,
		                                                        		  "merge_log_view"));
		log = anjuta_column_text_view_get_text (merge_log_view);

		if (!git_pane_check_input (GTK_WIDGET (ANJUTA_PLUGIN (plugin)->shell),
		                           GTK_WIDGET (merge_log_view), log,
		                           _("Please enter a log message.")))
		{
			g_free (revision);
			g_free (log);
			return;
		}
	}

	merge_command = git_merge_command_new (plugin->project_root_directory, 
	                                       revision, log,
	                                       gtk_toggle_action_get_active (no_commit_action),
	                                       gtk_toggle_action_get_active (squash_action));

	g_free (revision);
	g_free (log);

	git_pane_create_message_view (plugin);

	g_signal_connect (G_OBJECT (merge_command), "data-arrived",
	                  G_CALLBACK (git_pane_on_command_info_arrived),
	                  plugin);

	g_signal_connect (G_OBJECT (merge_command), "command-finished",
	                  G_CALLBACK (git_pane_report_errors),
	                  plugin);

	g_signal_connect (G_OBJECT (merge_command), "command-finished",
	                  G_CALLBACK (g_object_unref),
	                  NULL);

	anjuta_command_start (ANJUTA_COMMAND (merge_command));
	                                       

	git_pane_remove_from_dock (GIT_PANE (self));
}
Esempio n. 19
0
static void
on_log_pane_drag_data_received (GtkWidget *widget,
                                GdkDragContext *context, gint x, gint y,
                                GtkSelectionData *data, guint target_type,
                                guint time, GitLogPane *self)
{
	Git *plugin;
	AnjutaEntry *path_entry;
	gboolean success;
	gchar **uri_list;
	GFile *parent_file;
	GFile *file;
	gchar *path;

	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
	path_entry = ANJUTA_ENTRY (gtk_builder_get_object (self->priv->builder,
	                                                   "path_entry"));
	success = FALSE;

	if ((data != NULL) && 
	    (gtk_selection_data_get_length (data) >= 0))
	{
		if (target_type == 0)
		{
			uri_list = gtk_selection_data_get_uris (data);
			parent_file = NULL;
			
			parent_file = g_file_new_for_path (plugin->project_root_directory);

			/* Take only the first file */
			file = g_file_new_for_uri (uri_list[0]);

			if (parent_file)
			{
				path = g_file_get_relative_path (parent_file, file);

				g_object_unref (parent_file);
			}
			else
				path = g_file_get_path (file);

			if (path)
			{
				anjuta_entry_set_text (path_entry, path);

				g_free (self->priv->path);
				self->priv->path = g_strdup (path);

				refresh_log (self);

				g_free (path);
			}
			
			success = TRUE;

			g_object_unref (file);
			g_strfreev (uri_list);
		}
	}

	/* Do not delete source data */
	gtk_drag_finish (context, success, FALSE, time);
}
Esempio n. 20
0
static void
on_ok_action_activated (GtkAction *action, GitPushPane *self)
{
    Git *plugin;
    GtkTreeModel *push_branch_model;
    GtkTreeModel *push_tag_model;
    GtkToggleButton *push_all_tags_check;
    GtkToggleButton *push_all_check;
    GtkToggleAction *force_action;
    GList *selected_items;
    gboolean push_all_tags;
    gboolean push_all;
    gchar *repository;
    GitPushCommand *push_command;

    plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
    push_branch_model = GTK_TREE_MODEL (gtk_builder_get_object (self->priv->builder,
                                        "push_branch_model"));
    push_tag_model = GTK_TREE_MODEL (gtk_builder_get_object (self->priv->builder,
                                     "push_tag_model"));
    push_all_tags_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
                          "push_all_tags_check"));
    push_all_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
                                        "push_all_check"));
    force_action = GTK_TOGGLE_ACTION (gtk_builder_get_object (self->priv->builder,
                                      "force_action"));
    selected_items = NULL;
    push_all_tags = gtk_toggle_button_get_active (push_all_tags_check);
    push_all = gtk_toggle_button_get_active (push_all_check);

    /* Check that the user has given a valid repository. In this case we only
     * care about checking if the selector widget is in URL mode, because even
     * if a remote isn't selected, it will default to origin, so we should
     * always get something when the selector is in Remote mode. */
    repository = git_repository_selector_get_repository (GIT_REPOSITORY_SELECTOR (self->priv->repository_selector));

    if (!git_pane_check_input (GTK_WIDGET (ANJUTA_PLUGIN (plugin)->shell),
                               self->priv->repository_selector, repository,
                               _("Please enter a URL.")))
    {
        g_free (repository);
        return;
    }

    if (!push_all)
    {
        /* Get selected branches */
        gtk_tree_model_foreach (push_branch_model,
                                (GtkTreeModelForeachFunc) get_selected_items,
                                &selected_items);
    }

    /* Don't bother getting selected tags if Push all tags is checked or if
     * Push all branches and tags is checked */
    if (!push_all && !push_all_tags)
    {
        /* Get selected tags */
        gtk_tree_model_foreach (push_tag_model,
                                (GtkTreeModelForeachFunc) get_selected_items,
                                &selected_items);
    }

    push_command = git_push_command_new (plugin->project_root_directory,
                                         repository, selected_items,
                                         push_all, push_all_tags,
                                         gtk_toggle_action_get_active (force_action));

    g_free (repository);
    anjuta_util_glist_strings_free (selected_items);

    git_pane_create_message_view (plugin);

    g_signal_connect (G_OBJECT (push_command), "data-arrived",
                      G_CALLBACK (git_pane_on_command_info_arrived),
                      plugin);

    g_signal_connect (G_OBJECT (push_command), "command-finished",
                      G_CALLBACK (git_pane_report_errors),
                      plugin);

    g_signal_connect (G_OBJECT (push_command), "command-finished",
                      G_CALLBACK (git_plugin_status_changed_emit),
                      plugin);

    g_signal_connect (G_OBJECT (push_command), "command-finished",
                      G_CALLBACK (g_object_unref),
                      NULL);

    anjuta_command_start (ANJUTA_COMMAND (push_command));

    git_pane_remove_from_dock (GIT_PANE (self));
}
Esempio n. 21
0
static void
on_ok_action_activated (GtkAction *action, GitDeleteBranchesPane *self)
{
	Git *plugin;
	GtkToggleButton *require_merged_check;
	GList *selected_local_branches;
	GList *selected_remote_branches;
	GitBranchDeleteCommand *local_delete_command;
	GitBranchDeleteCommand *remote_delete_command;
	AnjutaCommandQueue *queue;

	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
	require_merged_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (self->priv->builder,
	                                                                  "require_merged_check"));
	selected_local_branches = git_branches_pane_get_selected_local_branches (GIT_BRANCHES_PANE (plugin->branches_pane));
	selected_remote_branches = git_branches_pane_get_selected_remote_branches (GIT_BRANCHES_PANE (plugin->branches_pane));

	/* The user might not have selected anything */
	if (git_branches_pane_count_selected_items (GIT_BRANCHES_PANE (plugin->branches_pane)) > 0)
	{
		queue = anjuta_command_queue_new (ANJUTA_COMMAND_QUEUE_EXECUTE_MANUAL);
		
		if (selected_local_branches)
		{
			local_delete_command = git_branch_delete_command_new (plugin->project_root_directory,
			                                                      selected_local_branches,
			                                                      FALSE,
			                                                      gtk_toggle_button_get_active (require_merged_check));

			anjuta_util_glist_strings_free (selected_local_branches);

			g_signal_connect (G_OBJECT (local_delete_command), 
			                  "command-finished",
			                  G_CALLBACK (git_pane_report_errors),
			                  plugin);
			

			g_signal_connect (G_OBJECT (local_delete_command), 
			                  "command-finished",
			                  G_CALLBACK (g_object_unref),
			                  NULL);

			anjuta_command_queue_push (queue, 
			                           ANJUTA_COMMAND (local_delete_command));
		}

		if (selected_remote_branches)
		{
			remote_delete_command = git_branch_delete_command_new (plugin->project_root_directory,
			                                                       selected_remote_branches,
			                                                       TRUE,
			                                                       gtk_toggle_button_get_active (require_merged_check));

			anjuta_util_glist_strings_free (selected_remote_branches);

			g_signal_connect (G_OBJECT (remote_delete_command), 
			                  "command-finished",
			                  G_CALLBACK (git_pane_report_errors),
			                  plugin);


			g_signal_connect (G_OBJECT (remote_delete_command), "command-finished",
			                  G_CALLBACK (g_object_unref),
			                  NULL);
			
			anjuta_command_queue_push (queue, 
			                           ANJUTA_COMMAND (remote_delete_command));
		}

		/* Run the commands */
		g_signal_connect (G_OBJECT (queue), "finished",
		                  G_CALLBACK (g_object_unref),
		                  NULL);

		anjuta_command_queue_start (queue);
	}


	git_pane_remove_from_dock (GIT_PANE (self));
	                            
}
Esempio n. 22
0
static void
on_status_view_drag_data_received (GtkWidget *widget,
                            	   GdkDragContext *context, gint x, gint y,
                                   GtkSelectionData *data, guint target_type,
                                   guint time, GitStatusPane *self)
{
	Git *plugin;
	gboolean success;
	gchar **uri_list;
	int i;
	GFile *file;
	gchar *path;
	GList *paths;
	GitAddCommand *add_command;

	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
	success = FALSE;
	path = NULL;
	paths = NULL;

	if ((data != NULL) && 
	    (gtk_selection_data_get_length (data) >= 0))
	{
		if (target_type == 0)
		{
			uri_list = gtk_selection_data_get_uris (data);

			for (i = 0; uri_list[i]; i++)
			{
				file = g_file_new_for_uri (uri_list[i]);
				path = g_file_get_path (file);

				if (path && !g_file_test (path, G_FILE_TEST_IS_DIR))
				{
					paths = g_list_append (paths, 
					                       g_strdup (path +
					                                 strlen (plugin->project_root_directory) + 1));
				}

				g_free (path);
				g_object_unref (file);
			}


			add_command = git_add_command_new_list (plugin->project_root_directory,
			                                        paths, FALSE);

			g_signal_connect (G_OBJECT (add_command), "command-finished",
			                  G_CALLBACK (g_object_unref),
			                  NULL);

			anjuta_command_start (ANJUTA_COMMAND (add_command));
			success = TRUE;

			anjuta_util_glist_strings_free (paths);
			g_strfreev (uri_list);
		}
	}

	/* Do not delete source data */
	gtk_drag_finish (context, success, FALSE, time);
}