Ejemplo n.º 1
0
static void
activate (GtkApplication *app)
{
	GList *list;
	GSList* actions;
	gboolean hidden = FALSE;

	list = gtk_application_get_windows (app);

	AppShellData* app_data = appshelldata_new("matecc.menu", GTK_ICON_SIZE_DND, FALSE, TRUE, 0);

	generate_categories(app_data);

	actions = get_actions_list();
	layout_shell(app_data, _("Filter"), _("Groups"), _("Common Tasks"), actions, handle_static_action_clicked);

	if (list)
	{
		gtk_window_present (GTK_WINDOW (list->data));
	}
	else
	{
		create_main_window(app_data, "MyControlCenter", _("Control Center"), "preferences-desktop", 975, 600, hidden);
		gtk_application_add_window (app, GTK_WINDOW(app_data->main_app));
	}
}
Ejemplo n.º 2
0
static void
switch_to_item (BjbMainView *view, BijiItem *to_open)
{
  if (BIJI_IS_NOTE_OBJ (to_open))
  {
    /* If the note is already opened in another window, just show it. */
    if (biji_note_obj_is_opened (BIJI_NOTE_OBJ (to_open)))
    {
      GList *notes ;

      notes = gtk_application_get_windows(GTK_APPLICATION(g_application_get_default()));
      g_list_foreach (notes, show_window_if_note, to_open);
      return ;
    }

    /* Otherwise, leave main view */
    switch_to_note_view (view, BIJI_NOTE_OBJ (to_open));
  }

  /* Notebook
   * TODO : check if already opened (same as above) */
  else if (BIJI_IS_NOTEBOOK (to_open))
  {
    bjb_controller_set_notebook (view->priv->controller,
                                   BIJI_NOTEBOOK (to_open));
  }
}
Ejemplo n.º 3
0
static void
shell_action_new_window_cb (GSimpleAction *action,
                            GVariant *parameter,
                            EShell *shell)
{
	GtkApplication *application;
	GList *list;
	const gchar *view_name;

	application = GTK_APPLICATION (shell);
	list = gtk_application_get_windows (application);

	view_name = g_variant_get_string (parameter, NULL);

	/* Present the first EShellWindow showing 'view_name'. */
	while (list != NULL) {
		GtkWindow *window = GTK_WINDOW (list->data);

		if (E_IS_SHELL_WINDOW (window)) {
			const gchar *active_view;

			active_view = e_shell_window_get_active_view (
				E_SHELL_WINDOW (window));
			if (g_strcmp0 (active_view, view_name) == 0) {
				gtk_window_present (window);
				return;
			}
		}

		list = g_list_next (list);
	}

	/* No suitable EShellWindow found, so create one. */
	e_shell_create_shell_window (shell, view_name);
}
static gboolean
launch_search_cb (GcalShellSearchProvider  *search_provider,
                  GDBusMethodInvocation    *invocation,
                  gchar                   **terms,
                  guint32                   timestamp,
                  GcalShellSearchProvider2 *skel)
{
  GApplication *application;
  gchar *terms_joined;
  GList *windows;

  application = g_application_get_default ();
  g_application_activate (application);

  terms_joined = g_strjoinv (" ", terms);
  windows = g_list_reverse (gtk_application_get_windows (GTK_APPLICATION (application)));
  if (windows != NULL)
    {
      gcal_window_set_search_mode (GCAL_WINDOW (windows->data), TRUE);
      gcal_window_set_search_query (GCAL_WINDOW (windows->data), terms_joined);

      g_list_free (windows);
    }

  g_free (terms_joined);
  return TRUE;
}
Ejemplo n.º 5
0
void 
gw_application_open_settingswindow_cb (GSimpleAction *action,
                                       GVariant      *parameter,
                                       gpointer       data)
{
    //Declarations
    GwApplication *application;
    GwSearchWindow *searchwindow;
    GtkWindow *settingswindow;
    GList *link;

    //Initializations
    searchwindow = GW_SEARCHWINDOW (gw_application_get_last_focused_searchwindow (GW_APPLICATION (data)));
    application = gw_window_get_application (GW_WINDOW (searchwindow));
    link = gtk_application_get_windows (GTK_APPLICATION (application));

    while (link != NULL && !GW_IS_SETTINGSWINDOW (link->data)) link = link->next;

    if (link != NULL)
    {
      settingswindow = GTK_WINDOW (link->data);
      gtk_window_set_transient_for (GTK_WINDOW (settingswindow), GTK_WINDOW (searchwindow));
      gtk_window_present (GTK_WINDOW (settingswindow));
    }
    else
    {
      settingswindow = gw_settingswindow_new (GTK_APPLICATION (application));
      gtk_window_set_transient_for (GTK_WINDOW (settingswindow), GTK_WINDOW (searchwindow));
      gtk_widget_show (GTK_WIDGET (settingswindow));
    }
}
Ejemplo n.º 6
0
static gboolean
maybe_open_with_existing_workspace (IdeApplication *self,
                                    GFile          *file,
                                    const gchar    *hint,
                                    GCancellable   *cancellable)
{
  GList *windows;
  GList *iter;

  g_assert (IDE_IS_APPLICATION (self));
  g_assert (G_IS_FILE (file));

  windows = gtk_application_get_windows (GTK_APPLICATION (self));

  for (iter = windows; iter != NULL; iter = iter->next)
    {
      GtkWindow *window = iter->data;

      if (IDE_IS_WORKBENCH (window) &&
          workbench_manages_file (IDE_WORKBENCH (window), file))
        {
          ide_workbench_open_files_async (IDE_WORKBENCH (window),
                                          &file,
                                          1,
                                          hint,
                                          0,
                                          cancellable,
                                          NULL,
                                          NULL);
          return TRUE;
        }
    }

  return FALSE;
}
Ejemplo n.º 7
0
static GtkWidget *
ag_app_get_usable_window(AgApp *app)
{
    GtkWidget *window;
    GList     *l;

    // Favour current window
    window = GTK_WIDGET(gtk_application_get_active_window(GTK_APPLICATION(app)));

    if (AG_IS_WINDOW(window) && ag_window_is_usable(AG_WINDOW(window))) {
        return window;
    }

    // Otherwise, let’s use the first existing, usable window
    for (
                l = gtk_application_get_windows(GTK_APPLICATION(app));
                l;
                l = g_list_next(l)
            ) {
        if (AG_IS_WINDOW(l->data) && ag_window_is_usable(AG_WINDOW(l->data))) {
            return l->data;
        }
    }

    // If we are still here, no usable windows were found. Let’s create one
    window = ag_app_create_window(app);

    return window;
}
Ejemplo n.º 8
0
static void
get_network_available (GNetworkMonitor *monitor,
		       gboolean         available,
		       GeditApp        *app)
{
	gboolean enable;
	GList *windows, *w;

	enable = g_network_monitor_get_network_available (monitor);

	windows = gtk_application_get_windows (GTK_APPLICATION (app));

	for (w = windows; w != NULL; w = w->next)
	{
		GeditWindow *window = GEDIT_WINDOW (w->data);

		if (GEDIT_IS_WINDOW (window))
		{
			GList *tabs, *t;

			tabs = _gedit_window_get_all_tabs (window);

			for (t = tabs; t != NULL; t = t->next)
			{
				_gedit_tab_set_network_available (GEDIT_TAB (t->data),
					                          enable);
			}

			g_list_free (tabs);
		}
	}
}
Ejemplo n.º 9
0
static GeditWindow *
get_active_window (GtkApplication *app)
{
	GdkScreen *screen;
	guint workspace;
	gint viewport_x, viewport_y;
	GList *windows, *l;

	screen = gdk_screen_get_default ();

	workspace = gedit_utils_get_current_workspace (screen);
	gedit_utils_get_current_viewport (screen, &viewport_x, &viewport_y);

	/* Gtk documentation says the window list is always in MRU order */
	windows = gtk_application_get_windows (app);
	for (l = windows; l != NULL; l = l->next)
	{
		GtkWindow *window = l->data;

		if (GEDIT_IS_WINDOW (window) && is_in_viewport (window, screen, workspace, viewport_x, viewport_y))
		{
			return GEDIT_WINDOW (window);
		}
	}

	return NULL;
}
Ejemplo n.º 10
0
static void
gucharmap_activate (GApplication *application,
                    gpointer      unused)
{
  GList *windows = gtk_application_get_windows (GTK_APPLICATION (application));
  gtk_window_present (GTK_WINDOW (windows->data));
}
static int
trg_gtk_app_command_line(GApplication * application,
                         GApplicationCommandLine * cmdline)
{
    GList *windows =
        gtk_application_get_windows(GTK_APPLICATION(application));
    TrgMainWindow *window;
    gchar **argv;

    if (!windows || !windows->data)
        return 1;

    window = TRG_MAIN_WINDOW(windows->data);
    argv = g_application_command_line_get_arguments(cmdline, NULL);

    if (g_application_command_line_get_is_remote(cmdline)) {
        if (!argv[0]) {
            gtk_window_present(GTK_WINDOW(window));
            g_strfreev(argv);
        } else {
            return trg_add_from_filename(window, argv);
        }
    } else {
        trg_main_window_set_start_args(window, argv);
        auto_connect_if_required(TRG_MAIN_WINDOW(windows->data));
    }

    return 0;
}
Ejemplo n.º 12
0
void
ide_application_actions_update (IdeApplication *self)
{
  GList *windows;
  GAction *action;
  gboolean enabled;

  g_assert (IDE_IS_APPLICATION (self));

  /*
   * We only enable the preferences action if we have a workbench open
   * that is past the greeter.
   */
  action = g_action_map_lookup_action (G_ACTION_MAP (self), "preferences");
  enabled = FALSE;
  for (windows = gtk_application_get_windows (GTK_APPLICATION (self));
       windows != NULL;
       windows = windows->next)
    {
      GtkWindow *window = windows->data;

      if (IDE_IS_WORKBENCH (window) &&
          !ide_str_equal0 ("greeter",
                           ide_workbench_get_visible_perspective_name (IDE_WORKBENCH (window))))
        {
          enabled = TRUE;
          break;
        }
    }
  g_simple_action_set_enabled (G_SIMPLE_ACTION (action), enabled);
}
Ejemplo n.º 13
0
static void preferences_app_activated (GtkApplication* app) {
	GtkApplication* _tmp0_;
	GList* _tmp1_ = NULL;
	GList* list;
	GList* _tmp2_;
	g_return_if_fail (app != NULL);
	_tmp0_ = app;
	_tmp1_ = gtk_application_get_windows (_tmp0_);
	list = _tmp1_;
	_tmp2_ = list;
	if (_tmp2_ != NULL) {
		GList* _tmp3_;
		gconstpointer _tmp4_;
		guint32 _tmp5_ = 0U;
		_tmp3_ = list;
		_tmp4_ = _tmp3_->data;
		_tmp5_ = gtk_get_current_event_time ();
		gtk_window_present_with_time ((GtkWindow*) _tmp4_, _tmp5_);
	} else {
		GtkWindow* _tmp6_;
		GtkWindow* _tmp7_;
		GtkWindow* dlg;
		GtkWindow* _tmp8_;
		const gchar* _tmp9_ = NULL;
		GtkWindow* _tmp10_;
		DejaDupPreferences* _tmp11_;
		DejaDupPreferences* _tmp12_;
		DejaDupPreferences* prefs;
		DejaDupPreferences* _tmp13_;
		GtkWindow* _tmp14_;
		DejaDupPreferences* _tmp15_;
		GtkWindow* _tmp16_;
		GtkApplication* _tmp17_;
		GtkWindow* _tmp18_;
		_tmp6_ = (GtkWindow*) gtk_window_new (GTK_WINDOW_TOPLEVEL);
		_tmp7_ = g_object_ref_sink (_tmp6_);
		dlg = _tmp7_;
		_tmp8_ = dlg;
		_tmp9_ = _ ("Backup");
		gtk_window_set_title (_tmp8_, _tmp9_);
		_tmp10_ = dlg;
		gtk_window_set_resizable (_tmp10_, FALSE);
		_tmp11_ = deja_dup_preferences_new ();
		_tmp12_ = g_object_ref_sink (_tmp11_);
		prefs = _tmp12_;
		_tmp13_ = prefs;
		gtk_container_set_border_width ((GtkContainer*) _tmp13_, (guint) 12);
		_tmp14_ = dlg;
		_tmp15_ = prefs;
		gtk_container_add ((GtkContainer*) _tmp14_, (GtkWidget*) _tmp15_);
		_tmp16_ = dlg;
		_tmp17_ = app;
		gtk_window_set_application (_tmp16_, _tmp17_);
		_tmp18_ = dlg;
		gtk_widget_show_all ((GtkWidget*) _tmp18_);
		_g_object_unref0 (prefs);
		_g_object_unref0 (dlg);
	}
}
static void
action_quit (GSimpleAction *action,
             GVariant *parameter,
             gpointer user_data)
{
  GList *windows = gtk_application_get_windows (GTK_APPLICATION (user_data));
  gtk_widget_destroy (g_list_nth_data (windows, 0));
}
Ejemplo n.º 15
0
static void quit_action(GSimpleAction* action, GVariant* parameter, gpointer user_data) {
    RefImplApp* app = REFIMPL_APP(user_data);
    GList* windowListItem;

    while((windowListItem = gtk_application_get_windows(GTK_APPLICATION(app)))) {
	gtk_application_remove_window(GTK_APPLICATION(app), GTK_WINDOW(windowListItem->data));
    }
}
static void
action_help (GSimpleAction *action,
             GVariant *parameter,
             gpointer user_data)
{
  GList *windows = gtk_application_get_windows (GTK_APPLICATION (user_data));
  screenshot_display_help (g_list_nth_data (windows, 0));
}
Ejemplo n.º 17
0
static void
app_activate (GtkApplication *app)
{
    GList *list = gtk_application_get_windows (app);

    if (list) {
        gtk_window_present (GTK_WINDOW (list->data));
    }
}
Ejemplo n.º 18
0
static GdkPixbuf *
photos_base_item_create_placeholder_icon (const gchar *icon_name)
{
  GApplication *app;
  GdkPixbuf *centered_pixbuf = NULL;
  GdkPixbuf *pixbuf = NULL;
  GdkPixbuf *ret_val = NULL;
  GError *error;
  GIcon *icon = NULL;
  GList *windows;
  GtkIconInfo *info = NULL;
  GtkIconTheme *theme;
  GtkStyleContext *context;
  gint icon_size;
  gint scale;

  app = g_application_get_default ();
  windows = gtk_application_get_windows (GTK_APPLICATION (app));
  if (windows == NULL)
    goto out;

  icon = g_themed_icon_new (icon_name);
  scale = photos_application_get_scale_factor (PHOTOS_APPLICATION (app));
  theme = gtk_icon_theme_get_default ();
  info = gtk_icon_theme_lookup_by_gicon_for_scale (theme,
                                                   icon,
                                                   16,
                                                   scale,
                                                   GTK_ICON_LOOKUP_FORCE_SIZE | GTK_ICON_LOOKUP_FORCE_SYMBOLIC);
  if (info == NULL)
    goto out;

  context = gtk_widget_get_style_context (GTK_WIDGET (windows->data));

  error = NULL;
  pixbuf = gtk_icon_info_load_symbolic_for_context (info, context, NULL, &error);
  if (error != NULL)
    {
      g_warning ("Unable to load icon '%s': %s", icon_name, error->message);
      g_error_free (error);
      goto out;
    }

  icon_size = photos_utils_get_icon_size ();
  centered_pixbuf = photos_utils_center_pixbuf (pixbuf, icon_size);
  photos_utils_border_pixbuf (centered_pixbuf);

  ret_val = centered_pixbuf;
  centered_pixbuf = NULL;

 out:
  g_clear_object (&centered_pixbuf);
  g_clear_object (&pixbuf);
  g_clear_object (&info);
  g_clear_object (&icon);
  return ret_val;
}
Ejemplo n.º 19
0
void
nemo_application_quit (NemoApplication *self)
{
	GApplication *app = G_APPLICATION (self);
	GList *windows;

	windows = gtk_application_get_windows (GTK_APPLICATION (app));
	g_list_foreach (windows, (GFunc) gtk_widget_destroy, NULL);
}
Ejemplo n.º 20
0
Archivo: main.c Proyecto: raja651/gtk
static void
command_line (GApplication            *app,
              GApplicationCommandLine *cmdline)
{
  GVariantDict *options;
  const gchar *name = NULL;
  gint autoquit = 0;
  Demo *d, *c;
  GDoDemoFunc func = 0;
  GtkWidget *window, *demo;

  activate (app);

  options = g_application_command_line_get_options_dict (cmdline);
  g_variant_dict_lookup (options, "run", "&s", &name);
  g_variant_dict_lookup (options, "autoquit", "i", &autoquit);

  if (name == NULL)
    goto out;

  window = gtk_application_get_windows (GTK_APPLICATION (app))->data;

  d = gtk_demos;

  while (d->title)
    {
      c = d->children;
      if (g_strcmp0 (d->name, name) == 0)
        {
          func = d->func;
          goto out;
        }
      d++;
      while (c && c->title)
        {
          if (g_strcmp0 (c->name, name) == 0)
            {
              func = c->func;
              goto out;
            }
          c++;
        }
    }

out:
  if (func)
    {
      demo = (func) (window);

      gtk_window_set_transient_for (GTK_WINDOW (demo), GTK_WINDOW (window));
      gtk_window_set_modal (GTK_WINDOW (demo), TRUE);
    }

  if (autoquit > 0)
    g_timeout_add_seconds (autoquit, auto_quit, app);
}
Ejemplo n.º 21
0
static GAction *
get_corresponding_window_action (GtkApplication *app,
                                 GAction        *action)
{
  GList *windows = gtk_application_get_windows (app);
  const char *name;

  name = g_action_get_name (G_ACTION (action));
  return g_action_map_lookup_action (G_ACTION_MAP (windows->data), name);
}
Ejemplo n.º 22
0
static void
activate (GApplication *app,
          gpointer      user_data)
{
    GtkWidget *win;
    GtkWidget *button;
    GSimpleActionGroup *doc_actions;
    GtkBuilder *builder;
    GMenuModel *doc_menu;
    GMenuModel *win_menu;
    GMenu *button_menu;
    GMenuItem *section;

    if (gtk_application_get_windows (GTK_APPLICATION (app)) != NULL)
        return;

    win = gtk_application_window_new (GTK_APPLICATION (app));

    doc_actions = g_simple_action_group_new ();
    g_action_map_add_action_entries (G_ACTION_MAP (doc_actions), doc_entries, G_N_ELEMENTS (doc_entries), win);

    g_action_map_add_action_entries (G_ACTION_MAP (win), win_entries,
                                     G_N_ELEMENTS (win_entries), win);

    builder = gtk_builder_new ();
    gtk_builder_add_from_string (builder, menu_ui, -1, NULL);

    doc_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "doc-menu"));
    win_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "win-menu"));

    button_menu = g_menu_new ();

    section = g_menu_item_new_section (NULL, doc_menu);
    g_menu_item_set_attribute (section, "action-namespace", "s", "doc");
    g_menu_append_item (button_menu, section);
    g_object_unref (section);

    section = g_menu_item_new_section (NULL, win_menu);
    g_menu_item_set_attribute (section, "action-namespace", "s", "win");
    g_menu_append_item (button_menu, section);
    g_object_unref (section);

    button = gtk_menu_button_new ();
    gtk_button_set_label (GTK_BUTTON (button), "Menu");
    gtk_widget_insert_action_group (button, "doc", G_ACTION_GROUP (doc_actions));
    gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), G_MENU_MODEL (button_menu));

    gtk_container_add (GTK_CONTAINER (win), button);
    gtk_container_set_border_width (GTK_CONTAINER (win), 12);
    gtk_widget_show_all (win);

    g_object_unref (button_menu);
    g_object_unref (doc_actions);
    g_object_unref (builder);
}
Ejemplo n.º 23
0
static GtkWidget *
_gth_application_get_current_window (GApplication *application)
{
        GList *windows;

        windows = gtk_application_get_windows (GTK_APPLICATION (application));
        if (windows == NULL)
        	return NULL;

        return GTK_WIDGET (windows->data);
}
Ejemplo n.º 24
0
static void
action_quit (GSimpleAction *action,
             GVariant      *parameter,
             gpointer       user_data)
{
	GList *windows;

	windows = gtk_application_get_windows (GTK_APPLICATION (user_data));

	g_list_foreach (windows, (GFunc) eog_window_close, NULL);
}
Ejemplo n.º 25
0
void
gth_application_activate_quit (GSimpleAction *action,
			       GVariant      *parameter,
			       gpointer       user_data)
{
        GApplication *application = user_data;
        GList        *windows;

        windows = gtk_application_get_windows (GTK_APPLICATION (application));
        if (windows != NULL)
        	gth_quit (FALSE);
}
Ejemplo n.º 26
0
static void
quit_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
{
    GList *l;

    while ((l = gtk_application_get_windows(GTK_APPLICATION(user_data)))) {
        gtk_application_remove_window(
                GTK_APPLICATION(user_data),
                GTK_WINDOW(l->data)
            );
    }
}
Ejemplo n.º 27
0
static void
activate_about (GSimpleAction *action,
		GVariant      *parameter,
		gpointer       user_data)
{
	GApplication *application = user_data;
	GList        *windows;

	windows = gtk_application_get_windows (GTK_APPLICATION (application));
	if (windows != NULL)
		activate_action_about (NULL, windows->data);
}
Ejemplo n.º 28
0
static void
action_quit (GSimpleAction *action,
	     GVariant *parameter,
	     gpointer user_data)
{
	GtkApplication *application = user_data;
	GList *windows;

	/* nautilus_window_close() doesn't do anything for desktop windows */
	windows = gtk_application_get_windows (application);
	g_list_foreach (windows, (GFunc) nautilus_window_close, NULL);
}
Ejemplo n.º 29
0
void
activate_action_quit (GtkAction *action,
		      gpointer   data)
{
	GList *windows;

	/* Copy the list to avoid possible errors if the original list is
	 * modified after closing a window. */
	windows = g_list_copy (gtk_application_get_windows (GTK_APPLICATION (g_application_get_default ())));
	g_list_foreach (windows, (GFunc) fr_window_close, NULL);

	g_list_free (windows);
}
Ejemplo n.º 30
0
static void
fcitx_config_wizard_app_activate(GApplication *application)
{
    GList* list = gtk_application_get_windows(GTK_APPLICATION(application));
    if (list) {
        gtk_window_present(GTK_WINDOW(list->data));
    } else {
        GtkWidget *window;
        window = create_assistant();
        gtk_application_add_window(GTK_APPLICATION(application), GTK_WINDOW(window));
        gtk_widget_show_all(GTK_WIDGET(window));
    }
}