Rename greeter the ui file and gtkrc file to make them gtk2-specific. This ease futur...
authorHong Jen Yee (PCMan) <pcman.tw@gmail.com>
Sun, 11 Nov 2012 06:49:57 +0000 (14:49 +0800)
committerHong Jen Yee (PCMan) <pcman.tw@gmail.com>
Sun, 11 Nov 2012 06:51:20 +0000 (14:51 +0800)
configure.ac
data/Makefile.am
data/themes/Industrial/Makefile.am [new file with mode: 0644]
data/themes/Industrial/greeter-gtk2.ui [new file with mode: 0644]
data/themes/Industrial/greeter.ui [deleted file]
data/themes/Industrial/gtk2.rc [new file with mode: 0644]
data/themes/Industrial/gtkrc [deleted file]
data/themes/Makefile.am [new file with mode: 0644]
src/lightdm-gtk-builder-greeter.c

index 13d6674..e20d301 100644 (file)
@@ -105,6 +105,8 @@ AC_CONFIG_FILES([
     Makefile
     src/Makefile
     data/Makefile
+    data/themes/Makefile
+    data/themes/Industrial/Makefile
     data/themes/Industrial/index.theme
     po/Makefile.in
 ])
index 027cd96..3e6a7f6 100644 (file)
@@ -1,6 +1,7 @@
 NULL=
 
 SUBDIRS= \
+       themes \
        $(NULL)
 
 xgreetersdir = $(datadir)/xgreeters
@@ -13,18 +14,6 @@ xgreeters_DATA = $(xgreeters_in_files:.desktop.in=.desktop)
 configdir = $(sysconfdir)/lightdm
 config_DATA = lightdm-gtk-builder-greeter.conf
 
-themedir=$(datadir)/lightdm-gtk-builder-greeter/themes/Industrial
-theme_DATA= \
-       themes/Industrial/greeter.ui \
-       themes/Industrial/login.png \
-       themes/Industrial/shade.png \
-       themes/Industrial/index.theme \
-       themes/Industrial/gtkrc \
-       themes/Industrial/lang.png \
-       themes/Industrial/session.png \
-       themes/Industrial/wave.svg \
-       $(NULL)
-
 if GLADE_SUPPORT
 gladedir=$(GLADE_CATALOG_DIR)
 glade_DATA= \
@@ -38,6 +27,5 @@ endif
 EXTRA_DIST= \
        $(xgreeters_DATA) \
        $(config_DATA) \
-       $(theme_DATA) \
        $(glade_DATA) \
        $(NULL)
