Beispiel #1
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));
}
Beispiel #2
0
AnjutaDockPane *
git_status_pane_new (Git *plugin)
{
	GitStatusPane *self;
	GtkTreeView *status_view;

	self = g_object_new (GIT_TYPE_STATUS_PANE, "plugin", plugin, NULL);
	status_view = GTK_TREE_VIEW (gtk_builder_get_object (self->priv->builder,
														 "status_view"));

	g_signal_connect_swapped (G_OBJECT (plugin->commit_status_command), 
	                          "command-started",
	                          G_CALLBACK (git_status_pane_clear),
	                          self);

	/* Expand the placeholders so something is visible to the user after 
	 * refreshing */
	g_signal_connect_swapped (G_OBJECT (plugin->not_updated_status_command),
	                          "command-finished",
	                          G_CALLBACK (gtk_tree_view_expand_all),
	                          status_view);

	g_signal_connect (G_OBJECT (plugin->commit_status_command),
	                  "data-arrived",
	                  G_CALLBACK (on_commit_status_data_arrived),
	                  self);

	g_signal_connect (G_OBJECT (plugin->not_updated_status_command),
	                  "data-arrived",
	                  G_CALLBACK (on_not_updated_status_data_arrived),
	                  self);

	return ANJUTA_DOCK_PANE (self);
}
Beispiel #3
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));
	                            
}
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));
}
Beispiel #5
0
static gboolean
on_log_view_button_press_event (GtkWidget *log_view, GdkEventButton *event,
                                GitLogPane *self)
{
	GtkMenu *menu;
	GtkTreeSelection *selection;
	AnjutaPlugin *plugin;
	AnjutaUI *ui;

	if (event->type == GDK_BUTTON_PRESS && event->button == 3)
	{
		selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (log_view));

		if (gtk_tree_selection_count_selected_rows (selection) > 0)
		{
			plugin = anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self));
			ui = anjuta_shell_get_ui (plugin->shell, NULL);

			menu = GTK_MENU (gtk_ui_manager_get_widget (GTK_UI_MANAGER (ui),
			                                            "/GitLogPopup"));

			gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event->button, 
			                event->time);
		}
	}

	return FALSE;
}
Beispiel #6
0
static void
on_branch_list_command_data_arrived (AnjutaCommand *command,
                                     GitLogPane *self)
{
	GtkListStore *log_branch_combo_model;
	AnjutaPlugin *plugin;
	GList *current_branch;
	GitBranch *branch;
	gchar *name;
	GtkTreeIter iter;

	log_branch_combo_model = GTK_LIST_STORE (gtk_builder_get_object (self->priv->builder,
	                                                                 "log_branch_combo_model"));
	plugin = anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self));
	current_branch = git_branch_list_command_get_output (GIT_BRANCH_LIST_COMMAND (command));

	while (current_branch)
	{
		branch = current_branch->data;
		name = git_branch_get_name (branch);

		gtk_list_store_append (log_branch_combo_model, &iter);

		if (git_branch_is_active (branch))
		{
			gtk_list_store_set (log_branch_combo_model, &iter,
			                    BRANCH_COL_ACTIVE, TRUE,
			                    BRANCH_COL_ACTIVE_ICON, GTK_STOCK_APPLY,
			                    -1);

			self->priv->active_branch_iter = iter;
		}
		else
		{
			gtk_list_store_set (log_branch_combo_model, &iter,
			                    BRANCH_COL_ACTIVE, FALSE,
			                    BRANCH_COL_ACTIVE_ICON, NULL,
			                    -1);
		}

		gtk_list_store_set (log_branch_combo_model, &iter, 
		                    BRANCH_COL_NAME, name, 
		                    -1);
		g_hash_table_insert (self->priv->branches_table, g_strdup (name), 
		                     g_memdup (&iter, sizeof (GtkTreeIter)));

		g_free (name);
		
		current_branch = g_list_next (current_branch);
	}
	
}
Beispiel #7
0
AnjutaDockPane *
git_log_pane_new (Git *plugin)
{
	GitLogPane *self;

	self = g_object_new (GIT_TYPE_LOG_PANE, "plugin", plugin, NULL);

	g_signal_connect_object (G_OBJECT (plugin->ref_command), "command-finished",
	                         G_CALLBACK (on_ref_command_finished),
	                         self, 0);

	return ANJUTA_DOCK_PANE (self);
}
Beispiel #8
0
static gboolean
on_status_view_button_press_event (GtkWidget *widget, GdkEvent *event,
                                   GitStatusPane *self)
{
	GdkEventButton *button_event;
	AnjutaPlugin *plugin;
	AnjutaUI *ui;
	GtkTreeView *status_view;
	GtkTreeSelection *selection;
	GtkTreeModel *status_model;
	GtkTreeIter iter;
	StatusType status_type;
	GtkMenu *menu;

	button_event = (GdkEventButton *) event;
	menu = NULL;
	
	if (button_event->type == GDK_BUTTON_PRESS && button_event->button == 3)
	{
		plugin = anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self));
		ui = anjuta_shell_get_ui (plugin->shell, NULL);
		status_view = GTK_TREE_VIEW (gtk_builder_get_object (self->priv->builder,
		                                                     "status_view"));
		selection = gtk_tree_view_get_selection (status_view);

		if (gtk_tree_selection_get_selected (selection, &status_model, &iter))
		{
			gtk_tree_model_get (status_model, &iter, COL_TYPE, &status_type, 
			                    -1);

			if (status_type == STATUS_TYPE_COMMIT)
			{
				menu = GTK_MENU (gtk_ui_manager_get_widget (GTK_UI_MANAGER (ui),
				                              			    "/GitStatusCommitPopup"));
			}
			else if (status_type == STATUS_TYPE_NOT_UPDATED)
			{
				menu = GTK_MENU (gtk_ui_manager_get_widget (GTK_UI_MANAGER (ui),
				                              				"/GitStatusNotUpdatedPopup"));
			}

			if (menu)
			{
				gtk_menu_popup (menu, NULL, NULL, NULL, NULL, button_event->button, 
				                button_event->time);
			}
		}
	}

	return FALSE;
}
Beispiel #9
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);
}
Beispiel #10
0
AnjutaDockPane *
git_merge_pane_new_with_revision (Git *plugin, const gchar *revision)
{
	GitMergePane *self;
	AnjutaEntry *merge_revision_entry;

	self = g_object_new (GIT_TYPE_MERGE_PANE, "plugin", plugin, NULL);;
	merge_revision_entry = ANJUTA_ENTRY (gtk_builder_get_object (self->priv->builder,
	                                           					 "merge_revision_entry"));

	anjuta_entry_set_text (merge_revision_entry, revision);

	return ANJUTA_DOCK_PANE (self);
}
Beispiel #11
0
AnjutaDockPane *
git_reset_pane_new_with_sha (Git *plugin, const gchar *sha)
{
	GitResetPane *self;
	AnjutaEntry *reset_revision_entry;

	self = g_object_new (GIT_TYPE_RESET_PANE, "plugin", plugin, NULL);
	reset_revision_entry = ANJUTA_ENTRY (gtk_builder_get_object (self->priv->builder,
	                                                             "reset_revision_entry"));

	anjuta_entry_set_text (reset_revision_entry, sha);

	return ANJUTA_DOCK_PANE (self);
}
Beispiel #12
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);
}
Beispiel #13
0
AnjutaDockPane *
git_remove_files_pane_new (Git *plugin)
{
	GitRemoveFilesPane *self;
	AnjutaFileList *file_list;

	self = g_object_new (GIT_TYPE_REMOVE_FILES_PANE, "plugin", plugin, NULL);
	file_list = ANJUTA_FILE_LIST (gtk_builder_get_object (self->priv->builder,
	                                                      "file_list"));

	anjuta_file_list_set_relative_path (file_list, 
	                                    plugin->project_root_directory);

	return ANJUTA_DOCK_PANE (self);
}
Beispiel #14
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));
}
Beispiel #15
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));
}
Beispiel #16
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);

}
Beispiel #17
0
AnjutaDockPane *
git_push_pane_new (Git *plugin)
{
    GitPushPane *self;
    GtkListStore *push_branch_model;
    GtkListStore *push_tag_model;
    GitBranchListCommand *branch_list_command;
    GitTagListCommand *tag_list_command;

    self = g_object_new (GIT_TYPE_PUSH_PANE, "plugin", plugin, NULL);
    push_branch_model = GTK_LIST_STORE (gtk_builder_get_object (self->priv->builder,
                                        "push_branch_model"));
    push_tag_model = GTK_LIST_STORE (gtk_builder_get_object (self->priv->builder,
                                     "push_tag_model"));
    branch_list_command = git_branch_list_command_new (plugin->project_root_directory,
                          GIT_BRANCH_TYPE_LOCAL);
    tag_list_command = git_tag_list_command_new (plugin->project_root_directory);

    g_signal_connect (G_OBJECT (plugin->remotes_pane), "single-selection-changed",
                      G_CALLBACK (on_remote_selected),
                      self->priv->repository_selector);

    g_signal_connect (G_OBJECT (branch_list_command), "data-arrived",
                      G_CALLBACK (on_branch_list_command_data_arrived),
                      push_branch_model);

    g_signal_connect (G_OBJECT (tag_list_command), "data-arrived",
                      G_CALLBACK (on_tag_list_command_data_arrived),
                      push_tag_model);

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

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

    /* Set the contents of the selected remote label */
    on_remote_selected (plugin->remotes_pane,
                        GIT_REPOSITORY_SELECTOR (self->priv->repository_selector));

    anjuta_command_start (ANJUTA_COMMAND (branch_list_command));
    anjuta_command_start (ANJUTA_COMMAND (tag_list_command));

    return ANJUTA_DOCK_PANE (self);
}
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));
	                            
}
AnjutaDockPane *
git_delete_branches_pane_new (Git *plugin)
{
	GitDeleteBranchesPane *self;
	GtkWidget *delete_branches_pane;
	
	self = g_object_new (GIT_TYPE_DELETE_BRANCHES_PANE, "plugin", plugin, NULL);
	delete_branches_pane = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
	                                                           "delete_branches_pane"));

	g_signal_connect (G_OBJECT (delete_branches_pane), "map",
	                  G_CALLBACK (on_delete_branches_pane_map),
	                  plugin->branches_pane);

	g_signal_connect (G_OBJECT (delete_branches_pane), "unmap",
	                  G_CALLBACK (on_delete_branches_pane_unmap),
	                  plugin->branches_pane);

	return ANJUTA_DOCK_PANE (self);
}
Beispiel #20
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;
}
Beispiel #21
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);
}
Beispiel #22
0
AnjutaDockPane *
git_stash_pane_new (Git *plugin)
{
	GitStashPane *self;
	GtkListStore *stash_list_model;

	self = g_object_new (GIT_TYPE_STASH_PANE, "plugin", plugin, NULL);
	stash_list_model = GTK_LIST_STORE (gtk_builder_get_object (self->priv->builder,
	                                                           "stash_list_model"));

	g_signal_connect (G_OBJECT (plugin->stash_list_command), "command-started",
	                  G_CALLBACK (on_stash_list_command_started),
	                  self);

	g_signal_connect (G_OBJECT (plugin->stash_list_command), "command-finished",
	                  G_CALLBACK (on_stash_list_command_finished),
	                  self);

	g_signal_connect (G_OBJECT (plugin->stash_list_command), "data-arrived",
	                  G_CALLBACK (on_stash_list_command_data_arrived),
	                  stash_list_model);

	return ANJUTA_DOCK_PANE (self);
}
Beispiel #23
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));
}
Beispiel #24
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));
}
Beispiel #25
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);
}
Beispiel #26
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));
}
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));
	                            
}
Beispiel #28
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);
}