Author: pollux
Date: 2006-07-23 22:45:09 +0000 (Sun, 23 Jul 2006)
New Revision: 22519

Modified:
   xfburn/trunk/xfburn/xfburn-composition.c
   xfburn/trunk/xfburn/xfburn-composition.h
   xfburn/trunk/xfburn/xfburn-compositions-notebook.c
   xfburn/trunk/xfburn/xfburn-data-composition.c
   xfburn/trunk/xfburn/xfburn-disc-usage.c
   xfburn/trunk/xfburn/xfburn-main-window.c
Log:
* prevent the user to open the burning dialog if the composition is bigger than 
the media
* rename tab and menu label if the user saves the composition



Modified: xfburn/trunk/xfburn/xfburn-composition.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-composition.c    2006-07-23 21:23:19 UTC (rev 
22518)
+++ xfburn/trunk/xfburn/xfburn-composition.c    2006-07-23 22:45:09 UTC (rev 
22519)
@@ -31,6 +31,7 @@
 /*******************************************/
 /* interface definition and initialization */
 /*******************************************/
+static guint composition_signals[LAST_SIGNAL];
 
 static void
 xfburn_composition_base_init (gpointer g_iface)
@@ -38,6 +39,11 @@
   static gboolean initialized = FALSE;
 
   if (!initialized) {
+    composition_signals[NAME_CHANGED] = g_signal_new ("name-changed", 
XFBURN_TYPE_COMPOSITION, G_SIGNAL_ACTION,
+                                                      G_STRUCT_OFFSET 
(XfburnCompositionInterface, name_changed),
+                                                      NULL, NULL, 
g_cclosure_marshal_VOID__STRING,
+                                                      G_TYPE_NONE, 1, 
G_TYPE_STRING);
+    
     initialized = TRUE;
   }
 }

Modified: xfburn/trunk/xfburn/xfburn-composition.h
===================================================================
--- xfburn/trunk/xfburn/xfburn-composition.h    2006-07-23 21:23:19 UTC (rev 
22518)
+++ xfburn/trunk/xfburn/xfburn-composition.h    2006-07-23 22:45:09 UTC (rev 
22519)
@@ -28,10 +28,10 @@
 
 G_BEGIN_DECLS
 
-#define XFBURN_COMPOSITION_TYPE                (xfburn_composition_get_type ())
-#define XFBURN_COMPOSITION(obj)                (G_TYPE_CHECK_INSTANCE_CAST 
((obj), XFBURN_COMPOSITION_TYPE, XfburnComposition))
-#define XFBURN_IS_COMPOSITION(obj)             (G_TYPE_CHECK_INSTANCE_TYPE 
((obj), XFBURN_COMPOSITION_TYPE))
-#define XFBURN_COMPOSITION_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE 
((inst), XFBURN_COMPOSITION_TYPE, XfburnCompositionInterface))
+#define XFBURN_TYPE_COMPOSITION                (xfburn_composition_get_type ())
+#define XFBURN_COMPOSITION(obj)                (G_TYPE_CHECK_INSTANCE_CAST 
((obj), XFBURN_TYPE_COMPOSITION, XfburnComposition))
+#define XFBURN_IS_COMPOSITION(obj)             (G_TYPE_CHECK_INSTANCE_TYPE 
((obj), XFBURN_TYPE_COMPOSITION))
+#define XFBURN_COMPOSITION_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE 
((inst), XFBURN_TYPE_COMPOSITION, XfburnCompositionInterface))
 
 typedef struct _XfburnCompositon XfburnComposition; /* dummy object */
   
@@ -43,6 +43,8 @@
   
   void (*load) (XfburnComposition *composition, const gchar *file);
   void (*save) (XfburnComposition *composition);
+  
+  void (*name_changed) (XfburnComposition *composition, const gchar *name);
 } XfburnCompositionInterface;
 
 GType xfburn_composition_get_type (void);

Modified: xfburn/trunk/xfburn/xfburn-compositions-notebook.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-compositions-notebook.c  2006-07-23 21:23:19 UTC 
(rev 22518)
+++ xfburn/trunk/xfburn/xfburn-compositions-notebook.c  2006-07-23 22:45:09 UTC 
(rev 22519)
@@ -129,6 +129,20 @@
   gtk_notebook_remove_page (notebook, page_num);
 }
 
+static void
+cb_composition_name_changed (XfburnComposition *composition, const gchar * 
name, XfburnCompositionsNotebook *notebook)
+{
+  guint page_num;
+  GtkWidget *tab, *menu_label;
+  
+  page_num = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), GTK_WIDGET 
(composition));
+  
+  tab = gtk_notebook_get_tab_label (GTK_NOTEBOOK (notebook), GTK_WIDGET 
(composition));
+  xfburn_notebook_tab_set_label (XFBURN_NOTEBOOK_TAB (tab), name);
+  menu_label = gtk_notebook_get_menu_label (GTK_NOTEBOOK (notebook), 
GTK_WIDGET (composition));
+  gtk_label_set_text (GTK_LABEL (menu_label), name);
+}
+
 /**********/
 /* public */
 /**********/