diff --git a/data/themes/Industrial/Makefile.am b/data/themes/Industrial/Makefile.am
new file mode 100644 (file)
index 0000000..4531318
--- /dev/null
@@ -0,0 +1,17 @@
+NULL=
+
+themedir=$(datadir)/lightdm-gtk-builder-greeter/themes/Industrial
+theme_DATA= \
+       greeter-gtk2.ui \
+       gtk2.rc \
+       login.png \
+       shade.png \
+       index.theme \
+       lang.png \
+       session.png \
+       wave.svg \
+       $(NULL)
+
+EXTRA_DIST= \
+       $(theme_DATA) \
+       $(NULL)
diff --git a/data/themes/Industrial/greeter-gtk2.ui b/data/themes/Industrial/greeter-gtk2.ui
new file mode 100644 (file)
index 0000000..f37df1f
--- /dev/null
@@ -0,0 +1,222 @@
+<?xml version="1.0"?>
+<interface>
+  <!-- interface-requires gtk+ 2.12 -->
+  <!-- interface-requires ldmwidget 0.0 -->
+  <!-- interface-naming-policy project-wide -->
+  <object class="GtkWindow" id="win">
+    <child>
+      <object class="LdmLayout" id="top_box">
+        <property name="visible">True</property>
+        <property name="image">wave.svg</property>
+        <property name="color">#000000000000</property>
+        <property name="alpha">0</property>
+        <child>
+          <object class="GtkLabel" id="time">
+            <property name="visible">True</property>
+            <property name="xalign">1</property>
+            <property name="xpad">12</property>
+            <property name="ypad">12</property>
+            <property name="single_line_mode">True</property>
+          </object>
+          <packing>
+            <property name="top_padding">10</property>
+            <property name="right_padding">10</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkVBox" id="vbox2">
+            <property name="visible">True</property>
+            <child>
+              <object class="GtkImage" id="image1">
+                <property name="visible">True</property>
+                <property name="pixbuf">login.png</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkAlignment" id="alignment1">
+                <property name="visible">True</property>
+                <property name="xscale">0</property>
+                <property name="yscale">0</property>
+                <child>
+                  <object class="GtkHBox" id="hbox3">
+                    <property name="height_request">60</property>
+                    <property name="visible">True</property>
+                    <property name="spacing">12</property>
+                    <child>
+                      <object class="GtkLabel" id="prompt">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">login:</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="login_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">&#x25CF;</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="x_align">0.5</property>
+            <property name="y_align">0.5</property>
+          </packing>
+        </child>
+        <child>
+          <object class="LdmLayout" id="bottom_pane">
+            <property name="visible">True</property>
+            <property name="color">#000000000000</property>
+            <property name="alpha">0.59999999999999998</property>
+            <child>
+              <object class="GtkHBox" id="bottom_hbox">
+                <property name="visible">True</property>
+                <property name="border_width">6</property>
+                <property name="spacing">12</property>
+                <child>
+                  <object class="GtkHBox" id="sessions_box">
+                    <property name="visible">True</property>
+                    <property name="spacing">6</property>
+                    <child>
+                      <object class="GtkImage" id="image2">
+                        <property name="visible">True</property>
+                        <property name="pixbuf">session.png</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label2">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">Desktop:</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkComboBoxEntry" id="sessions">
+                        <property name="visible">True</property>
+                        <property name="text_column">0</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label3">
+                    <property name="label" translatable="yes">Keyboard Layout:</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkComboBox" id="keyboard"/>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="position">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHBox" id="lang_box">
+                    <property name="visible">True</property>
+                    <property name="spacing">6</property>
+                    <child>
+                      <object class="GtkImage" id="image3">
+                        <property name="visible">True</property>
+                        <property name="pixbuf">lang.png</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label_lang">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">Language:</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkComboBoxEntry" id="lang">
+                        <property name="visible">True</property>
+                        <property name="text_column">0</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="position">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="exit_btn">
+                    <property name="label">gtk-quit</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="relief">none</property>
+                    <property name="use_stock">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="pack_type">end</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="width">100%</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="bottom_padding">0</property>
+            <property name="width">100%</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/data/themes/Industrial/greeter.ui b/data/themes/Industrial/greeter.ui
deleted file mode 100644 (file)
index f37df1f..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-<?xml version="1.0"?>
-<interface>
-  <!-- interface-requires gtk+ 2.12 -->
-  <!-- interface-requires ldmwidget 0.0 -->
-  <!-- interface-naming-policy project-wide -->
-  <object class="GtkWindow" id="win">
-    <child>
-      <object class="LdmLayout" id="top_box">
-        <property name="visible">True</property>
-        <property name="image">wave.svg</property>
-        <property name="color">#000000000000</property>
-        <property name="alpha">0</property>
-        <child>
-          <object class="GtkLabel" id="time">
-            <property name="visible">True</property>
-            <property name="xalign">1</property>
-            <property name="xpad">12</property>
-            <property name="ypad">12</property>
-            <property name="single_line_mode">True</property>
-          </object>
-          <packing>
-            <property name="top_padding">10</property>
-            <property name="right_padding">10</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkVBox" id="vbox2">
-            <property name="visible">True</property>
-            <child>
-              <object class="GtkImage" id="image1">
-                <property name="visible">True</property>
-                <property name="pixbuf">login.png</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkAlignment" id="alignment1">
-                <property name="visible">True</property>
-                <property name="xscale">0</property>
-                <property name="yscale">0</property>
-                <child>
-                  <object class="GtkHBox" id="hbox3">
-                    <property name="height_request">60</property>
-                    <property name="visible">True</property>
-                    <property name="spacing">12</property>
-                    <child>
-                      <object class="GtkLabel" id="prompt">
-                        <property name="visible">True</property>
-                        <property name="label" translatable="yes">login:</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkEntry" id="login_entry">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="invisible_char">&#x25CF;</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="x_align">0.5</property>
-            <property name="y_align">0.5</property>
-          </packing>
-        </child>
-        <child>
-          <object class="LdmLayout" id="bottom_pane">
-            <property name="visible">True</property>
-            <property name="color">#000000000000</property>
-            <property name="alpha">0.59999999999999998</property>
-            <child>
-              <object class="GtkHBox" id="bottom_hbox">
-                <property name="visible">True</property>
-                <property name="border_width">6</property>
-                <property name="spacing">12</property>
-                <child>
-                  <object class="GtkHBox" id="sessions_box">
-                    <property name="visible">True</property>
-                    <property name="spacing">6</property>
-                    <child>
-                      <object class="GtkImage" id="image2">
-                        <property name="visible">True</property>
-                        <property name="pixbuf">session.png</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="label2">
-                        <property name="visible">True</property>
-                        <property name="label" translatable="yes">Desktop:</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkComboBoxEntry" id="sessions">
-                        <property name="visible">True</property>
-                        <property name="text_column">0</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="position">2</property>
-                      </packing>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="label3">
-                    <property name="label" translatable="yes">Keyboard Layout:</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="position">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkComboBox" id="keyboard"/>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="position">3</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkHBox" id="lang_box">
-                    <property name="visible">True</property>
-                    <property name="spacing">6</property>
-                    <child>
-                      <object class="GtkImage" id="image3">
-                        <property name="visible">True</property>
-                        <property name="pixbuf">lang.png</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="label_lang">
-                        <property name="visible">True</property>
-                        <property name="label" translatable="yes">Language:</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkComboBoxEntry" id="lang">
-                        <property name="visible">True</property>
-                        <property name="text_column">0</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="position">2</property>
-                      </packing>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="position">4</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkButton" id="exit_btn">
-                    <property name="label">gtk-quit</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="relief">none</property>
-                    <property name="use_stock">True</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="pack_type">end</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="width">100%</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="bottom_padding">0</property>
-            <property name="width">100%</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-  </object>
-</interface>
diff --git a/data/themes/Industrial/gtk2.rc b/data/themes/Industrial/gtk2.rc
new file mode 100644 (file)
index 0000000..fcd440e
--- /dev/null
@@ -0,0 +1,21 @@
+style "time"
+{
+    fg[NORMAL]="#ffffff"
+    font_name="Sans 12"
+}
+
+style "prompt"
+{
+    fg[NORMAL]="#000000"
+    font_name="Sans Bold 14"
+}
+
+style "bottom"
+{
+    fg[NORMAL]="#ffffff"
+    font_name="Sans 12"
+}
+
+widget "win.*.time" style "time"
+widget "win.*.prompt" style "prompt"
+widget "win.*.bottom_hbox.*" style "bottom"
diff --git a/data/themes/Industrial/gtkrc b/data/themes/Industrial/gtkrc
deleted file mode 100644 (file)
index fcd440e..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-style "time"
-{
-    fg[NORMAL]="#ffffff"
-    font_name="Sans 12"
-}
-
-style "prompt"
-{
-    fg[NORMAL]="#000000"
-    font_name="Sans Bold 14"
-}
-
-style "bottom"
-{
-    fg[NORMAL]="#ffffff"
-    font_name="Sans 12"
-}
-
-widget "win.*.time" style "time"
-widget "win.*.prompt" style "prompt"
-widget "win.*.bottom_hbox.*" style "bottom"
diff --git a/data/themes/Makefile.am b/data/themes/Makefile.am
new file mode 100644 (file)
index 0000000..97076e1
--- /dev/null
@@ -0,0 +1,5 @@
+NULL=
+
+SUBDIRS= \
+       Industrial \
+       $(NULL)
index cbf0c5e..cf99e84 100644 (file)
 #include <unistd.h>
 #include <stdlib.h>
 
