Skip to content

Use GtkApplication#169

Open
andy128k wants to merge 2 commits intomvo5:masterfrom
andy128k:gtk-application
Open

Use GtkApplication#169
andy128k wants to merge 2 commits intomvo5:masterfrom
andy128k:gtk-application

Conversation

@andy128k
Copy link
Contributor

No description provided.

Copy link
Owner

@mvo5 mvo5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This looks very nice, a few quick comments inline, I thnk the -o is the only critical one though.

RGUserDialog userDialog;
userDialog.showErrors();
exit(1);
GtkApplication *app = gtk_application_new(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AIUI with this we can remove the if (!gtk_init_check(&argc, &argv)) (from a few lines above) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I just wanted to have as less intrusive change as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually removing it.

gtk/gsynaptic.cc Outdated
{ "filter-file", 'f', G_OPTION_FLAG_NONE, G_OPTION_ARG_FILENAME, NULL, N_("Give an alternative filter file"), N_("<filter-file>") },
{ "title", 't', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, NULL, N_("Give an alternative main window title (e.g. hostname with `uname -n`)"), N_("title") },
{ "initial-filter", 'i', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, NULL, N_("Start with the initial filter with given name"), N_("<filter-name>") },
{ "option", 'o', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, NULL, N_("Set an arbitrary configuration option, eg -o dir::cache=/tmp"), N_("<option>") },
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need a G_OPTION_ARG_STRING_ARRAY or something here, I'm pretty sure the old code allowed -o foo=bar -o baz=quax etc and here I think we only support a single flag anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

if (pipe (sigterm_unix_signal_pipe_fds) != 0) {
g_warning ("Could not setup pipe, errno=%d", errno);
return 1;
exit(1);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels slightly not-nice (to exit here hard instead of returning), but I guess its the only way(?) if applicationActivate is void :( oh well :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about removing this code and just rely on Gtk?


RPackageLister *packageLister = new RPackageLister();
RGMainWindow *mainWindow = new RGMainWindow(packageLister, "main");
RGMainWindow *mainWindow = new RGMainWindow(GTK_APPLICATION(app), packageLister, "main");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pre-existing so feel free to ignore but I wonder if construcuting the packageLister and mainWindow should happen after the trick around putting an existing synaptic into the foreground (feel free to ignore)

gtk/gsynaptic.cc Outdated

if (g_variant_dict_lookup(options, "repositories", "b", &flag))
_config->Set("Volatile::startInRepositories", flag ? "true" : "false");
if (g_variant_dict_lookup(options, "filter-file", "s", &arg))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to free arg here (and in the other places), no? AIUI we could use &s here to get the raw pointer which we then don't need to free (and _config->Set() clones it into a string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

gtk/gsynaptic.cc Outdated
g_signal_connect(app, "activate",
G_CALLBACK(applicationActivate), nullptr);

return g_application_run(G_APPLICATION(app), argc, argv);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(super nitpick) technically we should g_object_unref(app); after it was run, so something like:

  int status = g_application_run(G_APPLICATION(app), argc, argv);
  g_object_unref(app);
  return status;

but I guess it does not really matter much as we are exiting anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants