[gitg] Bit of code cleanup
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Bit of code cleanup
- Date: Sat, 29 May 2010 16:26:21 +0000 (UTC)
commit ffa32f035a4d3974dd4e41ace2b8f578050559a4
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Sat May 29 18:00:00 2010 +0200
Bit of code cleanup
gitg/gitg-branch-actions.c | 28 +++---
gitg/gitg-commit-view.c | 121 +++++++++++++++---------
gitg/gitg-commit.c | 54 ++++++++---
gitg/gitg-dnd.c | 16 ++-
gitg/gitg-lanes.c | 2 +-
gitg/gitg-preferences-dialog.c | 46 ++++++++--
gitg/gitg-repository-dialog.c | 51 +++++++++-
gitg/gitg-runner.c | 30 ++++---
gitg/gitg-window.c | 205 ++++++++++++++++++++++++---------------
gitg/gitg.c | 82 ++++++++--------
10 files changed, 408 insertions(+), 227 deletions(-)
---
diff --git a/gitg/gitg-branch-actions.c b/gitg/gitg-branch-actions.c
index b355066..6988036 100644
--- a/gitg/gitg-branch-actions.c
+++ b/gitg/gitg-branch-actions.c
@@ -1671,14 +1671,12 @@ on_cherry_pick_result (GitgWindow *window,
if (progress == GITG_PROGRESS_ERROR)
{
- gchar const *message;
-
message_dialog (window,
- GTK_MESSAGE_ERROR,
- _("Failed to cherry-pick on <%s>"),
- NULL,
- NULL,
- gitg_ref_get_shortname (info->dest));
+ GTK_MESSAGE_ERROR,
+ _("Failed to cherry-pick on <%s>"),
+ NULL,
+ NULL,
+ gitg_ref_get_shortname (info->dest));
}
else if (progress == GITG_PROGRESS_SUCCESS)
{
@@ -1850,14 +1848,12 @@ on_format_patch_result (GitgWindow *window,
if (progress == GITG_PROGRESS_ERROR)
{
- gchar const *message;
-
message_dialog (window,
- GTK_MESSAGE_ERROR,
- _("Failed to generate format-patch"),
- NULL,
- NULL,
- NULL);
+ GTK_MESSAGE_ERROR,
+ _("Failed to generate format-patch"),
+ NULL,
+ NULL,
+ NULL);
}
format_patch_info_free (info);
@@ -1903,7 +1899,9 @@ gitg_branch_actions_format_patch (GitgWindow *window,
message = g_strdup_printf (_("Generating format-patch for <%s>"),
gitg_revision_get_subject (revision));
- FormatPatchInfo *info = format_patch_info_new (revision, destination, G_OUTPUT_STREAM (stream));
+ FormatPatchInfo *info = format_patch_info_new (revision,
+ destination,
+ G_OUTPUT_STREAM (stream));
ret = run_progress (window,
_("Format patch"),
diff --git a/gitg/gitg-commit-view.c b/gitg/gitg-commit-view.c
index 176b570..c4308ec 100644
--- a/gitg/gitg-commit-view.c
+++ b/gitg/gitg-commit-view.c
@@ -456,79 +456,110 @@ unstaged_selection_changed(GtkTreeSelection *selection, GitgCommitView *view)
view->priv->is_diff = TRUE;
connect_update(view);
- gchar *path = gitg_repository_relative(view->priv->repository, f);
+ gchar *path = gitg_repository_relative (view->priv->repository, f);
gchar ct[10];
- g_snprintf(ct, sizeof(ct), "-U%d", view->priv->context_size);
-
- gitg_repository_run_commandv(view->priv->repository, view->priv->runner, NULL, "diff", "--no-color", ct, "--", path, NULL);
- g_free(path);
+ g_snprintf (ct, sizeof(ct), "-U%d", view->priv->context_size);
+
+ gitg_repository_run_commandv (view->priv->repository,
+ view->priv->runner,
+ NULL,
+ "diff",
+ "--no-color",
+ ct,
+ "--",
+ path,
+ NULL);
+ g_free (path);
}
- set_current_file(view, file, GITG_CHANGED_FILE_CHANGES_UNSTAGED);
+ set_current_file (view, file, GITG_CHANGED_FILE_CHANGES_UNSTAGED);
- g_object_unref(file);
- g_object_unref(f);
+ g_object_unref (file);
+ g_object_unref (f);
}
static void
-staged_selection_changed(GtkTreeSelection *selection, GitgCommitView *view)
+staged_selection_changed (GtkTreeSelection *selection, GitgCommitView *view)
{
GtkTreeModel *model;
GtkTreeIter iter;
- if (!check_selection(view->priv->tree_view_staged, &iter, view))
+ if (!check_selection (view->priv->tree_view_staged, &iter, view))
return;
- model = gtk_tree_view_get_model(view->priv->tree_view_staged);
- unselect_tree_view(view->priv->tree_view_unstaged);
+ model = gtk_tree_view_get_model (view->priv->tree_view_staged);
+ unselect_tree_view (view->priv->tree_view_unstaged);
GitgChangedFile *file;
- gtk_tree_model_get(model, &iter, COLUMN_FILE, &file, -1);
- GitgChangedFileStatus status = gitg_changed_file_get_status(file);
+ gtk_tree_model_get (model, &iter, COLUMN_FILE, &file, -1);
+ GitgChangedFileStatus status = gitg_changed_file_get_status (file);
- GFile *f = gitg_changed_file_get_file(file);
- gchar *path = gitg_repository_relative(view->priv->repository, f);
+ GFile *f = gitg_changed_file_get_file (file);
+ gchar *path = gitg_repository_relative (view->priv->repository, f);
if (status == GITG_CHANGED_FILE_STATUS_NEW)
{
view->priv->is_diff = FALSE;
- gchar *content_type = gitg_utils_get_content_type(f);
+ gchar *content_type = gitg_utils_get_content_type (f);
- if (!gitg_utils_can_display_content_type(content_type))
+ if (!gitg_utils_can_display_content_type (content_type))
{
- show_binary_information(view);
+ show_binary_information (view);
}
else
{
- gchar *basename = g_file_get_basename(f);
- GtkSourceLanguage *language = gitg_utils_get_language(basename, content_type);
- g_free(basename);
+ gchar *basename;
+ GtkSourceLanguage *language;
- gtk_widget_set_sensitive(GTK_WIDGET(view->priv->hscale_context), FALSE);
+ basename = g_file_get_basename(f);
+ language = gitg_utils_get_language(basename,
+ content_type);
- connect_update(view);
+ g_free(basename);
- gchar *indexpath = g_strconcat(":0:", path, NULL);
- gitg_repository_run_commandv(view->priv->repository, view->priv->runner, NULL, "show", "--encoding=UTF-8", indexpath, NULL);
- g_free(indexpath);
+ gtk_widget_set_sensitive (GTK_WIDGET (view->priv->hscale_context),
+ FALSE);
+
+ connect_update (view);
+
+ gchar *indexpath = g_strconcat (":0:", path, NULL);
+ gitg_repository_run_commandv (view->priv->repository,
+ view->priv->runner,
+ NULL,
+ "show",
+ "--encoding=UTF-8",
+ "--no-color",
+ indexpath,
+ NULL);
+ g_free (indexpath);
}
- g_free(content_type);
+ g_free (content_type);
}
else
{
view->priv->is_diff = TRUE;
- set_diff_language(view);
- connect_update(view);
+ set_diff_language (view);
+ connect_update (view);
- gchar *head = gitg_repository_parse_head(view->priv->repository);
+ gchar *head = gitg_repository_parse_head (view->priv->repository);
gchar ct[10];
- g_snprintf(ct, sizeof(ct), "-U%d", view->priv->context_size);
-
- gitg_repository_run_commandv(view->priv->repository, view->priv->runner, NULL, "diff-index", ct, "--cached", head, "--", path, NULL);
+ g_snprintf (ct, sizeof(ct), "-U%d", view->priv->context_size);
+
+ gitg_repository_run_commandv (view->priv->repository,
+ view->priv->runner,
+ NULL,
+ "diff-index",
+ ct,
+ "--cached",
+ "--no-color",
+ head,
+ "--",
+ path,
+ NULL);
g_free(head);
}
@@ -1200,18 +1231,16 @@ gitg_commit_view_set_repository(GitgCommitView *view, GitgRepository *repository
static void
append_file(GtkListStore *store, GitgChangedFile *file, GitgCommitView *view)
{
- GFile *f = gitg_changed_file_get_file(file);
- GFile *repos = g_file_new_for_path(gitg_repository_get_path(view->priv->repository));
+ GFile *f = gitg_changed_file_get_file (file);
+ gchar *rel = gitg_repository_relative (view->priv->repository, f);
GtkTreeIter iter;
- gchar *rel = g_file_get_relative_path(repos, f);
- gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter, COLUMN_NAME, rel, COLUMN_FILE, file, -1);
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, COLUMN_NAME, rel, COLUMN_FILE, file, -1);
- g_free(rel);
- g_object_unref(repos);
- g_object_unref(f);
+ g_free (rel);
+ g_object_unref (f);
}
/* Callbacks */
@@ -1742,11 +1771,11 @@ on_unstage_changes(GtkAction *action, GitgCommitView *view)
}
}
-GtkWidget *
-create_context_menu_item(GitgCommitView *view, gchar const *action)
+static GtkWidget *
+create_context_menu_item (GitgCommitView *view, gchar const *action)
{
- GtkAction *ac = gtk_action_group_get_action(view->priv->group_context, action);
- return gtk_action_create_menu_item(ac);
+ GtkAction *ac = gtk_action_group_get_action (view->priv->group_context, action);
+ return gtk_action_create_menu_item (ac);
}
static void
diff --git a/gitg/gitg-commit.c b/gitg/gitg-commit.c
index 0c55cc7..5c96c91 100644
--- a/gitg/gitg-commit.c
+++ b/gitg/gitg-commit.c
@@ -555,15 +555,25 @@ refresh_changes(GitgCommit *commit, GitgChangedFile *file)
}
}
-gboolean
-apply_hunk(GitgCommit *commit, GitgChangedFile *file, gchar const *hunk, gboolean reverse, GError **error)
+static gboolean
+apply_hunk (GitgCommit *commit,
+ GitgChangedFile *file,
+ gchar const *hunk,
+ gboolean reverse,
+ GError **error)
{
- g_return_val_if_fail(GITG_IS_COMMIT(commit), FALSE);
- g_return_val_if_fail(GITG_IS_CHANGED_FILE(file), FALSE);
+ g_return_val_if_fail (GITG_IS_COMMIT(commit), FALSE);
+ g_return_val_if_fail (GITG_IS_CHANGED_FILE(file), FALSE);
- g_return_val_if_fail(hunk != NULL, FALSE);
+ g_return_val_if_fail (hunk != NULL, FALSE);
- gboolean ret = gitg_repository_command_with_inputv(commit->priv->repository, hunk, error, "apply", "--cached", reverse ? "--reverse" : NULL, NULL);
+ gboolean ret = gitg_repository_command_with_inputv (commit->priv->repository,
+ hunk,
+ error,
+ "apply",
+ "--cached",
+ reverse ? "--reverse" : NULL,
+ NULL);
if (ret)
refresh_changes(commit, file);
@@ -952,7 +962,15 @@ gitg_commit_revert(GitgCommit *commit, GitgChangedFile *file, gchar const *hunk,
GFile *f = gitg_changed_file_get_file(file);
gchar *path = gitg_repository_relative(commit->priv->repository, f);
- ret = gitg_repository_command_with_inputv(commit->priv->repository, path, error, "checkout-index", "--index", "--quiet", "--force", "--stdin", NULL);
+ ret = gitg_repository_command_with_inputv (commit->priv->repository,
+ path,
+ error,
+ "checkout-index",
+ "--index",
+ "--quiet",
+ "--force",
+ "--stdin",
+ NULL);
g_free(path);
@@ -994,19 +1012,25 @@ gitg_commit_add_ignore(GitgCommit *commit, GitgChangedFile *file, GError **error
if (stream)
{
gchar *line = g_strdup_printf("/%s\n", path);
- ret = g_output_stream_write_all(G_OUTPUT_STREAM(stream), line, strlen(line), NULL, NULL, error);
- g_output_stream_close(G_OUTPUT_STREAM(stream), NULL, NULL);
- g_object_unref(stream);
- g_free(line);
+ ret = g_output_stream_write_all (G_OUTPUT_STREAM (stream),
+ line,
+ strlen (line),
+ NULL,
+ NULL,
+ error);
+
+ g_output_stream_close (G_OUTPUT_STREAM (stream), NULL, NULL);
+
+ g_object_unref (stream);
+ g_free (line);
}
if (ret)
- remove_file(commit, file);
+ remove_file (commit, file);
- g_object_unref(f);
- g_free(ignore);
- g_free(path);
+ g_object_unref (f);
+ g_free (path);
return ret;
}
diff --git a/gitg/gitg-dnd.c b/gitg/gitg-dnd.c
index 9367bf3..312fc2a 100644
--- a/gitg/gitg-dnd.c
+++ b/gitg/gitg-dnd.c
@@ -815,7 +815,7 @@ get_xds_filename (GdkDragContext *context)
return NULL;
}
- guint len;
+ gint len;
gchar *ret = NULL;
if (gdk_property_get (context->source_window,
@@ -877,7 +877,7 @@ gitg_drag_source_data_get_cb (GtkWidget *widget,
gtk_selection_data_set (selection,
selection->target,
8,
- "S",
+ (guchar const *)"S",
1);
}
else
@@ -885,7 +885,7 @@ gitg_drag_source_data_get_cb (GtkWidget *widget,
gtk_selection_data_set (selection,
selection->target,
8,
- "E",
+ (guchar const *)"E",
1);
}
@@ -904,9 +904,15 @@ gitg_drag_source_data_get_cb (GtkWidget *widget,
break;
case DRAG_TARGET_TREEISH:
{
- gchar *treeish = revision_to_treeish (repository, data->revision);
+ gchar *treeish = revision_to_treeish (repository,
+ data->revision);
+
+ gtk_selection_data_set (selection,
+ selection->target,
+ 8,
+ (guchar const *)treeish,
+ strlen (treeish));
- gtk_selection_data_set (selection, selection->target, 8, treeish, strlen (treeish));
g_free (treeish);
}
break;
diff --git a/gitg/gitg-lanes.c b/gitg/gitg-lanes.c
index 606747e..a1a73ad 100644
--- a/gitg/gitg-lanes.c
+++ b/gitg/gitg-lanes.c
@@ -274,7 +274,7 @@ lane_container_new(gchar const *from, gchar const *to)
return lane_container_new_with_color(from, to, NULL);
}
-GSList *
+static GSList *
lanes_list(GitgLanes *lanes)
{
GSList *lns = NULL;
diff --git a/gitg/gitg-preferences-dialog.c b/gitg/gitg-preferences-dialog.c
index 8fe6c18..e16180b 100644
--- a/gitg/gitg-preferences-dialog.c
+++ b/gitg/gitg-preferences-dialog.c
@@ -37,6 +37,18 @@ enum
N_COLUMNS
};
+void on_collapse_inactive_lanes_changed (GtkAdjustment *adjustment,
+ GParamSpec *spec,
+ GitgPreferencesDialog *dialog);
+
+gboolean on_entry_configuration_user_name_focus_out_event (GtkEntry *entry,
+ GdkEventFocus *event,
+ GitgPreferencesDialog *dialog);
+
+gboolean on_entry_configuration_user_email_focus_out_event (GtkEntry *entry,
+ GdkEventFocus *event,
+ GitgPreferencesDialog *dialog);
+
#define GITG_PREFERENCES_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_PREFERENCES_DIALOG, GitgPreferencesDialogPrivate))
static GitgPreferencesDialog *preferences_dialog;
@@ -271,29 +283,47 @@ gitg_preferences_dialog_present(GtkWindow *window)
}
void
-on_collapse_inactive_lanes_changed(GtkAdjustment *adjustment, GParamSpec *spec, GitgPreferencesDialog *dialog)
+on_collapse_inactive_lanes_changed (GtkAdjustment *adjustment,
+ GParamSpec *spec,
+ GitgPreferencesDialog *dialog)
{
gint val = round_val(gtk_adjustment_get_value(adjustment));
if (val > 0)
{
- g_signal_handlers_block_by_func(adjustment, G_CALLBACK(on_collapse_inactive_lanes_changed), dialog);
- gtk_adjustment_set_value(adjustment, val);
- g_signal_handlers_unblock_by_func(adjustment, G_CALLBACK(on_collapse_inactive_lanes_changed), dialog);
+ g_signal_handlers_block_by_func (adjustment,
+ on_collapse_inactive_lanes_changed,
+ dialog);
+
+ gtk_adjustment_set_value (adjustment, val);
+
+ g_signal_handlers_unblock_by_func (adjustment,
+ on_collapse_inactive_lanes_changed,
+ dialog);
}
}
gboolean
-on_entry_configuration_user_name_focus_out_event(GtkEntry *entry, GdkEventFocus *event, GitgPreferencesDialog *dialog)
+on_entry_configuration_user_name_focus_out_event (GtkEntry *entry,
+ GdkEventFocus *event,
+ GitgPreferencesDialog *dialog)
{
- gitg_config_set_value (dialog->priv->config, "user.name", gtk_entry_get_text (entry));
+ gitg_config_set_value (dialog->priv->config,
+ "user.name",
+ gtk_entry_get_text (entry));
+
return FALSE;
}
gboolean
-on_entry_configuration_user_email_focus_out_event(GtkEntry *entry, GdkEventFocus *event, GitgPreferencesDialog *dialog)
+on_entry_configuration_user_email_focus_out_event (GtkEntry *entry,
+ GdkEventFocus *event,
+ GitgPreferencesDialog *dialog)
{
- gitg_config_set_value (dialog->priv->config, "user.email", gtk_entry_get_text (entry));
+ gitg_config_set_value (dialog->priv->config,
+ "user.email",
+ gtk_entry_get_text (entry));
+
return FALSE;
}
diff --git a/gitg/gitg-repository-dialog.c b/gitg/gitg-repository-dialog.c
index 1284927..9de419d 100644
--- a/gitg/gitg-repository-dialog.c
+++ b/gitg/gitg-repository-dialog.c
@@ -29,6 +29,33 @@
#include "gitg-config.h"
#include "gitg-spinner.h"
+void on_button_fetch_remote_clicked (GtkButton *button,
+ GitgRepositoryDialog *dialog);
+
+void on_button_remove_remote_clicked (GtkButton *button,
+ GitgRepositoryDialog *dialog);
+
+void on_button_add_remote_clicked (GtkButton *button,
+ GitgRepositoryDialog *dialog);
+
+gboolean on_entry_repository_user_name_focus_out_event (GtkEntry *entry,
+ GdkEventFocus *focus,
+ GitgRepositoryDialog *dialog);
+
+gboolean on_entry_repository_user_email_focus_out_event (GtkEntry *entry,
+ GdkEventFocus *focus,
+ GitgRepositoryDialog *dialog);
+
+void on_remote_name_edited (GtkCellRendererText *renderer,
+ gchar *path,
+ gchar *new_text,
+ GitgRepositoryDialog *dialog);
+
+void on_remote_url_edited (GtkCellRendererText *renderer,
+ gchar *path,
+ gchar *new_text,
+ GitgRepositoryDialog *dialog);
+
#define GITG_REPOSITORY_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GITG_TYPE_REPOSITORY_DIALOG, GitgRepositoryDialogPrivate))
static GitgRepositoryDialog *repository_dialog = NULL;
@@ -576,7 +603,8 @@ remove_remote (GitgRepositoryDialog *dialog, gchar const *name)
}
void
-on_button_remove_remote_clicked (GtkButton *button, GitgRepositoryDialog *dialog)
+on_button_remove_remote_clicked (GtkButton *button,
+ GitgRepositoryDialog *dialog)
{
GtkTreeSelection *selection;
GtkTreeModel *model;
@@ -626,7 +654,8 @@ on_button_remove_remote_clicked (GtkButton *button, GitgRepositoryDialog *dialog
}
void
-on_button_add_remote_clicked (GtkButton *button, GitgRepositoryDialog *dialog)
+on_button_add_remote_clicked (GtkButton *button,
+ GitgRepositoryDialog *dialog)
{
GtkTreeModel *model = GTK_TREE_MODEL (dialog->priv->list_store_remotes);
GtkTreeIter iter;
@@ -678,7 +707,9 @@ on_button_add_remote_clicked (GtkButton *button, GitgRepositoryDialog *dialog)
}
gboolean
-on_entry_repository_user_name_focus_out_event (GtkEntry *entry, GdkEventFocus *focus, GitgRepositoryDialog *dialog)
+on_entry_repository_user_name_focus_out_event (GtkEntry *entry,
+ GdkEventFocus *focus,
+ GitgRepositoryDialog *dialog)
{
gchar const *text;
@@ -689,7 +720,9 @@ on_entry_repository_user_name_focus_out_event (GtkEntry *entry, GdkEventFocus *f
}
gboolean
-on_entry_repository_user_email_focus_out_event (GtkEntry *entry, GdkEventFocus *focus, GitgRepositoryDialog *dialog)
+on_entry_repository_user_email_focus_out_event (GtkEntry *entry,
+ GdkEventFocus *focus,
+ GitgRepositoryDialog *dialog)
{
gchar const *text;
@@ -700,7 +733,10 @@ on_entry_repository_user_email_focus_out_event (GtkEntry *entry, GdkEventFocus *
}
void
-on_remote_name_edited(GtkCellRendererText *renderer, gchar *path, gchar *new_text, GitgRepositoryDialog *dialog)
+on_remote_name_edited (GtkCellRendererText *renderer,
+ gchar *path,
+ gchar *new_text,
+ GitgRepositoryDialog *dialog)
{
if (!*new_text)
{
@@ -742,7 +778,10 @@ on_remote_name_edited(GtkCellRendererText *renderer, gchar *path, gchar *new_tex
}
void
-on_remote_url_edited(GtkCellRendererText *renderer, gchar *path, gchar *new_text, GitgRepositoryDialog *dialog)
+on_remote_url_edited (GtkCellRendererText *renderer,
+ gchar *path,
+ gchar *new_text,
+ GitgRepositoryDialog *dialog)
{
if (!*new_text)
{
diff --git a/gitg/gitg-runner.c b/gitg/gitg-runner.c
index ec4da5f..ec4244e 100644
--- a/gitg/gitg-runner.c
+++ b/gitg/gitg-runner.c
@@ -79,21 +79,21 @@ typedef struct
GCancellable *cancellable;
} AsyncData;
-AsyncData *
-async_data_new(GitgRunner *runner, GCancellable *cancellable)
+static AsyncData *
+async_data_new (GitgRunner *runner, GCancellable *cancellable)
{
- AsyncData *data = g_slice_new(AsyncData);
+ AsyncData *data = g_slice_new (AsyncData);
data->runner = runner;
- data->cancellable = g_object_ref(cancellable);
+ data->cancellable = g_object_ref (cancellable);
return data;
}
-void
-async_data_free(AsyncData *data)
+static void
+async_data_free (AsyncData *data)
{
- g_object_unref(data->cancellable);
- g_slice_free(AsyncData, data);
+ g_object_unref (data->cancellable);
+ g_slice_free (AsyncData, data);
}
GQuark
@@ -530,8 +530,12 @@ write_input_ready(GOutputStream *stream, GAsyncResult *result, AsyncData *data)
}
}
-gboolean
-gitg_runner_run_streams(GitgRunner *runner, GInputStream *input_stream, GOutputStream *output_stream, gchar const *input, GError **error)
+static gboolean
+gitg_runner_run_streams (GitgRunner *runner,
+ GInputStream *input_stream,
+ GOutputStream *output_stream,
+ gchar const *input,
+ GError **error)
{
gitg_runner_cancel(runner);
@@ -625,9 +629,11 @@ gitg_runner_run(GitgRunner *runner, gchar const **argv, GError **error)
}
gboolean
-gitg_runner_run_stream(GitgRunner *runner, GInputStream *stream, GError **error)
+gitg_runner_run_stream (GitgRunner *runner,
+ GInputStream *stream,
+ GError **error)
{
- return gitg_runner_run_streams(runner, stream, NULL, NULL, error);
+ return gitg_runner_run_streams (runner, stream, NULL, NULL, error);
}
guint
diff --git a/gitg/gitg-window.c b/gitg/gitg-window.c
index fb0d6dd..ac3c0b0 100644
--- a/gitg/gitg-window.c
+++ b/gitg/gitg-window.c
@@ -106,6 +106,35 @@ static gboolean on_tree_view_button_release(GtkTreeView *treeview, GdkEventButto
static void gitg_window_buildable_iface_init(GtkBuildableIface *iface);
+void on_subject_activate (GtkAction *action, GitgWindow *window);
+void on_author_activate (GtkAction *action, GitgWindow *window);
+void on_date_activate (GtkAction *action, GitgWindow *window);
+void on_hash_activate (GtkAction *action, GitgWindow *window);
+void on_file_quit (GtkAction *action, GitgWindow *window);
+void on_file_open (GtkAction *action, GitgWindow *window);
+void on_edit_cut (GtkAction *action, GitgWindow *window);
+void on_edit_copy (GtkAction *action, GitgWindow *window);
+void on_edit_paste (GtkAction *action, GitgWindow *window);
+void on_view_refresh (GtkAction *action, GitgWindow *window);
+void on_recent_open (GtkRecentChooser *chooser, GitgWindow *window);
+void on_window_set_focus (GitgWindow *window, GtkWidget *widget);
+void on_help_about (GtkAction *action, GitgWindow *window);
+void on_edit_preferences (GtkAction *action, GitgWindow *window);
+void on_repository_properties (GtkAction *action, GitgWindow *window);
+
+gboolean on_tree_view_rv_button_press_event (GtkWidget *widget,
+ GdkEventButton *event,
+ GitgWindow *window);
+
+void on_checkout_branch_action_activate (GtkAction *action, GitgWindow *window);
+void on_remove_branch_action_activate (GtkAction *action, GitgWindow *window);
+void on_rename_branch_action_activate (GtkAction *action, GitgWindow *window);
+void on_rebase_branch_action_activate (GtkAction *action, GitgWindow *window);
+void on_merge_branch_action_activate (GtkAction *action, GitgWindow *window);
+void on_revision_format_patch_activate (GtkAction *action, GitgWindow *window);
+void on_revision_tag_activate (GtkAction *action, GitgWindow *window);
+void on_revision_squash_activate (GtkAction *action, GitgWindow *window);
+
G_DEFINE_TYPE_EXTENDED(GitgWindow, gitg_window, GTK_TYPE_WINDOW, 0,
G_IMPLEMENT_INTERFACE(GTK_TYPE_BUILDABLE, gitg_window_buildable_iface_init));
@@ -197,7 +226,7 @@ on_search_icon_release(GtkEntry *entry, GtkEntryIconPosition icon_pos, int butto
gtk_menu_popup(GTK_MENU(window->priv->search_popup), NULL, NULL, NULL, NULL, button, gtk_get_current_event_time());
}
-void
+static void
search_column_activate(GtkAction *action, gint column, GtkTreeView *tree_view)
{
if (!gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)))
@@ -398,7 +427,6 @@ on_branches_combo_changed (GtkComboBox *combo, GitgWindow *window)
if (gtk_combo_box_get_active(combo) < 2)
return;
- gchar *name;
GtkTreeIter iter;
gchar **selection;
@@ -790,7 +818,7 @@ gitg_window_destroy(GtkObject *object)
}
static gboolean
-gitg_window_window_state_event(GtkWidget *widget, GdkEventWindowState *event)
+gitg_window_window_state_event (GtkWidget *widget, GdkEventWindowState *event)
{
GitgWindow *window = GITG_WINDOW(widget);
@@ -805,6 +833,9 @@ gitg_window_window_state_event(GtkWidget *widget, GdkEventWindowState *event)
gtk_statusbar_set_has_resize_grip (window->priv->statusbar, show);
}
+ GitgSettings *settings = gitg_settings_get_default ();
+ gitg_settings_set_window_state (settings, event->new_window_state);
+
return FALSE;
}
@@ -973,21 +1004,22 @@ create_repository(GitgWindow *window, gchar const *path, gboolean usewd)
}
static int
-sort_by_ref_type(GitgRef *a, GitgRef *b)
+sort_by_ref_type (GitgRef *a, GitgRef *b)
{
- if (gitg_ref_get_ref_type(a) == gitg_ref_get_ref_type(b))
+ if (gitg_ref_get_ref_type (a) == gitg_ref_get_ref_type (b))
{
- if (g_ascii_strcasecmp(gitg_ref_get_shortname(a), "master") == 0)
+ if (g_ascii_strcasecmp (gitg_ref_get_shortname (a), "master") == 0)
{
return -1;
}
- else if (g_ascii_strcasecmp(gitg_ref_get_shortname(b), "master") == 0)
+ else if (g_ascii_strcasecmp (gitg_ref_get_shortname (b), "master") == 0)
{
return 1;
}
else
{
- return g_ascii_strcasecmp(gitg_ref_get_shortname(a), gitg_ref_get_shortname(b));
+ return g_ascii_strcasecmp (gitg_ref_get_shortname (a),
+ gitg_ref_get_shortname (b));
}
}
else
@@ -1140,8 +1172,8 @@ fill_branches_combo(GitgWindow *window)
}
if (!active_from_selection &&
- (current_selection && equal_selection (selection, current_selection)) ||
- (!current_selection && gitg_ref_equal (ref, working_ref)))
+ ((current_selection && equal_selection (selection, current_selection)) ||
+ (!current_selection && gitg_ref_equal (ref, working_ref))))
{
GtkTreePath *path = gtk_tree_model_get_path (GTK_TREE_MODEL (store),
&iter);
@@ -1153,13 +1185,13 @@ fill_branches_combo(GitgWindow *window)
}
/* Separator */
- gtk_tree_store_append(store, &iter, NULL);
- gtk_tree_store_set(store,
- &iter,
- COLUMN_BRANCHES_NAME, NULL,
- COLUMN_BRANCHES_REF, NULL,
- COLUMN_BRANCHES_SELECTION, NULL,
- -1);
+ gtk_tree_store_append (store, &iter, NULL);
+ gtk_tree_store_set (store,
+ &iter,
+ COLUMN_BRANCHES_NAME, NULL,
+ COLUMN_BRANCHES_REF, NULL,
+ COLUMN_BRANCHES_SELECTION, NULL,
+ -1);
gchar const *selection[] = {
"--branches",
@@ -1259,23 +1291,27 @@ update_window_title (GitgWindow *window)
}
static void
-on_repository_load(GitgRepository *repository, GitgWindow *window)
+on_repository_load (GitgRepository *repository, GitgWindow *window)
{
- GdkCursor *cursor = gdk_cursor_new(GDK_WATCH);
- gdk_window_set_cursor(GTK_WIDGET(window->priv->tree_view)->window, cursor);
- gdk_cursor_unref(cursor);
+ GdkCursor *cursor = gdk_cursor_new (GDK_WATCH);
+ gdk_window_set_cursor (GTK_WIDGET (window->priv->tree_view)->window, cursor);
+ gdk_cursor_unref (cursor);
- gtk_statusbar_push(window->priv->statusbar, 0, _("Begin loading repository"));
+ gtk_statusbar_push (window->priv->statusbar, 0, _("Begin loading repository"));
- g_timer_reset(window->priv->load_timer);
- g_timer_start(window->priv->load_timer);
+ g_timer_reset (window->priv->load_timer);
+ g_timer_start (window->priv->load_timer);
- g_signal_handlers_block_by_func(window->priv->combo_branches, on_branches_combo_changed, window);
+ g_signal_handlers_block_by_func (window->priv->combo_branches,
+ on_branches_combo_changed,
+ window);
- clear_branches_combo(window);
- fill_branches_combo(window);
+ clear_branches_combo (window);
+ fill_branches_combo (window);
- g_signal_handlers_unblock_by_func(window->priv->combo_branches, on_branches_combo_changed, window);
+ g_signal_handlers_unblock_by_func (window->priv->combo_branches,
+ on_branches_combo_changed,
+ window);
update_window_title (window);
}
@@ -1311,10 +1347,15 @@ load_repository(GitgWindow *window, gchar const *path, gint argc, gchar const **
{
gtk_tree_view_set_model(window->priv->tree_view, NULL);
- g_signal_handlers_disconnect_by_func(window->priv->repository, G_CALLBACK(on_repository_load), window);
- g_signal_handlers_disconnect_by_func(window->priv->repository, G_CALLBACK(on_repository_loaded), window);
+ g_signal_handlers_disconnect_by_func (window->priv->repository,
+ G_CALLBACK (on_repository_load),
+ window);
- g_object_unref(window->priv->repository);
+ g_signal_handlers_disconnect_by_func (window->priv->repository,
+ G_CALLBACK (on_repository_loaded),
+ window);
+
+ g_object_unref (window->priv->repository);
window->priv->repository = NULL;
gitg_repository_dialog_close ();
@@ -1414,17 +1455,20 @@ gitg_window_get_repository(GitgWindow *window)
}
void
-on_file_quit(GtkAction *action, GitgWindow *window)
+on_file_quit( GtkAction *action, GitgWindow *window)
{
gtk_main_quit();
}
static void
-on_open_dialog_response(GtkFileChooser *dialog, gint response, GitgWindow *window)
+on_open_dialog_response (GtkFileChooser *dialog,
+ gint response,
+ GitgWindow *window)
{
if (response != GTK_RESPONSE_ACCEPT)
{
- gtk_widget_destroy(GTK_WIDGET(dialog));
+ gtk_widget_destroy (GTK_WIDGET(dialog));
+
return;
}
@@ -1441,7 +1485,7 @@ on_open_dialog_response(GtkFileChooser *dialog, gint response, GitgWindow *windo
}
void
-on_file_open(GtkAction *action, GitgWindow *window)
+on_file_open (GtkAction *action, GitgWindow *window)
{
if (window->priv->open_dialog)
{
@@ -1449,14 +1493,14 @@ on_file_open(GtkAction *action, GitgWindow *window)
return;
}
- window->priv->open_dialog = gtk_file_chooser_dialog_new(_("Open git repository"),
- GTK_WINDOW(window),
- GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN,
- GTK_RESPONSE_ACCEPT,
- NULL);
+ window->priv->open_dialog = gtk_file_chooser_dialog_new (_("Open git repository"),
+ GTK_WINDOW (window),
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN,
+ GTK_RESPONSE_ACCEPT,
+ NULL);
gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(window->priv->open_dialog), TRUE);
g_object_add_weak_pointer(G_OBJECT(window->priv->open_dialog), (gpointer *)&(window->priv->open_dialog));
@@ -1466,15 +1510,15 @@ on_file_open(GtkAction *action, GitgWindow *window)
}
void
-on_edit_copy(GtkAction *action, GitgWindow *window)
+on_edit_copy (GtkAction *action, GitgWindow *window)
{
- GtkWidget *focus = gtk_window_get_focus(GTK_WINDOW(window));
+ GtkWidget *focus = gtk_window_get_focus (GTK_WINDOW(window));
- g_signal_emit_by_name(focus, "copy-clipboard", 0);
+ g_signal_emit_by_name (focus, "copy-clipboard", 0);
}
void
-on_edit_cut(GtkAction *action, GitgWindow *window)
+on_edit_cut (GtkAction *action, GitgWindow *window)
{
GtkWidget *focus = gtk_window_get_focus(GTK_WINDOW(window));
@@ -1482,7 +1526,7 @@ on_edit_cut(GtkAction *action, GitgWindow *window)
}
void
-on_edit_paste(GtkAction *action, GitgWindow *window)
+on_edit_paste (GtkAction *action, GitgWindow *window)
{
GtkWidget *focus = gtk_window_get_focus(GTK_WINDOW(window));
@@ -1499,7 +1543,7 @@ on_view_refresh(GtkAction *action, GitgWindow *window)
}
void
-on_window_set_focus(GitgWindow *window, GtkWidget *widget)
+on_window_set_focus (GitgWindow *window, GtkWidget *widget)
{
if (widget == NULL)
return;
@@ -1550,7 +1594,7 @@ url_activate_hook(GtkAboutDialog *dialog, gchar const *link, gpointer data)
}
static void
-email_activate_hook(GtkAboutDialog *dialog, gchar const *link, gpointer data)
+email_activate_hook (GtkAboutDialog *dialog, gchar const *link, gpointer data)
{
gchar *uri;
gchar *escaped;
@@ -1586,33 +1630,34 @@ on_help_about(GtkAction *action, GitgWindow *window)
"Foundation, Inc., 59 Temple Place, Suite 330,\n"
"Boston, MA 02111-1307, USA.");
-#if GTK_CHECK_VERSION (2, 14, 0)
- gtk_about_dialog_set_url_hook(url_activate_hook, NULL, NULL);
- gtk_about_dialog_set_email_hook(email_activate_hook, NULL, NULL);
-#endif
- gchar *path = gitg_dirs_get_data_filename("icons", "gitg.svg", NULL);
- GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(path, NULL);
- g_free(path);
+ gtk_about_dialog_set_url_hook (url_activate_hook, NULL, NULL);
+ gtk_about_dialog_set_email_hook (email_activate_hook, NULL, NULL);
+
+ gchar *path = gitg_dirs_get_data_filename ("icons", "gitg.svg", NULL);
+ GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (path, NULL);
+ g_free (path);
if (!pixbuf)
{
- path = gitg_dirs_get_data_filename("icons", "gitg128x128.png", NULL);
- pixbuf = gdk_pixbuf_new_from_file(path, NULL);
- g_free(path);
+ path = gitg_dirs_get_data_filename ("icons", "gitg128x128.png", NULL);
+ pixbuf = gdk_pixbuf_new_from_file (path, NULL);
+ g_free (path);
}
- gtk_show_about_dialog(GTK_WINDOW(window),
- "authors", authors,
- "copyright", copyright,
- "comments", _(comments),
- "version", VERSION,
- "website", "http://trac.novowork.com/gitg",
- "logo", pixbuf,
- "license", _(license),
- NULL);
+ gtk_show_about_dialog (GTK_WINDOW(window),
+ "authors", authors,
+ "copyright", copyright,
+ "comments", _(comments),
+ "version", VERSION,
+ "website", "http://trac.novowork.com/gitg",
+ "logo", pixbuf,
+ "license", _(license),
+ NULL);
if (pixbuf)
- g_object_unref(pixbuf);
+ {
+ g_object_unref (pixbuf);
+ }
}
static gboolean
@@ -1710,13 +1755,13 @@ on_tree_view_button_release(GtkTreeView *treeview, GdkEventButton *event, GitgWi
}
void
-on_edit_preferences(GtkAction *action, GitgWindow *window)
+on_edit_preferences (GtkAction *action, GitgWindow *window)
{
- gitg_preferences_dialog_present(GTK_WINDOW(window));
+ gitg_preferences_dialog_present (GTK_WINDOW(window));
}
void
-on_repository_properties(GtkAction *action, GitgWindow *window)
+on_repository_properties (GtkAction *action, GitgWindow *window)
{
gitg_repository_dialog_present (window);
}
@@ -1772,7 +1817,6 @@ get_tracked_ref (GitgWindow *window, GitgRef *branch, gchar **retremote, gchar *
GitgConfig *config = gitg_config_new (window->priv->repository);
gchar *merge;
gchar *var;
- gchar *ret;
var = g_strconcat ("branch.", gitg_ref_get_shortname (branch), ".remote", NULL);
*retremote = gitg_config_get_value (config, var);
@@ -2344,9 +2388,11 @@ popup_revision (GitgWindow *window, GdkEventButton *event)
if (rows)
{
- GtkAction *tag = gtk_ui_manager_get_action (window->priv->menus_ui_manager, "/ui/revision_popup/TagAction");
- GtkAction *squash = gtk_ui_manager_get_action (window->priv->menus_ui_manager, "/ui/revision_popup/SquashAction");
- GtkAction *cherry_pick = gtk_ui_manager_get_action (window->priv->menus_ui_manager, "/ui/revision_popup/CherryPick");
+ GtkAction *tag = gtk_ui_manager_get_action (window->priv->menus_ui_manager,
+ "/ui/revision_popup/TagAction");
+
+ GtkAction *squash = gtk_ui_manager_get_action (window->priv->menus_ui_manager,
+ "/ui/revision_popup/SquashAction");
if (!rows->next)
{
@@ -2527,7 +2573,7 @@ on_tag_dialog_response (GtkWidget *dialog, gint response, TagInfo *info)
if (destroy)
{
- g_slice_free (TagInfo, info);
+ free_tag_info (info);
gtk_widget_destroy (dialog);
}
}
@@ -2577,7 +2623,7 @@ on_revision_format_patch_activate (GtkAction *action, GitgWindow *window)
selection = gtk_tree_view_get_selection (window->priv->tree_view);
GList *rows = gtk_tree_selection_get_selected_rows (selection, &model);
- GtkWidget *dialog;
+ GtkWidget *dialog = NULL;
if (!rows->next)
{
@@ -2674,6 +2720,7 @@ on_revision_tag_activate (GtkAction *action, GitgWindow *window)
gtk_tree_model_get (model, &iter, 0, &rev, -1);
TagInfo *info = g_slice_new (TagInfo);
+
info->revision = gitg_revision_ref (rev);
info->window = window;
info->builder = builder;
diff --git a/gitg/gitg.c b/gitg/gitg.c
index 690decb..7060603 100644
--- a/gitg/gitg.c
+++ b/gitg/gitg.c
@@ -55,56 +55,56 @@ static GOptionEntry entries[] =
{ NULL }
};
-void
-parse_options(int *argc, char ***argv)
+static void
+parse_options (int *argc, char ***argv)
{
GError *error = NULL;
GOptionContext *context;
- context = g_option_context_new(_("- git repository viewer"));
+ context = g_option_context_new (_("- git repository viewer"));
// Ignore unknown options so we can pass them to git
- g_option_context_set_ignore_unknown_options(context, TRUE);
- g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE);
- g_option_context_add_group(context, gtk_get_option_group (TRUE));
+ g_option_context_set_ignore_unknown_options (context, TRUE);
+ g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+ g_option_context_add_group (context, gtk_get_option_group (TRUE));
- if (!g_option_context_parse(context, argc, argv, &error))
+ if (!g_option_context_parse (context, argc, argv, &error))
{
- g_print("option parsing failed: %s\n", error->message);
- g_error_free(error);
- exit(1);
+ g_print ("option parsing failed: %s\n", error->message);
+ g_error_free (error);
+ exit (1);
}
g_option_context_free(context);
}
static gboolean
-on_window_delete_event(GtkWidget *widget, gpointer userdata)
+on_window_delete_event (GtkWidget *widget, gpointer userdata)
{
- gtk_main_quit();
+ gtk_main_quit ();
return FALSE;
}
static GitgWindow *
-build_ui()
+build_ui ()
{
- GtkBuilder *builder = gitg_utils_new_builder("gitg-window.ui");
+ GtkBuilder *builder = gitg_utils_new_builder ("gitg-window.ui");
- GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder, "window"));
- gtk_widget_show_all(window);
+ GtkWidget *window = GTK_WIDGET (gtk_builder_get_object(builder, "window"));
+ gtk_widget_show_all (window);
- g_signal_connect_after(window, "destroy", G_CALLBACK(on_window_delete_event), NULL);
- g_object_unref(builder);
+ g_signal_connect_after (window, "destroy", G_CALLBACK (on_window_delete_event), NULL);
+ g_object_unref (builder);
- return GITG_WINDOW(window);
+ return GITG_WINDOW (window);
}
static void
-set_language_search_path()
+set_language_search_path ()
{
- GtkSourceLanguageManager *manager = gtk_source_language_manager_get_default();
- gchar const * const *orig = gtk_source_language_manager_get_search_path(manager);
- gchar const **dirs = g_new0(gchar const *, g_strv_length((gchar **)orig) + 2);
+ GtkSourceLanguageManager *manager = gtk_source_language_manager_get_default ();
+ gchar const * const *orig = gtk_source_language_manager_get_search_path (manager);
+ gchar const **dirs = g_new0 (gchar const *, g_strv_length ((gchar **)orig) + 2);
guint i = 0;
while (orig[i])
@@ -113,26 +113,26 @@ set_language_search_path()
++i;
}
- gchar *path = gitg_dirs_get_data_filename("language-specs", NULL);
+ gchar *path = gitg_dirs_get_data_filename ("language-specs", NULL);
dirs[0] = path;
- gtk_source_language_manager_set_search_path(manager, (gchar **)dirs);
- g_free(path);
+ gtk_source_language_manager_set_search_path (manager, (gchar **)dirs);
+ g_free (path);
- g_free(dirs);
+ g_free (dirs);
}
static void
-set_style_scheme_search_path()
+set_style_scheme_search_path ()
{
- GtkSourceStyleSchemeManager *manager = gtk_source_style_scheme_manager_get_default();
+ GtkSourceStyleSchemeManager *manager = gtk_source_style_scheme_manager_get_default ();
- gchar *path = gitg_dirs_get_data_filename("styles", NULL);
- gtk_source_style_scheme_manager_prepend_search_path(manager, path);
- g_free(path);
+ gchar *path = gitg_dirs_get_data_filename ("styles", NULL);
+ gtk_source_style_scheme_manager_prepend_search_path (manager, path);
+ g_free (path);
}
static void
-set_icons()
+set_icons ()
{
static gchar const *icon_infos[] = {
"gitg16x16.png",
@@ -150,18 +150,20 @@ set_icons()
for (i = 0; icon_infos[i]; ++i)
{
- gchar *filename = gitg_dirs_get_data_filename("icons", icon_infos[i], NULL);
- GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
- g_free(filename);
+ gchar *filename = gitg_dirs_get_data_filename ("icons", icon_infos[i], NULL);
+ GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
+ g_free (filename);
if (pixbuf)
- icons = g_list_prepend(icons, pixbuf);
+ {
+ icons = g_list_prepend (icons, pixbuf);
+ }
}
- gtk_window_set_default_icon_list(icons);
+ gtk_window_set_default_icon_list (icons);
- g_list_foreach(icons, (GFunc)g_object_unref, NULL);
- g_list_free(icons);
+ g_list_foreach (icons, (GFunc)g_object_unref, NULL);
+ g_list_free (icons);
}
int
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]