+#if GTK_CHECK_VERSION(3, 0, 0)
+    #define GREETER_UI_FILE "greeter-gtk3.ui"
+    #define GTK_CSS_FILE    "gtk3.css"
+#elif GTK_CHECK_VERSION(2, 0, 0)
+    #define GREETER_UI_FILE "greeter-gtk2.ui"
+    #define GTK_RC_FILE    "gtk2.rc"
+#endif
+
 static char* test_dir = NULL;
 static LightDMGreeter *greeter = NULL;
 static char* theme_dir = NULL;
@@ -314,7 +322,6 @@ static void load_languages()
     const GList* langs = lightdm_get_languages();
     const GList* l;
     GtkListStore* list = gtk_list_store_new(2, G_TYPE_STRING, LIGHTDM_TYPE_LANGUAGE);
-    g_debug("def: %s", default_lang);
     for(l = langs; l; l=l->next)
     {
         LightDMLanguage* lang = LIGHTDM_LANGUAGE(l->data);
@@ -343,6 +350,54 @@ static void on_exit_btn_clicked(GtkButton* btn, GtkMenu* menu)
     gtk_menu_popup(menu, NULL, NULL, NULL, btn, 1, gtk_get_current_event_time());
 }
 
+static void show_error(const char* title, const char* message)
+{
+    GtkWidget* dlg = gtk_message_dialog_new(GTK_WINDOW(win), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, message);
+    gtk_window_set_title(GTK_WINDOW(dlg), title ? title:_("Error"));
+    gtk_dialog_run(GTK_DIALOG(dlg));
+    gtk_widget_destroy(dlg);
+}
+
+static void on_suspend(GtkMenuItem* item, gpointer user_data)
+{
+    GError* error = NULL;
+    if(!lightdm_suspend(&error))
+    {
+        show_error(NULL, error->message);
+        g_error_free(error);
+    }
+}
+
+static void on_hibernate(GtkMenuItem* item, gpointer user_data)
+{
+    GError* error = NULL;
+    if(!lightdm_hibernate(&error))
+    {
+        show_error(NULL, error->message);
+        g_error_free(error);
+    }
+}
+
+static void on_restart(GtkMenuItem* item, gpointer user_data)
+{
+    GError* error = NULL;
+    if(!lightdm_restart(&error))
+    {
+        show_error(NULL, error->message);
+        g_error_free(error);
+    }
+}
+
+static void on_shutdown(GtkMenuItem* item, gpointer user_data)
+{
+    GError* error = NULL;
+    if(!lightdm_shutdown(&error))
+    {
+        show_error(NULL, error->message);
+        g_error_free(error);
+    }
+}
+
 static void load_exit_btn()
 {
     GtkWidget* menu = gtk_menu_new();
@@ -351,26 +406,25 @@ static void load_exit_btn()
     {
         item = gtk_menu_item_new_with_label(_("Suspend"));
         gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-        g_signal_connect_swapped(item, "activate", G_CALLBACK(lightdm_suspend), greeter);
+        g_signal_connect(item, "activate", G_CALLBACK(on_suspend), NULL);
     }
     if(lightdm_get_can_hibernate())
     {
         item = gtk_menu_item_new_with_label(_("Hibernate"));
         gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-        g_signal_connect_swapped(item, "activate", G_CALLBACK(lightdm_hibernate), greeter);
+        g_signal_connect(item, "activate", G_CALLBACK(on_hibernate), NULL);
     }
     if(lightdm_get_can_restart())
     {
         item = gtk_menu_item_new_with_label(_("Restart"));
         gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-        g_signal_connect_swapped(item, "activate", G_CALLBACK(lightdm_restart), greeter);
+        g_signal_connect(item, "activate", G_CALLBACK(on_restart), NULL);
     }
-    g_debug("lightdm_get_can_shutdown() = %d", lightdm_get_can_shutdown());
     if(lightdm_get_can_shutdown())
     {
         item = gtk_menu_item_new_with_label(_("Shutdown"));
         gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-        g_signal_connect_swapped(item, "activate", G_CALLBACK(lightdm_shutdown), greeter);
+        g_signal_connect(item, "activate", G_CALLBACK(on_shutdown), NULL);
     }
     gtk_widget_show_all(menu);
     g_signal_connect_swapped(exit_btn, "destroy", G_CALLBACK(gtk_widget_destroy), menu);
@@ -396,7 +450,7 @@ static gboolean show_ui()
 
     /* we don't want to use the theme mechanism provided by lightdm. */
     GtkBuilder* builder = gtk_builder_new();
-    char* file = g_build_filename(theme_dir, "greeter.ui", NULL);
+    char* file = g_build_filename(theme_dir, GREETER_UI_FILE, NULL);
 
     if(!gtk_builder_add_from_file(builder, file, &err))
     {
@@ -558,7 +612,7 @@ int main(int argc, char** argv)
 
 #if GTK_CHECK_VERSION(3, 0, 0)
     /* NOTE: this piece of code is not yet tested */
-    char* gtkcss = g_build_filename(theme_dir, "gtk.css", NULL);
+    char* gtkcss = g_build_filename(theme_dir, GTK_CSS_FILE, NULL);
     GtkCssProvider *css = gtk_css_provider_new();
     gtk_css_provider_load_from_path(css, gtkcss, NULL);
     g_free(gtkcss);
@@ -568,7 +622,7 @@ int main(int argc, char** argv)
     g_object_unref(css);
 #else
      /* GTK+ 2.x */
-    char* gtkrc = g_build_filename(theme_dir, "gtkrc", NULL);
+    char* gtkrc = g_build_filename(theme_dir, GTK_RC_FILE, NULL);
     gtk_rc_parse(gtkrc);
     g_free(gtkrc);
 #endif