mirror of
https://gitlab.gnome.org/GNOME/glade.git
synced 2025-08-27 00:02:47 -04:00
* src/main.c, src/glade-window.c: Make Glade use GtkApplication, now Glade is
a single instance app. * data/icons/Makefile.am, data/desktop.in.in: Rename the 'glade-3' icon to 'glade'
This commit is contained in:
parent
53f9cdf1e7
commit
3d55aa8f54
@ -8,6 +8,11 @@
|
||||
this out by just using the "parent" xml attribute and deriving GtkWindow and
|
||||
disabling all the irrelevant GtkWindow properties.
|
||||
|
||||
* src/main.c, src/glade-window.c: Make Glade use GtkApplication, now Glade is
|
||||
a single instance app.
|
||||
|
||||
* data/icons/Makefile.am, data/desktop.in.in: Rename the 'glade-3' icon to 'glade'
|
||||
|
||||
2011-01-28 Tristan Van Berkom <tristanvb@openismus.com>
|
||||
|
||||
* gladeui/glade-xml-utils.h, gladeui/glade-widget-adaptor.[ch], gladeui/glade-widget.[ch]:
|
||||
|
@ -7,7 +7,7 @@ Exec=glade %F
|
||||
Terminal=false
|
||||
StartupNotify=true
|
||||
Type=Application
|
||||
Icon=glade-3
|
||||
Icon=glade
|
||||
Categories=GNOME;GTK;Development;GUIDesigner;
|
||||
MimeType=application/x-glade;
|
||||
X-GNOME-DocPath=glade/glade.xml
|
||||
|
@ -20,4 +20,4 @@ pixmapsdir = $(pkgdatadir)/pixmaps
|
||||
pixmaps_DATA = selector.png devhelp.png plus.png atk.png drag-resize.png fixed-bg.png placeholder.png
|
||||
|
||||
|
||||
EXTRA_DIST = $(pixmaps_DATA) glade-3.ico
|
||||
EXTRA_DIST = $(pixmaps_DATA) glade.ico
|
||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
@ -149,6 +149,7 @@ static void check_reload_project (GladeWindow * window, GladeProject * project);
|
||||
|
||||
static void glade_window_config_save (GladeWindow * window);
|
||||
|
||||
static void glade_window_check_devhelp (GladeWindow * window);
|
||||
|
||||
G_DEFINE_TYPE (GladeWindow, glade_window, GTK_TYPE_WINDOW)
|
||||
|
||||
@ -3559,7 +3560,7 @@ glade_window_init (GladeWindow * window)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
glade_window_check_devhelp (window);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -3601,7 +3602,7 @@ glade_window_new (void)
|
||||
return g_object_new (GLADE_TYPE_WINDOW, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
glade_window_check_devhelp (GladeWindow * window)
|
||||
{
|
||||
g_return_if_fail (GLADE_IS_WINDOW (window));
|
||||
|
@ -56,7 +56,7 @@ void glade_window_new_project (GladeWindow *window);
|
||||
gboolean glade_window_open_project (GladeWindow *window,
|
||||
const gchar *path);
|
||||
|
||||
void glade_window_check_devhelp (GladeWindow *window);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
205
src/main.c
205
src/main.c
@ -41,39 +41,147 @@
|
||||
#define APPLICATION_NAME (_("Glade"))
|
||||
|
||||
|
||||
/* Application arguments */
|
||||
static gboolean version = FALSE, without_devhelp = FALSE;
|
||||
static gchar **files = NULL;
|
||||
#define TYPE_GLADE (glade_get_type())
|
||||
#define GLADE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GLADE, Glade))
|
||||
|
||||
typedef struct _Glade Glade;
|
||||
typedef struct _GladeClass GladeClass;
|
||||
|
||||
struct _Glade {
|
||||
GtkApplication application;
|
||||
|
||||
GladeWindow *window;
|
||||
};
|
||||
|
||||
struct _GladeClass {
|
||||
GtkApplicationClass application_class;
|
||||
};
|
||||
|
||||
|
||||
static GType glade_get_type (void) G_GNUC_CONST;
|
||||
static void glade_finalize (GObject *object);
|
||||
static void glade_open (GApplication *application,
|
||||
GFile **files,
|
||||
gint n_files,
|
||||
const gchar *hint);
|
||||
static void glade_startup (GApplication *application);
|
||||
static void glade_activate (GApplication *application);
|
||||
|
||||
G_DEFINE_TYPE (Glade, glade, GTK_TYPE_APPLICATION)
|
||||
|
||||
static gboolean
|
||||
open_new_project (Glade *glade)
|
||||
{
|
||||
if (!glade_app_get_projects ())
|
||||
glade_window_new_project (glade->window);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
glade_init (Glade *glade)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
glade_class_init (GladeClass *glade_class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (glade_class);
|
||||
GApplicationClass *application_class = G_APPLICATION_CLASS (glade_class);
|
||||
|
||||
object_class->finalize = glade_finalize;
|
||||
|
||||
application_class->open = glade_open;
|
||||
application_class->startup = glade_startup;
|
||||
application_class->activate = glade_activate;
|
||||
}
|
||||
|
||||
static void
|
||||
glade_finalize (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (glade_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_open (GApplication *application,
|
||||
GFile **files,
|
||||
gint n_files,
|
||||
const gchar *hint)
|
||||
{
|
||||
Glade *glade = GLADE (application);
|
||||
gint i;
|
||||
gchar *path;
|
||||
|
||||
for (i = 0; i < n_files; i++)
|
||||
{
|
||||
if ((path = g_file_get_path (files[i])) != NULL)
|
||||
{
|
||||
glade_window_open_project (glade->window, path);
|
||||
|
||||
g_free (path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
glade_startup (GApplication *application)
|
||||
{
|
||||
Glade *glade = GLADE (application);
|
||||
|
||||
glade_setup_log_handlers ();
|
||||
|
||||
glade->window = GLADE_WINDOW (glade_window_new ());
|
||||
gtk_window_set_application (GTK_WINDOW (glade->window), GTK_APPLICATION (application));
|
||||
|
||||
gtk_widget_show (GTK_WIDGET (glade->window));
|
||||
|
||||
g_idle_add ((GSourceFunc)open_new_project, glade);
|
||||
|
||||
g_print ("Glade starting up\n");
|
||||
|
||||
G_APPLICATION_CLASS (glade_parent_class)->startup (application);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_activate (GApplication *application)
|
||||
{
|
||||
g_print ("Who knows what the GApplication:activate is for anyway\n");
|
||||
}
|
||||
|
||||
|
||||
static Glade *
|
||||
glade_new (void)
|
||||
{
|
||||
Glade *glade =
|
||||
g_object_new (TYPE_GLADE,
|
||||
"application-id", "org.gnome.Glade",
|
||||
"flags", G_APPLICATION_HANDLES_OPEN,
|
||||
NULL);
|
||||
|
||||
return glade;
|
||||
}
|
||||
|
||||
/* Version argument parsing */
|
||||
static gboolean version = FALSE;
|
||||
|
||||
static GOptionEntry option_entries[] = {
|
||||
{"version", '\0', 0, G_OPTION_ARG_NONE, &version,
|
||||
N_("Output version information and exit"), NULL},
|
||||
|
||||
{"without-devhelp", '\0', 0, G_OPTION_ARG_NONE, &without_devhelp,
|
||||
N_("Disable Devhelp integration"), NULL},
|
||||
|
||||
{G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &files,
|
||||
NULL, N_("[FILE...]")},
|
||||
|
||||
{NULL}
|
||||
};
|
||||
|
||||
/* Debugging arguments */
|
||||
static gboolean verbose = FALSE;
|
||||
|
||||
static GOptionEntry debug_option_entries[] = {
|
||||
{"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, N_("be verbose"), NULL},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GladeWindow *window;
|
||||
GOptionContext *option_context;
|
||||
GOptionGroup *option_group;
|
||||
GError *error = NULL;
|
||||
gboolean opened_project = FALSE;
|
||||
Glade *glade;
|
||||
gint status;
|
||||
|
||||
g_type_init ();
|
||||
|
||||
if (!g_thread_supported ())
|
||||
g_thread_init (NULL);
|
||||
@ -99,17 +207,6 @@ main (int argc, char *argv[])
|
||||
g_option_context_set_main_group (option_context, option_group);
|
||||
g_option_group_set_translation_domain (option_group, GETTEXT_PACKAGE);
|
||||
|
||||
option_group = g_option_group_new ("debug",
|
||||
N_("Glade debug options"),
|
||||
N_("Show Glade debug options"),
|
||||
NULL, NULL);
|
||||
g_option_group_add_entries (option_group, debug_option_entries);
|
||||
g_option_group_set_translation_domain (option_group, GETTEXT_PACKAGE);
|
||||
g_option_context_add_group (option_context, option_group);
|
||||
|
||||
/* Add Gtk option group */
|
||||
g_option_context_add_group (option_context, gtk_get_option_group (FALSE));
|
||||
|
||||
/* Parse command line */
|
||||
if (!g_option_context_parse (option_context, &argc, &argv, &error))
|
||||
{
|
||||
@ -136,11 +233,6 @@ main (int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Pass NULL here since we parsed the gtk+ args already...
|
||||
* from this point on we need a DISPLAY variable to be set.
|
||||
*/
|
||||
gtk_init (NULL, NULL);
|
||||
|
||||
/* Check for gmodule support */
|
||||
if (!g_module_supported ())
|
||||
{
|
||||
@ -149,44 +241,17 @@ main (int argc, char *argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
g_set_application_name (APPLICATION_NAME);
|
||||
gtk_window_set_default_icon_name ("glade-3");
|
||||
gtk_window_set_default_icon_name ("glade");
|
||||
|
||||
glade_setup_log_handlers ();
|
||||
/* Fire it up */
|
||||
glade = glade_new ();
|
||||
status = g_application_run (G_APPLICATION (glade), argc, argv);
|
||||
g_object_unref (glade);
|
||||
|
||||
|
||||
window = GLADE_WINDOW (glade_window_new ());
|
||||
|
||||
if (without_devhelp == FALSE)
|
||||
glade_window_check_devhelp (window);
|
||||
|
||||
gtk_widget_show (GTK_WIDGET (window));
|
||||
|
||||
/* load files specified on commandline */
|
||||
if (files != NULL)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; files[i]; ++i)
|
||||
{
|
||||
if (g_file_test (files[i], G_FILE_TEST_EXISTS) != FALSE)
|
||||
{
|
||||
if (glade_window_open_project (window, files[i]))
|
||||
opened_project = TRUE;
|
||||
}
|
||||
else
|
||||
g_warning (_("Unable to open '%s', the file does not exist.\n"),
|
||||
files[i]);
|
||||
}
|
||||
g_strfreev (files);
|
||||
}
|
||||
|
||||
if (!opened_project)
|
||||
glade_window_new_project (window);
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
return status;
|
||||
}
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
|
Loading…
x
Reference in New Issue
Block a user