@@ -155,24 +169,43 @@
       label_text = g_strdup_printf ("%s %d", _("Data composition"), ++i);
       break;
     case XFBURN_AUDIO_COMPOSITION:
-      DBG ("later");
+      DBG ("don't hurry ... it'll be implemented later");
       break;
   }
   
   if (composition) {
     GtkWidget *tab = NULL;
+    GtkWidget *menu_label = NULL;
+    
     guint page_num;
     
     tab = xfburn_notebook_tab_new (label_text);
     gtk_widget_show (tab);
        
+    menu_label = gtk_label_new (label_text);
+    gtk_widget_show (menu_label);
+    
     gtk_widget_show (composition);
-    page_num = gtk_notebook_append_page(GTK_NOTEBOOK (notebook), composition, 
tab);
+    page_num = gtk_notebook_append_page_menu (GTK_NOTEBOOK (notebook), 
composition, tab, menu_label);
     gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), page_num);
        
     g_object_set_data (G_OBJECT (tab), "composition", composition);
     g_signal_connect (G_OBJECT (tab), "button-close-clicked", G_CALLBACK 
(cb_composition_close), notebook);
+    
+    g_signal_connect (G_OBJECT (composition), "name-changed", G_CALLBACK 
(cb_composition_name_changed), notebook);
   }
   
   g_free (label_text);
 }
+
+void
+xfburn_compositions_notebook_save_composition (XfburnCompositionsNotebook 
*notebook)
+{
+  XfburnComposition *composition;
+  guint page_num;
+  
+  page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
+  composition = XFBURN_COMPOSITION (gtk_notebook_get_nth_page (GTK_NOTEBOOK 
(notebook), page_num));
+  
+  xfburn_composition_save (composition);
+}

Modified: xfburn/trunk/xfburn/xfburn-data-composition.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-data-composition.c       2006-07-23 21:23:19 UTC 
(rev 22518)
+++ xfburn/trunk/xfburn/xfburn-data-composition.c       2006-07-23 22:45:09 UTC 
(rev 22519)
@@ -110,6 +110,7 @@
 typedef struct
 {
   gchar *filename;
+  gboolean modified;
   
   GtkActionGroup *action_group;
   GtkUIManager *ui_manager;
@@ -175,7 +176,7 @@
     
     data_composition_type = g_type_register_static (GTK_TYPE_VBOX, 
"XfburnDataComposition", &data_composition_info, 0);
     
-    g_type_add_interface_static (data_composition_type, 
XFBURN_COMPOSITION_TYPE, &composition_info);
+    g_type_add_interface_static (data_composition_type, 
XFBURN_TYPE_COMPOSITION, &composition_info);
   }
 
   return data_composition_type;
@@ -658,6 +659,27 @@
   }
 }
 
+static void
+set_modified (XfburnDataCompositionPrivate *priv)
+{
+  if (!(priv->modified)) {
+    XfburnMainWindow *mainwin;
+    GtkUIManager *ui_manager;
+    GtkActionGroup *action_group;
+    GtkAction *action;
+  
+    mainwin = xfburn_main_window_get_instance ();
+    ui_manager = xfburn_main_window_get_ui_manager (mainwin);
+  
+    action_group = (GtkActionGroup *) gtk_ui_manager_get_action_groups 
(ui_manager)->data;
+    
+    action = gtk_action_group_get_action (action_group, "save-composition");
+    gtk_action_set_sensitive (GTK_ACTION (action), TRUE);
+  
+    priv->modified = TRUE;
+  }
+}
+
 static gboolean
 add_file_to_list_with_name (const gchar *name, XfburnDataComposition * dc, 
GtkTreeModel * model, const gchar * path,
                             GtkTreeIter * iter, GtkTreeIter * insertion, 
GtkTreeViewDropPosition position)
@@ -814,6 +836,7 @@
     g_free (humansize);
     g_free (parent);
 
+    set_modified (priv);
     return TRUE;
   }
   
@@ -1175,6 +1198,12 @@
   CompositionSaveInfo info = {};
   gint i;
     
+  if (!(priv->filename)) {
+    priv->filename = g_strdup ("/tmp/gna");
+    
+    g_signal_emit_by_name (G_OBJECT (composition), "name-changed", 
priv->filename);
+  }
+  
   file_content = fopen (priv->filename, "w+");
   fprintf (file_content, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n");
   fprintf (file_content, "<xfburn-composition version=\"0.1\">\n");

Modified: xfburn/trunk/xfburn/xfburn-disc-usage.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-disc-usage.c     2006-07-23 21:23:19 UTC (rev 
22518)
+++ xfburn/trunk/xfburn/xfburn-disc-usage.c     2006-07-23 22:45:09 UTC (rev 
22519)
@@ -52,10 +52,11 @@
   600 *1000 * 1000, "600MB CD"},
   {
   700 *1000 * 1000, "700MB CD"},
-  {
+/*  {
   4.7 *1000 * 1000 * 1000, "4.7GB DVD"},
   {
-8.5 *1000 * 1000 * 1000, "8.5GB DVD"},};
+8.5 *1000 * 1000 * 1000, "8.5GB DVD"},*/
+};
 
 enum
 {
@@ -65,9 +66,9 @@
 
 static guint signals[LAST_SIGNAL];
 
-/***************************/
+/*******************************/
 /* XfburnDataComposition class */
-/***************************/
+/*******************************/
 GtkType
 xfburn_disc_usage_get_type (void)
 {
@@ -156,7 +157,8 @@
 
   gtk_progress_bar_set_text (GTK_PROGRESS_BAR (disc_usage->progress_bar), 
size);
 
-  if (disc_usage->size == 0)
+  if (disc_usage->size == 0 || 
+      disc_usage->size > datadisksizes[gtk_combo_box_get_active (GTK_COMBO_BOX 
(disc_usage->combo))].size)
     gtk_widget_set_sensitive (disc_usage->button, FALSE);
   else
     gtk_widget_set_sensitive (disc_usage->button, TRUE);
@@ -168,7 +170,11 @@
 static void 
 cb_button_clicked (GtkButton *button, XfburnDiscUsage *du)
 {
-  g_signal_emit (G_OBJECT (du), signals[BEGIN_BURN], 0);
+  if (du->size <= datadisksizes[gtk_combo_box_get_active (GTK_COMBO_BOX 
(du->combo))].size) {
+    g_signal_emit (G_OBJECT (du), signals[BEGIN_BURN], 0);
+  } else {
+    xfce_err (_("You are trying to burn more data than the disk can contain 
!"));
+  }
 }
 
 static void

Modified: xfburn/trunk/xfburn/xfburn-main-window.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-main-window.c    2006-07-23 21:23:19 UTC (rev 
22518)
+++ xfburn/trunk/xfburn/xfburn-main-window.c    2006-07-23 22:45:09 UTC (rev 
22519)
@@ -83,11 +83,13 @@
 static GtkWindowClass *parent_class = NULL;
 static const GtkActionEntry action_entries[] = {
   {"file-menu", NULL, N_("_File"), NULL,},
-  {"new-composition", GTK_STOCK_NEW, N_("_New composition"), "", N_("Create a 
new composition"),},
-  {"new-data-composition", GTK_STOCK_HARDDISK, N_("New data composition"), 
"<Control><Alt>e", N_("New data composition"),
+  /*{"new-composition", GTK_STOCK_NEW, N_("_New composition"), "", N_("Create 
a new composition"),},*/
+  {"new-composition", GTK_STOCK_NEW, N_("_New composition"), NULL, N_("Create 
a new composition"), 
     G_CALLBACK (xfburn_window_action_new_data_composition),},
+  /*{"new-data-composition", GTK_STOCK_HARDDISK, N_("New data composition"), 
"<Control><Alt>e", N_("New data composition"),
+    G_CALLBACK (xfburn_window_action_new_data_composition),},
   {"new-audio-composition", "audio-x-generic", N_("New audio composition"), 
"<Control><Alt>A", N_("New audio composition"),
-    G_CALLBACK (xfburn_window_action_new_audio_composition),},
+    G_CALLBACK (xfburn_window_action_new_audio_composition),},*/
   {"load-composition", GTK_STOCK_OPEN, N_("Load composition"), NULL, N_("Load 
composition"),
    G_CALLBACK (xfburn_window_action_load),},
   {"save-composition", GTK_STOCK_SAVE, N_("Save composition"), NULL, N_("Save 
composition"), 
@@ -121,6 +123,7 @@
 };
 
 static const gchar *toolbar_actions[] = {
+  "new-composition",
   "blank-cd",
   //"format-dvd",
   "copy-data",
@@ -385,7 +388,7 @@
 {
   XfburnMainWindowPrivate *priv = XFBURN_MAIN_WINDOW_GET_PRIVATE (window);
   
-  //xfburn_data_composition_save_to_file (XFBURN_DATA_COMPOSITION 
(priv->data_composition), "/tmp/test.xml");
+  xfburn_compositions_notebook_save_composition (XFBURN_COMPOSITIONS_NOTEBOOK 
(priv->compositions_notebook));
 }
 
 static void
@@ -545,6 +548,8 @@
     gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), 
xfburn_settings_get_boolean ("show-filebrowser", TRUE));
     action = gtk_action_group_get_action (priv->action_group, "show-toolbar");
     gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), 
xfburn_settings_get_boolean ("show-toolbar", TRUE));
+    action = gtk_action_group_get_action (priv->action_group, 
"save-composition");
+    gtk_action_set_sensitive (GTK_ACTION (action), FALSE);
   }
   
   return obj;

_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to